Bug 46037 - --enable-stage1-languages=c,lto --enable-languages=c,lto --with-build-config=bootstrap-lto fails on darwin
Summary: --enable-stage1-languages=c,lto --enable-languages=c,lto --with-build-config=...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 4.6.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-10-15 14:35 UTC by Jack Howarth
Modified: 2011-01-14 16:14 UTC (History)
5 users (show)

See Also:
Host: x86_64-apple-darwin10
Target: x86_64-apple-darwin10
Build: x86_64-apple-darwin10
Known to work:
Known to fail:
Last reconfirmed: 2011-01-10 22:27:07


Attachments
preprocessed source for libcpp/lex.c (33.49 KB, text/plain)
2010-10-16 01:23 UTC, Jack Howarth
Details
proposed patch (561 bytes, patch)
2011-01-11 19:32 UTC, Jack Howarth
Details | Diff
revised patch (478 bytes, patch)
2011-01-12 03:28 UTC, Jack Howarth
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jack Howarth 2010-10-15 14:35:59 UTC
Bootstrapping with...

../gcc/configure --prefix=/Users/howarth/dist --with-gmp=/sw --with-mpc=/sw --with-libiconv-prefix=/sw --with-system-zlib --x-includes=/usr/X11R6/include --x-libraries=/usr/X11R6/lib --enable-stage1-languages=c,lto --enable-languages=c,lto --with-build-config=bootstrap-lto

fails on x86_64-apple-darwin10 with the error...

Configuring stage 2 in ./intl
Configuring stage 2 in ./libiberty
Configuring stage 2 in ./libdecnumber
make[4]: Nothing to be done for `all'.
make[3]: Nothing to be done for `all'.
configure: creating cache ./config.cache
configure: creating cache ./config.cache
configure: creating cache ./config.cache
checking whether make sets $(MAKE)... checking whether make sets $(MAKE)... checking whether to enable maintainer-specific portions of Makefiles... no
checking for makeinfo... makeinfo --split-size=5000000 --split-size=5000000
checking for perl... perl
yes
yes
checking for a BSD-compatible install... checking for x86_64-apple-darwin10.5.0-gcc... /usr/bin/install -c
 /Users/howarth/darwin_objdir/./prev-gcc/xgcc -B/Users/howarth/darwin_objdir/./prev-gcc/ -B/Users/howarth/dist/x86_64-apple-darwin10.5.0/bin/ -B/Users/howarth/dist/x86_64-apple-darwin10.5.0/bin/ -B/Users/howarth/dist/x86_64-apple-darwin10.5.0/lib/ -isystem /Users/howarth/dist/x86_64-apple-darwin10.5.0/include -isystem /Users/howarth/dist/x86_64-apple-darwin10.5.0/sys-include   
checking whether NLS is requested... yes
checking for msgfmt... checking build system type... /sw/bin/msgfmt
checking for gmsgfmt... /sw/bin/msgfmt
checking for xgettext... x86_64-apple-darwin10.5.0
checking host system type... /sw/bin/xgettext
checking for msgmerge... checking for C compiler default output file name... x86_64-apple-darwin10.5.0
checking for x86_64-apple-darwin10.5.0-ar... ar
/sw/bin/msgmerge
checking for x86_64-apple-darwin10.5.0-ranlib... ranlib
checking for x86_64-apple-darwin10.5.0-gcc...  /Users/howarth/darwin_objdir/./prev-gcc/xgcc -B/Users/howarth/darwin_objdir/./prev-gcc/ -B/Users/howarth/dist/x86_64-apple-darwin10.5.0/bin/ -B/Users/howarth/dist/x86_64-apple-darwin10.5.0/bin/ -B/Users/howarth/dist/x86_64-apple-darwin10.5.0/lib/ -isystem /Users/howarth/dist/x86_64-apple-darwin10.5.0/include -isystem /Users/howarth/dist/x86_64-apple-darwin10.5.0/sys-include   
checking for x86_64-apple-darwin10.5.0-gcc...  /Users/howarth/darwin_objdir/./prev-gcc/xgcc -B/Users/howarth/darwin_objdir/./prev-gcc/ -B/Users/howarth/dist/x86_64-apple-darwin10.5.0/bin/ -B/Users/howarth/dist/x86_64-apple-darwin10.5.0/bin/ -B/Users/howarth/dist/x86_64-apple-darwin10.5.0/lib/ -isystem /Users/howarth/dist/x86_64-apple-darwin10.5.0/include -isystem /Users/howarth/dist/x86_64-apple-darwin10.5.0/sys-include   

configure: error: in `/Users/howarth/darwin_objdir/libdecnumber':
configure: error: C compiler cannot create executables
See `config.log' for more details.
checking for C compiler default output file name... checking for suffix of object files... make[2]: *** [configure-stage2-libdecnumber] Error 77
make[2]: *** Waiting for unfinished jobs....

configure: error: in `/Users/howarth/darwin_objdir/intl':
configure: error: C compiler cannot create executables
See `config.log' for more details.
configure: error: in `/Users/howarth/darwin_objdir/libiberty':
configure: error: cannot compute suffix of object files: cannot compile
See `config.log' for more details.
make[2]: *** [configure-stage2-intl] Error 77
make[2]: *** [configure-stage2-libiberty] Error 1
make[1]: *** [stage2-bubble] Error 2
make: *** [all] Error 2

