On Mon, Nov 24, 2014 at 01:06:45AM +0100, FX wrote: > tl;dr: One question to build maintainers, and one patch submitted to toplevel > configure.ac > > --------------- > > I’m looked into the issue some more, and am comparing two builds of trunk > (exact same source), one configured with system compiler (clang) in PATH, the > other with GCC 4.9.2 in PATH. > At the toplevel configure, the only meaningful difference is that the > gcc-based build sets stage1_ldflags='-static-libstdc++ -static-libgcc' while > the clang-based has stage1_ldflags='' (clang doesn’t recognized > -static-libstdc++). > > This is included into the toplevel Makefile as STAGE1_LDFLAGS (the comment > appropriately says "Linker flags to use on the host, for stage1 or when not > bootstrapping”). > Those are exported by HOST_EXPORTS, which is are then used by > configure-libcc1, all-libcc1, etc. Thus, we end up using STAGE1_LDFLAGS, > which correspond to the system compiler, instead of the stage3 compiler (as > we should). > > So, this is “false negative” part of the problem (namely, why we don’t see > the failure when bootstrapping with clang): we use STAGE1_LDFLAGS in building > libcc1, and with clang as system compiler we don’t use static linking of the > C++ library. This part, I don’t know how to fix: it is for the build experts > to address. It is a real problem: it leads to libcc1.so being linked > dynamically to libstdc++ and libgcc, instead of statically (as it should). > > --------------- > > Second part of the question: when the freshly built g++ is used, we need to > pass the appropriate -B options. As I understand it, the appropriate place > for that is in the toplevel configure.ac, where we already pass down the > respective -L options. Indeed, the attached patch restores bootstrap on > x86_64-apple-darwin14 with gcc as system compiler (and doesn’t break the > bootstrap with clang as system compiler). > > OK to commit?
Reading the toplevel Makefile and trying to understand how things work for non-bootstrap vs. bootstrap host dirs that aren't bootstrapped, I'd say the right fix should be something like following (bootstrapping/regtesting it right now on x86_64-linux and i686-linux, though it won't make much difference there, on x86_64-linux STAGE1_LDFLAGS is equal to POSTSTAGE1_LDFLAGS and STAGE1_LIBS is equal to POSTSTAGE1_LIBS. On i686-linux there is at least a difference for some reason (possibly related with my setarch and gcc -m32 wrappers hacks to make i686-linux bootstrap work on x86_64-linux box) in *STAGE1_LDFLAGS, only the POSTSTAGE1_LDFLAGS is -static-libstdc++ -static-libgcc. >From my reading, POSTSTAGE1_HOST_EXPORTS is clearly inappropriate for the modules like libcc1, because it uses prev-gcc/, while we want to use gcc/, but otherwise looking at the HOST_EXPORTS vs. POSTSTAGE1_HOST_EXPORTS differences, LDFLAGS and HOST_LIBS is what needs changing. For some reason POSTSTAGE1_HOST_EXPORTS sets LDFLAGS to $(POSTSTAGE1_LDFLAGS) $(BOOT_LDFLAGS) (the first part is ok and clear, the latter differs from the HOST_EXPORTS $(STAGE1_LDFLAGS) $(LDFLAGS). With my patch below, one actually ends up with $(POSTSTAGE1_LDFLAGS) $(LDFLAGS_FOR_TARGET) for libcc1 when bootstrapping in LDFLAGS, while previously $(STAGE1_LDFLAGS) $(LDFLAGS_FOR_TARGET) was used. STAGE1_L{DFLAGS,IBS} is only used in $(HOST_EXPORTS), so at least in theory I think my patch should DTRT. Can you please test it on Darwin (or whatever other target has similar issues with bootstrapping libcc1)? 2014-12-05 Jakub Jelinek <ja...@redhat.com> PR bootstrap/64023 * Makefile.tpl (EXTRA_TARGET_FLAGS): Set STAGE1_LDFLAGS to POSTSTAGE1_LDFLAGS and STAGE1_LIBS to POSTSTAGE1_LIBS. * Makefile.in: Regenerated. --- Makefile.tpl.jj 2014-11-12 09:31:59.000000000 +0100 +++ Makefile.tpl 2014-12-05 17:14:16.115295667 +0100 @@ -659,6 +659,8 @@ EXTRA_TARGET_FLAGS = \ 'WINDRES=$$(WINDRES_FOR_TARGET)' \ 'WINDMC=$$(WINDMC_FOR_TARGET)' \ 'XGCC_FLAGS_FOR_TARGET=$(XGCC_FLAGS_FOR_TARGET)' \ + 'STAGE1_LDFLAGS=$$(POSTSTAGE1_LDFLAGS)' \ + 'STAGE1_LIBS=$$(POSTSTAGE1_LIBS)' \ "TFLAGS=$$TFLAGS" TARGET_FLAGS_TO_PASS = $(BASE_FLAGS_TO_PASS) $(EXTRA_TARGET_FLAGS) --- Makefile.in.jj 2014-11-28 14:40:52.000000000 +0100 +++ Makefile.in 2014-12-05 17:15:04.322439003 +0100 @@ -853,6 +853,8 @@ EXTRA_TARGET_FLAGS = \ 'WINDRES=$$(WINDRES_FOR_TARGET)' \ 'WINDMC=$$(WINDMC_FOR_TARGET)' \ 'XGCC_FLAGS_FOR_TARGET=$(XGCC_FLAGS_FOR_TARGET)' \ + 'STAGE1_LDFLAGS=$$(POSTSTAGE1_LDFLAGS)' \ + 'STAGE1_LIBS=$$(POSTSTAGE1_LIBS)' \ "TFLAGS=$$TFLAGS" TARGET_FLAGS_TO_PASS = $(BASE_FLAGS_TO_PASS) $(EXTRA_TARGET_FLAGS) Jakub