delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2006/05/31/14:34:39

X-Spam-Check-By: sourceware.org
MIME-Version: 1.0
Subject: RE: Cygwin build error
Date: Wed, 31 May 2006 14:34:27 -0400
Message-ID: <682871732942384FA2647BF058AE9A7906A26A@steelpo1.steeleye.com>
From: "Ernie Coskrey" <Ernie DOT Coskrey AT steeleye DOT com>
To: <newlib AT sourceware DOT org>
Cc: <cygwin AT cygwin DOT com>
X-IsSubscribed: yes
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
X-MIME-Autoconverted: from quoted-printable to 8bit by delorie.com id k4VIYcpH001345

> -----Original Message-----
> From: cygwin-owner AT cygwin DOT com 
> [mailto:cygwin-owner AT cygwin DOT com]On Behalf
> Of Corinna Vinschen
> Sent: Friday, April 28, 2006 4:28 AM
> To: newlib AT sourceware DOT org
> Cc: cygwin AT cygwin DOT 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/


- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019