Removing "-fuse-linker-plugin" from config/bootstrap-lto.mk changes the failure to...

checking whether fwrite_unlocked is declared... /Users/howarth/darwin_objdir/./prev-gcc/xgcc -B/Users/howarth/darwin_objdir/./prev-gcc/ -B/Users/howarth/dist/x86_64-apple-darwin10.5.0/bin/ -B/Users/howarth/dist/x86_64-apple-darwin10.5.0/bin/ -B/Users/howarth/dist/x86_64-apple-darwin10.5.0/lib/ -isystem /Users/howarth/dist/x86_64-apple-darwin10.5.0/include -isystem /Users/howarth/dist/x86_64-apple-darwin10.5.0/sys-include     -I../../gcc/libcpp -I. -I../../gcc/libcpp/../include -I../../gcc/libcpp/include -I/sw/include -g -O2 -fwhopr=jobserver -frandom-seed=1 -W -Wall -Wwrite-strings -Wmissing-format-attribute -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition -Wc++-compat -pedantic -Wno-long-long -Werror -I../../gcc/libcpp -I. -I../../gcc/libcpp/../include -I../../gcc/libcpp/include -I/sw/include -c -o mkdeps.o -MT mkdeps.o -MMD -MP -MF .deps/mkdeps.Tpo ../../gcc/libcpp/mkdeps.c
no
checking whether getchar_unlocked is declared... yes
checking whether getc_unlocked is declared... yes
checking whether putchar_unlocked is declared... ../../gcc/libcpp/lex.c:2838:1: sorry, unimplemented: gimple bytecode streams do not support the optimization attribute
yes
checking whether putc_unlocked is declared... make[3]: *** [lex.o] Error 1
make[3]: *** Waiting for unfinished jobs....
yes
checking whether getrlimit is declared... yes
checking whether setrlimit is declared... yes
checking whether getrusage is declared... yes
checking whether ldgetname is declared... no
checking whether times is declared... yes
checking whether sigaltstack is declared... yes
checking for struct tms... yes
checking for clock_t... yes
checking for .preinit_array/.init_array/.fini_array support... no
checking if mkdir takes one argument... no
Using `../../gcc/gcc/config/i386/i386.c' for machine-specific logic.
Using `../../gcc/gcc/config/i386/i386.md' as machine description file.
Using the following target machine macro files:
	../../gcc/gcc/config/vxworks-dummy.h
	../../gcc/gcc/config/i386/biarch64.h
	../../gcc/gcc/config/i386/i386.h
	../../gcc/gcc/config/darwin.h
	../../gcc/gcc/config/darwin9.h
	../../gcc/gcc/config/darwin10.h
	../../gcc/gcc/config/i386/darwin.h
	../../gcc/gcc/config/i386/darwin64.h
