This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: Cygwin build error


> -----Original Message-----
> From: cygwin-owner@cygwin.com 
> [mailto:cygwin-owner@cygwin.com]On Behalf
> Of Corinna Vinschen
> Sent: Friday, April 28, 2006 4:28 AM
> To: newlib@sourceware.org
> Cc: cygwin@cygwin.com
> Subject: Re: Cygwin build error
> 
> 
> This is a newlib problem.  I've redirected this mail to the 
> appropriate
> list newlib AT sourceware DOT org.
> 
> On Apr 27 15:14, Ernie Coskrey wrote:
> > I ran into the following problem building the latest cygwin 
> snapshot:
> > 
> > configure: loading cache .././config.cache
> > configure: error: `CFLAGS' has changed since the previous run:
> > configure:   former value:  -O2 -g -O2  
> > configure:   current value: -O2 -g -O2 
> > configure: error: changes in the environment can compromise 
> the build
> > configure: error: run `make distclean' and/or `rm 
> .././config.cache' and start over
> > configure: error: /bin/sh 
> '../../../../src/newlib/libc/configure' failed for libc
> > 
> > By piping the output to a file, I saw that the former value 
> of CFLAGS is "-O2 -g -O2  " (two spaces), while the current 
> value is "-O2 -g -O2 " (one space).  This causes the 
> comparison in libc/configure to fail.
> > 
> > The way I've resolved this is to replace the following line:
> > 
> >       if test "x$ac_old_val" != "x$ac_new_val"; then
> > 
> > with
> > 
> >       if test "`echo $ac_old_val`" != "`echo $ac_new_val`"; then
> > 
> > wherever it appears in any "configure" script (there are 75 
> configure scripts that contain this test, BTW).  There may be 
> a more elegant way around this, but I haven't found it.  
> Running "make distclean" or removing config.cache doesn't 
> resolve the problem.
> > 
> > -----
> > Ernie Coskrey       SteelEye Technology, Inc.    803-461-3875
> 
> 
> Corinna
> 

This problem isn't limited to newlib: the same fix must be applied to a number of non-newlib configure scripts.

However, I have found a simpler solution than patching all 70-plus configure scripts.  The root of the problem
is that the variable "CFLAGS_FOR_TARGET" gets defined in the top-level Makefile as follows:

CFLAGS_FOR_TARGET = -O2 $(CFLAGS) $(SYSROOT_CFLAGS_FOR_TARGET)

Since SYSROOT_CFLAGS_FOR_TARGET is usually empty, you end up with an extra space at the end of CFLAGS_FOR_TARGET (in my case, anyway).

The following patch will resolve the problem without requiring any changes in the underlying configure scripts.  This patch is for "src/Makefile.in" - the top-level Makefile.in.  It uses the "strip" command to remove the extra whitespace from CFLAGS_FOR_TARGET and CXXFLAGS_FOR_TARGET.

--- Makefile.in.ORIG    2006-05-31 08:49:14.166500000 -0400
+++ Makefile.in 2006-05-31 11:08:25.150875000 -0400
@@ -383,7 +383,7 @@
 # CFLAGS will be just -g.  We want to ensure that TARGET libraries
 # (which we know are built with gcc) are built with optimizations so
 # prepend -O2 when setting CFLAGS_FOR_TARGET.
-CFLAGS_FOR_TARGET = -O2 $(CFLAGS) $(SYSROOT_CFLAGS_FOR_TARGET)
+CFLAGS_FOR_TARGET = $(strip -O2 $(CFLAGS) $(SYSROOT_CFLAGS_FOR_TARGET))
 SYSROOT_CFLAGS_FOR_TARGET = @SYSROOT_CFLAGS_FOR_TARGET@

 # If GCC_FOR_TARGET is not overriden on the command line, then this
@@ -423,7 +423,7 @@
     fi; \
   fi`

-CXXFLAGS_FOR_TARGET = $(CXXFLAGS) $(SYSROOT_CFLAGS_FOR_TARGET)
+CXXFLAGS_FOR_TARGET = $(strip $(CXXFLAGS) $(SYSROOT_CFLAGS_FOR_TARGET))
 LIBCXXFLAGS_FOR_TARGET = $(CXXFLAGS_FOR_TARGET) -fno-implicit-templates

 GCJ_FOR_TARGET=$(STAGE_CC_WRAPPER) @GCJ_FOR_TARGET@ $(FLAGS_FOR_TARGET)

-----
Ernie Coskrey

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]