On Mon, Mar 30, 2015 at 10:38 PM, Jakub Jelinek wrote: > On Mon, Mar 30, 2015 at 07:08:00PM -0700, H.J. Lu wrote: >> --- a/gcc/gcc.c >> +++ b/gcc/gcc.c >> @@ -1566,11 +1566,13 @@ init_spec (void) >> if (in_sep && *p == '-' && strncmp (p, "-lgcc", 5) == 0) >> { >> init_gcc_specs (&obstack, >> + "-lgcc_nonshared " >> "-lgcc_s" >> #ifdef USE_LIBUNWIND_EXCEPTIONS >> " -lunwind" >> #endif >> , >> + "-lgcc_nonshared " >> "-lgcc", >> "-lgcc_eh" >> #ifdef USE_LIBUNWIND_EXCEPTIONS >> @@ -1591,7 +1593,9 @@ init_spec (void) >> /* Ug. We don't know shared library extensions. Hope that >> systems that use this form don't do shared libraries. */ >> init_gcc_specs (&obstack, >> + "libgcc_nonshared.a%s " >> "-lgcc_s", >> + "libgcc_nonshared.a%s " >> "libgcc.a%s", >> "libgcc_eh.a%s" > > Why do you need to link libgcc_nonshared.a twice here? -lgcc_s surely won't > add any new __cpu* undefined references. The one added for -lgcc_s is for building shared C++ library since -lgcc isn't used and only -lgcc_s is used. The one added for -lgcc is for static linking since -lgcc_s isn't used. I updated the patch to add some testcases for -static. I couldn't find a way to add tests for: export/build/gnu/gcc/build-x86_64-linux/gcc/xg++ -B/export/build/gnu/gcc/build-x86_64-linux/gcc/ -O2 -c -o main.o main.cc /export/build/gnu/gcc/build-x86_64-linux/gcc/xg++ -B/export/build/gnu/gcc/build-x86_64-linux/gcc/ -shared -fPIC -O2 -o libmv20.so mv20.cc -L/export/build/gnu/gcc/build-x86_64-linux/x86_64-unknown-linux-gnu/libstdc++-v3/src/.libs /export/build/gnu/gcc/build-x86_64-linux/gcc/xg++ -B/export/build/gnu/gcc/build-x86_64-linux/gcc/ -O2 -o x main.o libmv20.so -Wl,-R,. -L/export/build/gnu/gcc/build-x86_64-linux/x86_64-unknown-linux-gnu/libstdc++-v3/src/.libs /usr/local/bin/ld: x: hidden symbol `__cpu_model' in /export/build/gnu/gcc/build-x86_64-linux/gcc/libgcc_nonshared.a(cpuinfo.o) is referenced by DSO /usr/local/bin/ld: final link failed: Bad value collect2: error: ld returned 1 exit status >> @@ -424,3 +424,8 @@ __cpu_indicator_init (void) >> >> return 0; >> } >> + >> +#if defined SHARED && !defined _WIN32 >> +__asm__ (".symver __cpu_indicator_init, __cpu_indicator_init@GCC_4.8.0"); >> +__asm__ (".symver __cpu_model, __cpu_model@GCC_4.8.0"); >> +#endif > > Will this work on Solaris? > I'd say you at least want to also guard with some configure check if > .symver is supported by assembler. > I updated my patch with: @@ -424,3 +424,8 @@ __cpu_indicator_init (void) return 0; } + +#if defined SHARED && defined USE_ELF_SYMVER +__asm__ (".symver __cpu_indicator_init, __cpu_indicator_init@GCC_4.8.0"); +__asm__ (".symver __cpu_model, __cpu_model@GCC_4.8.0"); +#endif diff --git a/libgcc/config/i386/t-linux b/libgcc/config/i386/t-linux index 4f47f7b..11bb46e 100644 --- a/libgcc/config/i386/t-linux +++ b/libgcc/config/i386/t-linux @@ -3,4 +3,4 @@ # t-slibgcc-elf-ver and t-linux SHLIB_MAPFILES = libgcc-std.ver $(srcdir)/config/i386/libgcc-glibc.ver -HOST_LIBGCC2_CFLAGS += -mlong-double-80 +HOST_LIBGCC2_CFLAGS += -mlong-double-80 -DUSE_ELF_SYMVER OK for master? -- H.J.