Bug 18222

Summary: [4.0 Regression] libjava bootstrap failure on Tru64 UNIX: CPPFLAGS changed in libltdl
Product: gcc Reporter: Rainer Orth <ro>
Component: libgcjAssignee: Not yet assigned to anyone <unassigned>
Status: RESOLVED FIXED    
Severity: critical CC: gcc-bugs, gerald, kcook, sean, tromey
Priority: P2 Keywords: build
Version: 4.0.0   
Target Milestone: 4.0.0   
Host: Target:
Build: Known to work:
Known to fail: Last reconfirmed: 2004-11-15 12:17:43
Bug Depends on:    
Bug Blocks: 17574    
Attachments: Base target CPPFLAGS on CPPFLAGS_FOR_TARGET

Description Rainer Orth 2004-10-29 17:51:42 UTC
Bootstrapping current mainline fails when configuring libjava/libltdl on
both Tru64 UNIX V4.0F and V5.1B with the following error:

configure: configuring in libltdl
configure: running /bin/ksh '/vol/gnu/src/gcc/gcc-dist/libjava/libltdl/configure' --prefix=/vol/gcc  '--cache-file=./config.cache' '--host=alpha-dec-osf4.0f' '--build=alpha-dec-osf4.0f' '--enable-multilib' '--prefix=/vol/gcc' '--with-local-prefix=/vol/gcc' '--disable-nls' '--disable-libmudflap' '--with-gcc-version-trigger=/vol/gnu/src/gcc/gcc-dist/gcc/version.c' '--enable-languages=c,c++,java,objc' '--program-transform-name=s,y,y,' '--srcdir=/vol/gnu/src/gcc/gcc-dist/libjava' '--with-target-subdir=alpha-dec-osf4.0f' 'CPPFLAGS=-O2 -g -O2 -mieee' 'build_alias=alpha-dec-osf4.0f' 'host_alias=alpha-dec-osf4.0f' 'target_alias=alpha-dec-osf4.0f' --enable-ltdl-convenience --with-auxdir=/vol/gnu/src/gcc/gcc-dist --cache-file=.././config.cache --srcdir=/vol/gnu/src/gcc/gcc-dist/libjava/libltdl
configure: loading cache .././config.cache
configure: error: `CPPFLAGS' has changed since the previous run:
configure:   former value:  -O2 -g -O2  -mieee
configure:   current value: -O2 -g -O2 -mieee
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/ksh '/vol/gnu/src/gcc/gcc-dist/libjava/libltdl/configure' failed for libltdl
make[1]: *** [configure-target-libjava] Error 1

This problem exists at least since 20040910.

I have not yet been able to figure out where that additional blank comes from.

Environment:
System: OSF1 rimsky V4.0 1229 alpha
Machine: alpha
	
host: alpha-dec-osf4.0f
build: alpha-dec-osf4.0f
target: alpha-dec-osf4.0f
configured with: /vol/gnu/src/gcc/gcc-dist/configure --prefix=/vol/gcc --with-local-prefix=/vol/gcc --disable-nls --host alpha-dec-osf4.0f --build alpha-dec-osf4.0f --target alpha-dec-osf4.0f --disable-libmudflap

How-To-Repeat:
Bootstrap on Tru64 UNIX as above.
Comment 1 Gerald Pfeifer 2004-11-15 12:17:40 UTC
I'm seeing this in general, on *all* platforms, if I set CFLAGS to a string
ending with a blank: export CFLAGS="-pipe ", for example.
Comment 2 Andrew Pinski 2004-11-15 14:15:04 UTC
I think this is autoconf/automake/libtool bug (it is a quoting problem I assume).
Comment 3 Tom Tromey 2004-11-16 20:02:10 UTC
I tried reproducing this on x86 FC2.
I did:

rm i686-pc-linux-gnu/libjava/{config.cache,Makefile}
make CFLAGS_FOR_TARGET='-g -O2 ' configure-target-libjava

Then:

cd i686-pc-linux-gnu/libjava/libltdl/
./config.status --recheck

This worked fine.  And before running this last step I looked
in config.cache and libltdl/config.status to see how CFLAGS was
set.  It all looked ok to me.

Perhaps it is a ksh quoting bug.  Or perhaps my approach to reproducing
it is incorrect somehow.

It would be worth digging through your config.status and config.cache
files to see where the extra space occurs and where it does not.  This
will help in isolating the bug, e.g. if the space is in config.status
then the bug probably occurs during the actual invocation; if the space
is in config.cache but not config.status then it may be stripped when
creating config.status, etc.
Comment 4 Rainer Orth 2004-11-24 14:24:08 UTC
Subject: Re:  [4.0 Regression] libjava bootstrap failure on Tru64 UNIX: CPPFLAGS changed in libltdl

tromey at gcc dot gnu dot org writes:

> Perhaps it is a ksh quoting bug.  Or perhaps my approach to reproducing
> it is incorrect somehow.

To make sure the problem isn't shell dependent, I ran a bootstrap on
alpha-dec-osf5.1b with CONFIG_SHELL set to bash: the same problem occured
as with /bin/ksh.

> It would be worth digging through your config.status and config.cache
> files to see where the extra space occurs and where it does not.  This
> will help in isolating the bug, e.g. if the space is in config.status
> then the bug probably occurs during the actual invocation; if the space
> is in config.cache but not config.status then it may be stripped when
> creating config.status, etc.

In the alpha-dec-osf5.1b build mentioned above, I find in
alpha-dec-osf5.1b/libjava/config.cache:

ac_cv_env_CPPFLAGS_value='-O2 -g -O2  -mieee'

i.e. the extra space occurs.  In config.status, there is

  with options \"'--cache-file=./config.cache' '--host=alpha-dec-osf5.1b' '--build=alpha-dec-osf5.1b' '--enable-multilib' '--prefix=/vol/gcc' '--with-local-prefix=/vol/gcc' '--disable-nls' '--disable-libmudflap' '--with-gcc-version-trigger=/vol/gnu/src/gcc/gcc-dist/gcc/version.c' '--enable-languages=c,c++,java,objc' '--program-transform-name=s,y,y,' '--srcdir=/vol/gnu/src/gcc/gcc-dist/libjava' '--with-target-subdir=alpha-dec-osf5.1b' 'CPPFLAGS=-O2 -g -O2  -mieee' 'build_alias=alpha-dec-osf5.1b' 'host_alias=alpha-dec-osf5.1b' 'target_alias=alpha-dec-osf5.1b' --enable-ltdl-convenience --with-auxdir=/vol/gnu/src/gcc/gcc-dist\"
  echo "running /usr/local/bin/bash /vol/gnu/src/gcc/gcc-dist/libjava/configure " '--cache-file=./config.cache' '--host=alpha-dec-osf5.1b' '--build=alpha-dec-osf5.1b' '--enable-multilib' '--prefix=/vol/gcc' '--with-local-prefix=/vol/gcc' '--disable-nls' '--disable-libmudflap' '--with-gcc-version-trigger=/vol/gnu/src/gcc/gcc-dist/gcc/version.c' '--enable-languages=c,c++,java,objc' '--program-transform-name=s,y,y,' '--srcdir=/vol/gnu/src/gcc/gcc-dist/libjava' '--with-target-subdir=alpha-dec-osf5.1b' 'CPPFLAGS=-O2 -g -O2  -mieee' 'build_alias=alpha-dec-osf5.1b' 'host_alias=alpha-dec-osf5.1b' 'target_alias=alpha-dec-osf5.1b' --enable-ltdl-convenience --with-auxdir=/vol/gnu/src/gcc/gcc-dist $ac_configure_extra_args " --no-create --no-recursion" >&6
  exec /usr/local/bin/bash /vol/gnu/src/gcc/gcc-dist/libjava/configure '--cache-file=./config.cache' '--host=alpha-dec-osf5.1b' '--build=alpha-dec-osf5.1b' '--enable-multilib' '--prefix=/vol/gcc' '--with-local-prefix=/vol/gcc' '--disable-nls' '--disable-libmudflap' '--with-gcc-version-trigger=/vol/gnu/src/gcc/gcc-dist/gcc/version.c' '--enable-languages=c,c++,java,objc' '--program-transform-name=s,y,y,' '--srcdir=/vol/gnu/src/gcc/gcc-dist/libjava' '--with-target-subdir=alpha-dec-osf5.1b' 'CPPFLAGS=-O2 -g -O2  -mieee' 'build_alias=alpha-dec-osf5.1b' 'host_alias=alpha-dec-osf5.1b' 'target_alias=alpha-dec-osf5.1b' --enable-ltdl-convenience --with-auxdir=/vol/gnu/src/gcc/gcc-dist $ac_configure_extra_args --no-create --no-recursion
ac_configure_args="--enable-multilib '--cache-file=./config.cache' '--host=alpha-dec-osf5.1b' '--build=alpha-dec-osf5.1b' '--enable-multilib' '--prefix=/vol/gcc' '--with-local-prefix=/vol/gcc' '--disable-nls' '--disable-libmudflap' '--with-gcc-version-trigger=/vol/gnu/src/gcc/gcc-dist/gcc/version.c' '--enable-languages=c,c++,java,objc' '--program-transform-name=s,y,y,' '--srcdir=/vol/gnu/src/gcc/gcc-dist/libjava' '--with-target-subdir=alpha-dec-osf5.1b' 'CPPFLAGS=-O2 -g -O2  -mieee' 'build_alias=alpha-dec-osf5.1b' 'host_alias=alpha-dec-osf5.1b' 'target_alias=alpha-dec-osf5.1b' --enable-ltdl-convenience --with-auxdir=/vol/gnu/src/gcc/gcc-dist"
s,@CFLAGS@,-O2 -g -O2  -mieee,;t t
s,@CXXFLAGS@,-g -O2 -mieee,;t t
s,@LIBGCJ_CFLAGS@,  -mieee,;t t
s,@LIBGCJ_CXXFLAGS@,  -mieee,;t t
s,@LIBGCJ_JAVAFLAGS@,  -mieee,;t t
s,@CPPFLAGS@,-O2 -g -O2  -mieee,;t t
s,@IEEESPEC@,-mieee,;t t

I.e. the extra space is present here, too.

In libltdl/config.log, I find

  $ /vol/gnu/src/gcc/gcc-dist/libjava/libltdl/configure --prefix=/vol/gcc --cache-file=./config.cache --host=alpha-dec-osf5.1b --build=alpha-dec-osf5.1b --enable-multilib --prefix=/vol/gcc --with-local-prefix=/vol/gcc --disable-nls --disable-libmudflap --with-gcc-version-trigger=/vol/gnu/src/gcc/gcc-dist/gcc/version.c--enable-languages=c,c++,java,objc --program-transform-name=s,y,y, --srcdir=/vol/gnu/src/gcc/gcc-dist/libjava --with-target-subdir=alpha-dec-osf5.1b CPPFLAGS=-O2 -g -O2 -mieee build_alias=alpha-dec-osf5.1b host_alias=alpha-dec-osf5.1b target_alias=alpha-dec-osf5.1b --enable-ltdl-convenience --with-auxdir=/vol/gnu/src/gcc/gcc-dist --cache-file=.././config.cache --srcdir=/vol/gnu/src/gcc/gcc-dist/libjava/libltdl

Here, the extra space is gone.

	Rainer
Comment 5 Kelley Cook 2004-11-24 18:59:31 UTC
I'm up to three bugs here of which two are very related.

The first bug is that somewhere during bootstrap an extra space is getting
tacked on CFLAGS.  I'll try to track down where that happens.  I'm pretty sure
that some mistake is happening in the toplevel Makefile.* wizardy.  Obviously
this is not right, but on the other hand it really shouldn't matter much.

Usually, this extra space doesn't matter due to another bug shown by Gerald's
testcase which shows that at some invocation of a submake an intentional
trailing space is gets stripped from CFLAGS.

I do think I know why this bogus space causes bootstrap failures on Alpha and
that is the config/mt-alphaieee which appends " -mieee" to CFLAGS, this means
our wayward trailing space in CFLAGS is now longer a trailing space and so it
doesn't get stripped when it is calls a submake at some point.

So what does all this have to do with CPPFLAGS?

Well, this bug reports exposes that we do have a more troubling problem in that
CPPFLAGS is getting assigned "-O2 -g -O2".  CPPFLAGS is for the preproccesor and
only should have things like "-I ../dir" or "-DMACRO".  This came from this
patch here by Sean McNeil:

http://gcc.gnu.org/ml/gcc-patches/2003-02/msg01736.html

I think DJ rightfully questioned this patch at the time.  It's clearly not
correct to abuse CPPFLAGS that way IMO.  I propose that patch be reverted.

If one wants to pass something to libgfortran, use FCFLAGS (which actually may
need to get added to the toplevel to pass down to libgfortran).  For C++ use
CXXFLAGS.  That's what those two flags are for.

Great, but why should that matter you ask?  Because autoconf considers CPPFLAGS
to be a precious (unchanging) variable, but not CFLAGS.

So, reverting Sean's patch should fix both problems even with the first two bugs.

Finally, I'm pretty sure that this bug is misfiled, since is a bug within our
build machinery.  But we don't have category for that.
Comment 6 Andrew Pinski 2004-12-01 18:25:04 UTC
This can happen else where so removing target.
Comment 7 Kelley Cook 2005-01-13 18:28:15 UTC
Created attachment 7954 [details]
Base target CPPFLAGS on CPPFLAGS_FOR_TARGET

Could someone please verify that this patch fixes the Alpha bootstrap bug.
Comment 8 Gerald Pfeifer 2005-01-13 22:45:02 UTC
I can confirm that the patch addresses the issue from comment #1, which is a
good reason to go for that patch (even in case the alpha issue might not be
addressed).  Thanks!
Comment 9 Rainer Orth 2005-01-14 18:25:55 UTC
Subject: Re:  [4.0 Regression] libjava bootstrap failure on Tru64 UNIX: CPPFLAGS changed in libltdl

kcook at gcc dot gnu dot org writes:

> Could someone please verify that this patch fixes the Alpha bootstrap bug.

It does: I've successfully bootstrapped mainline on alpha-dec-osf5.1b with
this patch:

	http://gcc.gnu.org/ml/gcc-testresults/2005-01/msg00655.html

While there are many C++ execution failures (which seem to be easily
fixable), the Java results are quite similar to those from July 2004 (when
I last successfully bootstrapped on Tru64 UNIX V5.1B).

Thanks alot.

	Rainer
Comment 10 GCC Commits 2005-01-17 23:50:41 UTC
Subject: Bug 18222

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	kcook@gcc.gnu.org	2005-01-17 23:50:27

Modified files:
	.              : ChangeLog Makefile.def Makefile.in Makefile.tpl 

Log message:
	2005-01-17  Kelley Cook  <kcook@gcc.gnu.org>
	
	PR bootstrap/18222
	* Makefile.def: Pass CPPFLAGS_FOR_TARGET.
	* Makefile.tpl: Define target CPPFLAGS on CPPFLAGS_FOR_TARGET.
	* Makefile.in: Regenerate.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/ChangeLog.diff?cvsroot=gcc&r1=1.1045&r2=1.1046
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/Makefile.def.diff?cvsroot=gcc&r1=1.45&r2=1.46
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/Makefile.in.diff?cvsroot=gcc&r1=1.253&r2=1.254
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/Makefile.tpl.diff?cvsroot=gcc&r1=1.123&r2=1.124

Comment 11 Andrew Pinski 2005-01-17 23:57:17 UTC
Fixed.