As discussed in <http://gcc.gnu.org/ml/gcc-patches/2012-08/msg01219.html>, it is desirable for the libgcc build with inhibit_libc defined and --disable-shared to be similar enough to that build without inhibit_libc and --enable-shared to be usable to build glibc, producing the same results as if glibc were built with a toolchain that already included a shared libgcc and was built against previously built glibc. One source of differences noted there was functions in libgcc.a being hidden only if shared libgcc is also being built.
This patch changes the logic so that the way libgcc.a is built in the static-only case is more similar to how it is built when shared libgcc is being built as well; in particular, libgcc symbols are generally given hidden visibility (if supported) in the static libgcc. Tested with cross to arm-none-linux-gnueabi that it fixes the previously observed differences; rebuilding glibc with the second GCC now produces identical stripped binaries to the results of building with the first (static-only) GCC, except for the cases of nscd and static libraries which differ between multiple glibc builds even with identical compilers (in both cases because of embedded timestamps). Also bootstrapped with no regressions on x86_64-unknown-linux-gnu as a sanity check. OK to commit? 2012-08-21 Joseph Myers <jos...@codesourcery.com> * Makefile.in (vis_hide, gen-hide-list): Do not make definitions depend on --enable-shared. ($(lib1asmfuncs-o)): Use %.vis files independent of --enable-shared. * static-object.mk ($(base)$(objext), $(base).vis) ($(base)_s$(objext)): Use same rules for visibility handling as in shared-object.mk. Index: libgcc/Makefile.in =================================================================== --- libgcc/Makefile.in (revision 190577) +++ libgcc/Makefile.in (working copy) @@ -363,6 +363,7 @@ ifneq ($(LIBUNWIND),) install-libunwind = install-libunwind endif +endif # For -fvisibility=hidden. We need both a -fvisibility=hidden on # the command line, and a #define to prevent libgcc2.h etc from @@ -386,11 +387,8 @@ gen-hide-list = echo > $@ endif -else -# Not enable_shared. +ifneq ($(enable_shared),yes) iterator = $(srcdir)/empty.mk $(patsubst %,$(srcdir)/static-object.mk,$(iter-items)) -vis_hide = -gen-hide-list = echo > \$@ endif LIB2ADD += enable-execute-stack.c @@ -439,7 +437,6 @@ $(LIB2_DIVMOD_FUNCS)) # Build "libgcc1" (assembly) components. -ifeq ($(enable_shared),yes) lib1asmfuncs-o = $(patsubst %,%$(objext),$(LIB1ASMFUNCS)) $(lib1asmfuncs-o): %$(objext): $(srcdir)/config/$(LIB1ASMSRC) %.vis @@ -451,15 +448,10 @@ lib1asmfuncs-s-o = $(patsubst %,%_s$(objext),$(LIB1ASMFUNCS)) $(lib1asmfuncs-s-o): %_s$(objext): $(srcdir)/config/$(LIB1ASMSRC) $(gcc_s_compile) -DL$* -xassembler-with-cpp -c $< +ifeq ($(enable_shared),yes) + libgcc-s-objects += $(lib1asmfuncs-s-o) -else - -lib1asmfuncs-o = $(patsubst %,%$(objext),$(LIB1ASMFUNCS)) -$(lib1asmfuncs-o): %$(objext): $(srcdir)/config/$(LIB1ASMSRC) - $(gcc_compile) -DL$* -xassembler-with-cpp -c $< -libgcc-objects += $(lib1asmfuncs-o) - endif # Build lib2funcs. For the static library also include LIB2FUNCS_ST. Index: libgcc/static-object.mk =================================================================== --- libgcc/static-object.mk (revision 190577) +++ libgcc/static-object.mk (working copy) @@ -24,7 +24,13 @@ endif endif -$(base)$(objext): $o - $(gcc_compile) -c -xassembler-with-cpp $< +$(base)$(objext): $o $(base).vis + $(gcc_compile) -c -xassembler-with-cpp -include $*.vis $< +$(base).vis: $(base)_s$(objext) + $(gen-hide-list) + +$(base)_s$(objext): $o + $(gcc_s_compile) -c -xassembler-with-cpp $< + endif -- Joseph S. Myers jos...@codesourcery.com