Using host-darwin.o host-i386-darwin.o for host machine hooks.
checking for __cxa_atexit... yes
checking whether NLS is requested... yes
checking for catalogs to be installed...  be da de el es fi fr id ja nl ru sr sv tr vi zh_CN zh_TW
checking how to print strings... printf
checking for a sed that does not truncate output... /usr/bin/sed
checking for fgrep... /usr/bin/grep -F
checking for ld used by  /Users/howarth/darwin_objdir/./prev-gcc/xgcc -B/Users/howarth/darwin_objdir/./prev-gcc/ -B/Users/howarth/dist/x86_64-apple-darwin10.5.0/bin/ -B/Users/howarth/dist/x86_64-apple-darwin10.5.0/bin/ -B/Users/howarth/dist/x86_64-apple-darwin10.5.0/lib/ -isystem /Users/howarth/dist/x86_64-apple-darwin10.5.0/include -isystem /Users/howarth/dist/x86_64-apple-darwin10.5.0/sys-include   ... /usr/libexec/gcc/i686-apple-darwin10/4.2.1/ld
checking if the linker (/usr/libexec/gcc/i686-apple-darwin10/4.2.1/ld) is GNU ld... no
checking for BSD- or MS-compatible name lister (nm)... nm
checking the name lister (nm) interface... BSD nm
checking whether ln -s works... yes
checking the maximum length of command line arguments... 196608
checking whether the shell understands some XSI constructs... yes
checking whether the shell understands "+="... yes
checking for /usr/libexec/gcc/i686-apple-darwin10/4.2.1/ld option to reload object files... -r
checking for x86_64-apple-darwin10.5.0-objdump... objdump
checking how to recognize dependent libraries... pass_all
checking for x86_64-apple-darwin10.5.0-ar... (cached) ar
checking for x86_64-apple-darwin10.5.0-strip... no
checking for strip... strip
checking for x86_64-apple-darwin10.5.0-ranlib... (cached) ranlib
checking command to parse nm output from  /Users/howarth/darwin_objdir/./prev-gcc/xgcc -B/Users/howarth/darwin_objdir/./prev-gcc/ -B/Users/howarth/dist/x86_64-apple-darwin10.5.0/bin/ -B/Users/howarth/dist/x86_64-apple-darwin10.5.0/bin/ -B/Users/howarth/dist/x86_64-apple-darwin10.5.0/lib/ -isystem /Users/howarth/dist/x86_64-apple-darwin10.5.0/include -isystem /Users/howarth/dist/x86_64-apple-darwin10.5.0/sys-include    object... ok
make[2]: *** [all-stage2-libcpp] Error 2
checking for x86_64-apple-darwin10.5.0-dsymutil... make[2]: *** Waiting for unfinished jobs....
no
checking for dsymutil... dsymutil
checking for x86_64-apple-darwin10.5.0-nmedit... no
checking for nmedit... nmedit
checking for x86_64-apple-darwin10.5.0-lipo... no
checking for lipo... lipo
checking for x86_64-apple-darwin10.5.0-otool... no
checking for otool... otool
checking for x86_64-apple-darwin10.5.0-otool64... no
checking for otool64... no
checking for -single_module linker flag... yes
checking for -exported_symbols_list linker flag... yes
checking for -force_load linker flag... yes
checking for dlfcn.h... yes
checking for objdir... .libs
checking if  /Users/howarth/darwin_objdir/./prev-gcc/xgcc -B/Users/howarth/darwin_objdir/./prev-gcc/ -B/Users/howarth/dist/x86_64-apple-darwin10.5.0/bin/ -B/Users/howarth/dist/x86_64-apple-darwin10.5.0/bin/ -B/Users/howarth/dist/x86_64-apple-darwin10.5.0/lib/ -isystem /Users/howarth/dist/x86_64-apple-darwin10.5.0/include -isystem /Users/howarth/dist/x86_64-apple-darwin10.5.0/sys-include    supports -fno-rtti -fno-exceptions... no
checking for  /Users/howarth/darwin_objdir/./prev-gcc/xgcc -B/Users/howarth/darwin_objdir/./prev-gcc/ -B/Users/howarth/dist/x86_64-apple-darwin10.5.0/bin/ -B/Users/howarth/dist/x86_64-apple-darwin10.5.0/bin/ -B/Users/howarth/dist/x86_64-apple-darwin10.5.0/lib/ -isystem /Users/howarth/dist/x86_64-apple-darwin10.5.0/include -isystem /Users/howarth/dist/x86_64-apple-darwin10.5.0/sys-include    option to produce PIC... -fno-common -DPIC
checking if  /Users/howarth/darwin_objdir/./prev-gcc/xgcc -B/Users/howarth/darwin_objdir/./prev-gcc/ -B/Users/howarth/dist/x86_64-apple-darwin10.5.0/bin/ -B/Users/howarth/dist/x86_64-apple-darwin10.5.0/bin/ -B/Users/howarth/dist/x86_64-apple-darwin10.5.0/lib/ -isystem /Users/howarth/dist/x86_64-apple-darwin10.5.0/include -isystem /Users/howarth/dist/x86_64-apple-darwin10.5.0/sys-include    PIC flag -fno-common -DPIC works... yes
checking if  /Users/howarth/darwin_objdir/./prev-gcc/xgcc -B/Users/howarth/darwin_objdir/./prev-gcc/ -B/Users/howarth/dist/x86_64-apple-darwin10.5.0/bin/ -B/Users/howarth/dist/x86_64-apple-darwin10.5.0/bin/ -B/Users/howarth/dist/x86_64-apple-darwin10.5.0/lib/ -isystem /Users/howarth/dist/x86_64-apple-darwin10.5.0/include -isystem /Users/howarth/dist/x86_64-apple-darwin10.5.0/sys-include    static flag -static works... no
checking if  /Users/howarth/darwin_objdir/./prev-gcc/xgcc -B/Users/howarth/darwin_objdir/./prev-gcc/ -B/Users/howarth/dist/x86_64-apple-darwin10.5.0/bin/ -B/Users/howarth/dist/x86_64-apple-darwin10.5.0/bin/ -B/Users/howarth/dist/x86_64-apple-darwin10.5.0/lib/ -isystem /Users/howarth/dist/x86_64-apple-darwin10.5.0/include -isystem /Users/howarth/dist/x86_64-apple-darwin10.5.0/sys-include    supports -c -o file.o... yes
checking if  /Users/howarth/darwin_objdir/./prev-gcc/xgcc -B/Users/howarth/darwin_objdir/./prev-gcc/ -B/Users/howarth/dist/x86_64-apple-darwin10.5.0/bin/ -B/Users/howarth/dist/x86_64-apple-darwin10.5.0/bin/ -B/Users/howarth/dist/x86_64-apple-darwin10.5.0/lib/ -isystem /Users/howarth/dist/x86_64-apple-darwin10.5.0/include -isystem /Users/howarth/dist/x86_64-apple-darwin10.5.0/sys-include    supports -c -o file.o... (cached) yes
checking whether the  /Users/howarth/darwin_objdir/./prev-gcc/xgcc -B/Users/howarth/darwin_objdir/./prev-gcc/ -B/Users/howarth/dist/x86_64-apple-darwin10.5.0/bin/ -B/Users/howarth/dist/x86_64-apple-darwin10.5.0/bin/ -B/Users/howarth/dist/x86_64-apple-darwin10.5.0/lib/ -isystem /Users/howarth/dist/x86_64-apple-darwin10.5.0/include -isystem /Users/howarth/dist/x86_64-apple-darwin10.5.0/sys-include    linker (/usr/libexec/gcc/i686-apple-darwin10/4.2.1/ld) supports shared libraries... yes
checking dynamic linker characteristics... darwin10.5.0 dyld
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... yes
checking how to run the C++ preprocessor... g++ -E
checking for ld used by g++... /usr/libexec/gcc/i686-apple-darwin10/4.2.1/ld
checking if the linker (/usr/libexec/gcc/i686-apple-darwin10/4.2.1/ld) is GNU ld... no
checking whether the g++ linker (/usr/libexec/gcc/i686-apple-darwin10/4.2.1/ld) supports shared libraries... yes
checking for g++ option to produce PIC... -fno-common -DPIC
checking if g++ PIC flag -fno-common -DPIC works... yes
checking if g++ static flag -static works... no
checking if g++ supports -c -o file.o... yes
checking if g++ supports -c -o file.o... (cached) yes
checking whether the g++ linker (/usr/libexec/gcc/i686-apple-darwin10/4.2.1/ld) supports shared libraries... yes
checking dynamic linker characteristics... darwin10.5.0 dyld
checking how to hardcode library paths into programs... immediate
checking for as... /usr/bin/as
checking what assembler to use... /usr/bin/as
checking whether we are using gold... no
checking what linker to use... /usr/libexec/gcc/i686-apple-darwin10/4.2.1/ld
checking for nm... /usr/bin/nm
checking what nm to use... /usr/bin/nm
checking for objdump... no
checking what objdump to use... not found
checking for readelf... no
checking what readelf to use... not found
checking assembler flags...  
checking assembler for .balign and .p2align... yes
checking assembler for .p2align with maximum skip... yes
checking assembler for .literal16... yes
checking assembler for working .subsection -1... no
checking assembler for .weak... no
checking assembler for .weakref... no
checking assembler for .nsubspa comdat... no
checking assembler for .hidden... no
checking linker for .hidden support... no
checking linker read-only and read-write section mixing... unknown
checking assembler for .sleb128 and .uleb128... no
checking assembler for cfi directives... no
checking assembler for cfi personality directive... no
checking assembler for cfi sections directive... no
checking assembler for eh_frame optimization... no
checking assembler for section merging support... no
checking assembler for section merging support... (cached) no
checking assembler for COMDAT group support... no
checking assembler for COMDAT group support... no
checking assembler for line table discriminator support... no
checking assembler for thread-local storage support... no
checking linker -Bstatic/-Bdynamic option... no
checking assembler for filds and fists mnemonics... no
checking assembler for fildq and fistpq mnemonics... no
checking assembler for cmov syntax... no
checking assembler for ffreep mnemonic... yes
checking assembler for .quad directive... yes
checking assembler for sahf mnemonic... yes
checking assembler for swap suffix... no
checking assembler for different section symbol subtraction... no
checking assembler for GOTOFF in data... no
checking assembler for rep and lock prefix... yes
checking assembler for dwarf2 debug_line support... no
checking assembler for buggy dwarf2 .file directive... no
checking assembler for --gdwarf2 option... yes
checking assembler for --gstabs option... yes
checking assembler for --debug-prefix-map option... no
checking assembler for .lcomm with alignment... yes
checking assembler for gnu_unique_object... no
checking assembler for tolerance to line number 0... yes
checking linker PT_GNU_EH_FRAME support... no
checking linker position independent executable support... no
checking linker EH-compatible garbage collection of sections... no
checking linker --as-needed support... no
checking linker --build-id support... no
checking linker *_sol2 emulation support... no
checking linker --sysroot support... no
checking __stack_chk_fail in target C library... checking for __stack_chk_fail... yes
yes
Using ggc-page for garbage collection.
checking whether to enable maintainer-specific portions of Makefiles... no
Links are now set up to build a native compiler for x86_64-apple-darwin10.5.0.
checking for exported symbols... yes
checking for library containing dlopen... none required
checking for -fPIC -shared... yes
configure: updating cache ./config.cache
configure: creating ./config.status
config.status: creating as
config.status: creating collect-ld
config.status: creating nm
config.status: creating Makefile
config.status: creating gccbug
config.status: creating ada/gcc-interface/Makefile
config.status: creating ada/Makefile
config.status: creating auto-host.h
config.status: executing default commands
make[1]: *** [stage2-bubble] Error 2
make: *** [all] Error 2
Comment 1 Jack Howarth 2010-10-16 01:23:58 UTC
Created attachment 22058 [details]
preprocessed source for libcpp/lex.c

The attached preprocessed source, lex.i, for libcpp/lex.c provides an example of the code which triggers the bootstrap-lto failures on darwin....

/sw/src/fink.build/gcc46-4.6.0-1000/darwin_objdir/./prev-gcc/xgcc -B/sw/src/fink.build/gcc46-4.6.0-1000/darwin_objdir/./prev-gcc/ -B/sw/lib/gcc4.6/x86_64-apple-darwin10.5.0/bin/ -B/sw/lib/gcc4.6/x86_64-apple-darwin10.5.0/bin/ -B/sw/lib/gcc4.6/x86_64-apple-darwin10.5.0/lib/ -isystem /sw/lib/gcc4.6/x86_64-apple-darwin10.5.0/include -isystem /sw/lib/gcc4.6/x86_64-apple-darwin10.5.0/sys-include -I../../gcc-4.6-20101014/libcpp -I. -I../../gcc-4.6-20101014/libcpp/../include -I../../gcc-4.6-20101014/libcpp/include -I/sw/include -g -O2 -W -Wall -Wwrite-strings -Wmissing-format-attribute -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition -Wc++-compat -pedantic -Wno-long-long -Werror -I../../gcc-4.6-20101014/libcpp -I. -I../../gcc-4.6-20101014/libcpp/../include -I../../gcc-4.6-20101014/libcpp/include -I/sw/include -flto -c -o lex.o -MT lex.o -MMD -MP -MF .deps/lex.Tpo lex.i
../../gcc-4.6-20101014/libcpp/lex.c:2838:1: sorry, unimplemented: gimple bytecode streams do not support the optimization attribute

The same error appears when -fwhopr or -fwhopr=jobserver is used instead of -flto.
Comment 2 Richard Biener 2010-10-16 09:46:38 UTC
the optimize attribute isn't used in the preprocessed file but only the
target attribute which is supported.  Thus, "worksforme".
Comment 3 Jack Howarth 2010-10-16 13:41:03 UTC
(In reply to comment #2)
> the optimize attribute isn't used in the preprocessed file but only the
> target attribute which is supported.  Thus, "worksforme".

Using a stock build of gcc trunk on x86_64-apple-darwin10, built with...

Using built-in specs.
COLLECT_GCC=gcc-4
COLLECT_LTO_WRAPPER=/sw/lib/gcc4.6/libexec/gcc/x86_64-apple-darwin10.5.0/4.6.0/lto-wrapper
Target: x86_64-apple-darwin10.5.0
Configured with: ../gcc-4.6-20101014/configure --prefix=/sw --prefix=/sw/lib/gcc4.6 --mandir=/sw/share/man --infodir=/sw/lib/gcc4.6/info --enable-languages=c,c++,fortran,objc,obj-c++,java,lto --with-gmp=/sw --with-libiconv-prefix=/sw --with-ppl=/sw --with-cloog=/sw --with-mpc=/sw --with-system-zlib --x-includes=/usr/X11R6/include --x-libraries=/usr/X11R6/lib --program-suffix=-fsf-4.6 --enable-checking=yes
Thread model: posix
gcc version 4.6.0 20101015 (experimental) (GCC) 

the error can be reproduced out of tree with the lex.i file as...

gcc-4 -g -O2 -W -Wall -Wwrite-strings -Wmissing-format-attribute -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition -Wc++-compat -pedantic -Wno-long-long -Werror -flto -c -o lex.o -MT ex.o -MMD -MP -MF .deps/lex.Tpo lex.i
../../gcc-4.6-20101014/libcpp/lex.c:2838:1: sorry, unimplemented: gimple bytecode streams do not support the optimization attribute

It would be interesting to know if COFF's lto support has the same issues (since they share the same backend design for lto support).
Comment 4 Dave Korn 2011-01-10 15:28:51 UTC
(In reply to comment #2)
> the optimize attribute isn't used in the preprocessed file but only the
> target attribute which is supported.  Thus, "worksforme".

Target attributes must be implying optimisation attributes.  Bug depends also on --with-{arch,tune,fpmath} settings.  I'll try and reproduce it on x86_64-linux, it should be possible if I choose the right settings - will reply again later.

(In reply to comment #3)

> It would be interesting to know if COFF's lto support has the same issues
> (since they share the same backend design for lto support).

No, it's not related to the backend lto support at all; the sorry comes from the lto output streamer.  It does depend on the backend's attribute handling though.

(See also PR41201, vaguely related.)
Comment 5 Jan Hubicka 2011-01-10 15:46:25 UTC
> Target attributes must be implying optimisation attributes.  Bug depends also
> on --with-{arch,tune,fpmath} settings.  I'll try and reproduce it on
> x86_64-linux, it should be possible if I choose the right settings - will reply
> again later.

Well, we probably should just go ahead and implement streaming of optimizaion attribute.
But still I don't see how this implicatoin happens.

Honza
Comment 6 Jan Hubicka 2011-01-10 22:27:07 UTC
Well, so the problem is:
static bool
ix86_valid_target_attribute_p (tree fndecl,
                               tree ARG_UNUSED (name),
                               tree args,
                               int ARG_UNUSED (flags))
{
...
  new_optimize = build_optimization_node ();
...
      if (old_optimize != new_optimize)
        DECL_FUNCTION_SPECIFIC_OPTIMIZATION (fndecl) = new_optimize;

for some reason the optimization flags are believed to not match despite the fact only target attribute is used.  The difference is:

- <optimization_node 0x143209100
+ <optimization_node 0x100fda500
     align_functions (0x10)
     align_jumps (0x10)
     align_labels (0x1)
@@ -95,5 +96,6 @@
     flag_unwind_tables (0x1)
     flag_var_tracking (0x1)
     flag_var_tracking_assignments (0x1)
+    flag_var_tracking_uninit (0x1)
     flag_vect_cost_model (0x1)
 >

so it seems that re-running process_options on darwin somehow leads to this change.  Adding Joseph to CC.

Still streaming of optimization attribute is thing we should do.
Comment 7 jsm-csl@polyomino.org.uk 2011-01-10 22:47:26 UTC
On Mon, 10 Jan 2011, hubicka at gcc dot gnu.org wrote:

> so it seems that re-running process_options on darwin somehow leads to this
> change.  Adding Joseph to CC.

How exactly is process_options rerun?  It's a static function in toplev.c, 
called once from another static function in toplev.c....  I guess maybe 
you mean decode_options.  In that case, maybe you need to implement 
TARGET_OVERRIDE_OPTIONS_AFTER_CHANGE to set at least some of the variables 
set by darwin_override_options.
Comment 8 Jan Hubicka 2011-01-11 00:07:08 UTC
I guess it is decode options.  But I wonder how we manage to play this ping-pong game.  I see darwin.c setting the uninit:

  if (flag_var_tracking
      && (generating_for_darwin_version >= 9)
      && debug_info_level >= DINFO_LEVEL_NORMAL
      && debug_hooks->var_location != do_nothing_debug_hooks.var_location)
    flag_var_tracking_uninit = 1;

and toplev.c clearing it:

  /* We know which debug output will be used so we can set flag_var_tracking
     and flag_var_tracking_uninit if the user has not specified them.  */
  if (debug_info_level < DINFO_LEVEL_NORMAL
      || debug_hooks->var_location == do_nothing_debug_hooks.var_location)
    { 
      if (flag_var_tracking == 1
          || flag_var_tracking_uninit == 1)
        { 
          if (debug_info_level < DINFO_LEVEL_NORMAL)
            warning (0, "variable tracking requested, but useless unless "
                     "producing debug info");
          else
            warning (0, "variable tracking requested, but not supported "
                     "by this debug format");
        }
      flag_var_tracking = 0;
      flag_var_tracking_uninit = 0;
    }

First time we go
process_options->darwin_override_options and we end up with flag disabled (can't verify as I am not big friend with Jack's gdb)
next time we go
#0  0x00000001009edb40 in darwin_override_options ()
#1  0x000000010099b120 in ix86_option_override_internal ()
#2  0x000000010099f15b in ix86_valid_target_attribute_tree ()
#3  0x000000010099f25b in ix86_valid_target_attribute_p ()
#4  0x000000010007ac04 in handle_target_attribute ()
#5  0x00000001000024ca in decl_attributes ()
this time we bypass process_options.

I don't see how those two conditionals can both match.


I also wonder why is darwin enabling the flag? 
It seems to be off at all configurations except for darwin even if looks like generic var tracking feature.  -fvar-tracking-uninit is also undocumented.
Comment 9 Jan Hubicka 2011-01-11 00:26:40 UTC
OK, first time the flag is not set because 
debug_hooks->var_location == do_nothing_debug_hooks.var_location
second time it is no longer true

Seems we need to ininitialize the debug hook earlier or use different test when processing options.

Honza
Comment 10 Jan Hubicka 2011-01-11 00:36:33 UTC
Hi,
this should fix the issue.
Index: config/darwin.c
===================================================================
--- config/darwin.c     (revision 168632)
+++ config/darwin.c     (working copy)
@@ -2618,7 +2618,7 @@
   if (flag_var_tracking
       && (generating_for_darwin_version >= 9)
       && debug_info_level >= DINFO_LEVEL_NORMAL
-      && debug_hooks->var_location != do_nothing_debug_hooks.var_location)
+      && write_symbols == DWARF2_DEBUG)
     flag_var_tracking_uninit = 1;
 
   if (MACHO_DYNAMIC_NO_PIC_P)
Comment 11 Jack Howarth 2011-01-11 04:41:14 UTC
(In reply to comment #10)

While this patch allows the lto-bootstrap below to complete on x86_64-apple-darwin10...

../gcc/configure --enable-checking=release --prefix=/Users/howarth/dist --with-gmp=/sw --with-ppl=/sw --with-cloog=/sw --with-mpc=/sw --with-libiconv-prefix=/sw --with-system-zlib --x-includes=/usr/X11R6/include --x-libraries=/usr/X11R6/lib --with-build-config=bootstrap-lto --enable-stage1-languages=c,lto --enable-languages=c,lto

it breaks the standard bootstrap of...

../gcc/configure --enable-checking=release --prefix=/Users/howarth/dist --with-gmp=/sw --with-ppl=/sw --with-cloog=/sw --with-mpc=/sw --with-libiconv-prefix=/sw --with-system-zlib --x-includes=/usr/X11R6/include --x-libraries=/usr/X11R6/lib --enable-languages=c,lto

with the error...

/Users/howarth/darwin_objdir/./prev-gcc/xgcc -B/Users/howarth/darwin_objdir/./prev-gcc/ -B/Users/howarth/dist/x86_64-apple-darwin10.6.0/bin/ -B/Users/howarth/dist/x86_64-apple-darwin10.6.0/bin/ -B/Users/howarth/dist/x86_64-apple-darwin10.6.0/lib/ -isystem /Users/howarth/dist/x86_64-apple-darwin10.6.0/include -isystem /Users/howarth/dist/x86_64-apple-darwin10.6.0/sys-include     -I../../gcc/libcpp -I. -I../../gcc/libcpp/../include -I../../gcc/libcpp/include -I/sw/include -g -O2 -mdynamic-no-pic -gtoggle -W -Wall -Wwrite-strings -Wmissing-format-attribute -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition -Wc++-compat -pedantic -Wno-long-long -Werror -I../../gcc/libcpp -I. -I../../gcc/libcpp/../include -I../../gcc/libcpp/include -I/sw/include -c -o charset.o -MT charset.o -MMD -MP -MF .deps/charset.Tpo ../../gcc/libcpp/charset.c
../../gcc/libcpp/charset.c:1:0: error: variable tracking requested, but useless unless producing debug info [-Werror]
cc1: all warnings being treated as errors

make[3]: *** [charset.o] Error 1
make[2]: *** [all-stage2-libcpp] Error 2
make[1]: *** [stage2-bubble] Error 2
make: *** [all] Error 2
Comment 12 Jack Howarth 2011-01-11 06:19:54 UTC
In case it helps, the code being patched was introduced with r126927 and was proposed in...

http://gcc.gnu.org/ml/gcc-patches/2007-07/msg01799.html
Comment 13 Jack Howarth 2011-01-11 06:31:38 UTC
A slight correction. There appears to be no actual gcc-patches posting for r126927 (as it is an add-on fix to r126900)

2007-07-25  Daniel Berlin  <dberlin@dberlin.org>

	* config/darwin.c (darwin_override_options): Additional fix for
	debug info formats that don't support var tracking.
Comment 14 Jan Hubicka 2011-01-11 09:12:05 UTC
> /Users/howarth/darwin_objdir/./prev-gcc/xgcc
> -B/Users/howarth/darwin_objdir/./prev-gcc/
> -B/Users/howarth/dist/x86_64-apple-darwin10.6.0/bin/
> -B/Users/howarth/dist/x86_64-apple-darwin10.6.0/bin/
> -B/Users/howarth/dist/x86_64-apple-darwin10.6.0/lib/ -isystem
> /Users/howarth/dist/x86_64-apple-darwin10.6.0/include -isystem
> /Users/howarth/dist/x86_64-apple-darwin10.6.0/sys-include    
> -I../../gcc/libcpp -I. -I../../gcc/libcpp/../include -I../../gcc/libcpp/include
> -I/sw/include -g -O2 -mdynamic-no-pic -gtoggle -W -Wall -Wwrite-strings
> -Wmissing-format-attribute -Wstrict-prototypes -Wmissing-prototypes
> -Wold-style-definition -Wc++-compat -pedantic -Wno-long-long -Werror
> -I../../gcc/libcpp -I. -I../../gcc/libcpp/../include -I../../gcc/libcpp/include
> -I/sw/include -c -o charset.o -MT charset.o -MMD -MP -MF .deps/charset.Tpo
> ../../gcc/libcpp/charset.c
> ../../gcc/libcpp/charset.c:1:0: error: variable tracking requested, but useless
> unless producing debug info [-Werror]
> cc1: all warnings being treated as errors

I guess it is because of
  if (flag_gtoggle)
    {
      if (debug_info_level == DINFO_LEVEL_NONE)
        {
          debug_info_level = DINFO_LEVEL_NORMAL;

          if (write_symbols == NO_DEBUG)
            write_symbols = PREFERRED_DEBUGGING_TYPE;
        }
      else
        debug_info_level = DINFO_LEVEL_NONE;
    }

The conditinal in darwin.c tests debug_info_level.
I guess either this test could be moved earlier in the queue or darwin.c needs to test
gtoggle and  adjust debug_info_level accrodingly.

I am really not expert in this area. 
Joseph might know.

Honza
Comment 15 Jack Howarth 2011-01-11 13:48:30 UTC
The regression testresults a lto-bootstrap of the proposed patch in Comment 10 on x86_64-apple-darwin10...

http://gcc.gnu.org/ml/gcc-testresults/2011-01/msg00899.html

The patch will also be problematic for powerpc-apple-darwin9 and darwin8 since it relies on dwarf2 and those OS releases still use stabs.
Comment 16 Jan Hubicka 2011-01-11 14:06:58 UTC
> The patch will also be problematic for powerpc-apple-darwin9 and darwin8 since
> it relies on dwarf2 and those OS releases still use stabs.
It should not be problem.  For stabs we don't do var tracking.
The original test tested if target debug info supports var tracking and dwarf2 is the
only one. Since stabs support is not planned, I think the new test is as good as old
one.

For that -gtoggle failure you need something like

 if (flag_var_tracking
     && (generating_for_darwin_version >= 9)
     && debug_info_level >= DINFO_LEVEL_NORMAL
     && (flag_gtoggle ? (debug_info_level >= DINFO_LEVEL_NORMAL)
	 : (debug_info_level == DINFO_LEVEL_NONE))
     && write_symbols == DWARF2_DEBUG)

(i.e. -gtoggle is supposed to replace -g by -g0 and -g0 by -g.)

Honza
Comment 17 Jack Howarth 2011-01-11 15:11:49 UTC
I assume you really meant...

 if (flag_var_tracking
     && (generating_for_darwin_version >= 9)
     && (flag_gtoggle ? (debug_info_level >= DINFO_LEVEL_NORMAL)
         : (debug_info_level == DINFO_LEVEL_NONE))
     && write_symbols == DWARF2_DEBUG)

without the extra...

&& debug_info_level >= DINFO_LEVEL_NORMAL
Comment 18 Jack Howarth 2011-01-11 15:23:34 UTC
Both the patch in comment 16 and 17 produce the same errors in a standard bootstrap...

../../gcc/libdecnumber/decContext.c:1:0: error: variable tracking requested, but useless unless producing debug info [-Werror]
cc1: all warnings being treated as errors
Comment 19 Jack Howarth 2011-01-11 16:32:00 UTC
Why not retain the original code behavior unless generating lto? The patch below works with both a standard and lto-bootstrap on x86_64-apple-darwin10.

Index: gcc/config/darwin.c
===================================================================
--- gcc/config/darwin.c	(revision 168662)
+++ gcc/config/darwin.c	(working copy)
@@ -2618,7 +2618,8 @@
   if (flag_var_tracking
       && (generating_for_darwin_version >= 9)
       && debug_info_level >= DINFO_LEVEL_NORMAL
-      && debug_hooks->var_location != do_nothing_debug_hooks.var_location)
+      && (flag_generate_lto ? (write_symbols == DWARF2_DEBUG)
+      : (debug_hooks->var_location != do_nothing_debug_hooks.var_location)))
     flag_var_tracking_uninit = 1;
 
   if (MACHO_DYNAMIC_NO_PIC_P)
Comment 20 Jan Hubicka 2011-01-11 16:56:35 UTC
> Why not retain the original code behavior unless generating lto? The patch
Because the original code bahviour is wrong.  It assumes that debug_hooks is initialized
while it is not at the point.

Honza
> below works with both a standard and lto-bootstrap on x86_64-apple-darwin10.
> 
> Index: gcc/config/darwin.c
> ===================================================================
> --- gcc/config/darwin.c    (revision 168662)
> +++ gcc/config/darwin.c    (working copy)
> @@ -2618,7 +2618,8 @@
>    if (flag_var_tracking
>        && (generating_for_darwin_version >= 9)
>        && debug_info_level >= DINFO_LEVEL_NORMAL
> -      && debug_hooks->var_location != do_nothing_debug_hooks.var_location)
> +      && (flag_generate_lto ? (write_symbols == DWARF2_DEBUG)
> +      : (debug_hooks->var_location != do_nothing_debug_hooks.var_location)))
>      flag_var_tracking_uninit = 1;
> 
>    if (MACHO_DYNAMIC_NO_PIC_P)
Comment 21 Jack Howarth 2011-01-11 18:06:31 UTC
This brute force approach works for both a standard and lto-bootstrap...

Index: gcc/config/darwin.c
===================================================================
--- gcc/config/darwin.c	(revision 168667)
+++ gcc/config/darwin.c	(working copy)
@@ -2615,10 +2615,23 @@ darwin_override_options (void)
       darwin_emit_branch_islands = true;
     }
 
+  if (flag_gtoggle)
+    {
+      if (debug_info_level == DINFO_LEVEL_NONE)
+        {
+          debug_info_level = DINFO_LEVEL_NORMAL;
+
+          if (write_symbols == NO_DEBUG)
+            write_symbols = PREFERRED_DEBUGGING_TYPE;
+        }
+      else
+        debug_info_level = DINFO_LEVEL_NONE;
+    }
+
   if (flag_var_tracking
-      && (generating_for_darwin_version >= 9)
+      && generating_for_darwin_version >= 9
       && debug_info_level >= DINFO_LEVEL_NORMAL
-      && debug_hooks->var_location != do_nothing_debug_hooks.var_location)
+      && write_symbols == DWARF2_DEBUG)
     flag_var_tracking_uninit = 1;
 
   if (MACHO_DYNAMIC_NO_PIC_P)
Comment 22 Jack Howarth 2011-01-11 19:32:25 UTC
Created attachment 22949 [details]
proposed patch
Comment 23 Mike Stump 2011-01-12 00:46:43 UTC
Ok.
Comment 24 Jack Howarth 2011-01-12 03:28:39 UTC
Created attachment 22950 [details]
revised patch
Comment 25 Jack Howarth 2011-01-12 15:00:11 UTC
Testresults for lto-bootstrap with revised patch on x86_64-apple-darwin10...

http://gcc.gnu.org/ml/gcc-testresults/2011-01/msg01002.html
Comment 26 Richard Biener 2011-01-14 15:42:17 UTC
Author: rguenth
Date: Fri Jan 14 15:42:09 2011
New Revision: 168793

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=168793
Log:
2011-01-14  Jan Hubicka  <jh@suse.cz>
            Jack Howarth <howarth@bromo.med.uc.edu>

	PR target/46037
	* config/darwin.c (darwin_override_options): Honor flag_gtoggle
	when checking debug_info_level. Test write_symbols instead of
	debug_hooks->var_location when setting flag_var_tracking_uninit.

Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/config/darwin.c
Comment 27 Jack Howarth 2011-01-14 16:14:44 UTC
Fixed at r168793.