This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: PATCH] PR target/65612: Multiversioning doesn't work with DSO nor PIE


HJ,
     This patch breaks the bootstrap on targets like darwin which
don't build libgcc_nonshared.a...

if test -z "$objects"; then \
  echo 'int __libgcc_eh_dummy;' > eh_dummy.c; \
  /sw/src/fink.build/gcc5-5.0.0-1/darwin_objdir/./gcc/xgcc
-B/sw/src/fink.build/gcc5-5.0.0-1/darwin_objdir/./gcc/
-B/sw/lib/gcc5/x86_64-apple-darwin14.3.0/bin/
-B/sw/lib/gcc5/x86_64-apple-darwin14.3.0/lib/ -isystem
/sw/lib/gcc5/x86_64-apple-darwin14.3.0/include -isystem
/sw/lib/gcc5/x86_64-apple-darwin14.3.0/sys-include    -g -O2 -m32 -O2
-g -O2 -DIN_GCC    -W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual
-Wno-format -Wstrict-prototypes -Wmissing-prototypes
-Wold-style-definition  -isystem ./include   -pipe -fno-common -g
-DIN_LIBGCC2 -fbuilding-libgcc -fno-stack-protector   -pipe
-fno-common -I. -I. -I../../.././gcc
-I../../../../gcc-5-20150330/libgcc
-I../../../../gcc-5-20150330/libgcc/.
-I../../../../gcc-5-20150330/libgcc/../gcc
-I../../../../gcc-5-20150330/libgcc/../include  -DHAVE_CC_TLS
-DUSE_EMUTLS -fvisibility=hidden -DHIDE_EXPORTS -c eh_dummy.c \
     -o eh_dummy.o; \
  objects=eh_dummy.o; \
fi; \
ar  rc libgcc_nonshared.a $objects
ar: cpuinfo.o: No such file or directory
Makefile:905: recipe for target 'libgcc_nonshared.a' failed
make[5]: *** [libgcc_nonshared.a] Error 1
make[5]: Leaving directory
'/sw/src/fink.build/gcc5-5.0.0-1/darwin_objdir/x86_64-apple-darwin14.3.0/i386/libgcc'
Makefile:1168: recipe for target 'multi-do' failed
make[4]: *** [multi-do] Error 1
make[4]: Leaving directory
'/sw/src/fink.build/gcc5-5.0.0-1/darwin_objdir/x86_64-apple-darwin14.3.0/libgcc'
Makefile:117: recipe for target 'all-multi' failed
make[3]: *** [all-multi] Error 2
make[3]: Leaving directory
'/sw/src/fink.build/gcc5-5.0.0-1/darwin_objdir/x86_64-apple-darwin14.3.0/libgcc'
Makefile:14820: recipe for target 'all-stage1-target-libgcc' failed
make[2]: *** [all-stage1-target-libgcc] Error 2
make[2]: Leaving directory '/sw/src/fink.build/gcc5-5.0.0-1/darwin_objdir'
Makefile:20760: recipe for target 'stage1-bubble' failed
make[1]: *** [stage1-bubble] Error 2
make[1]: Leaving directory '/sw/src/fink.build/gcc5-5.0.0-1/darwin_objdir'
Makefile:21064: recipe for target 'bootstrap' failed
make: *** [bootstrap] Error 2

          Jack

On Mon, Mar 30, 2015 at 6:25 PM, H.J. Lu <hjl.tools@gmail.com> wrote:
> On Sun, Mar 29, 2015 at 7:40 PM, H.J. Lu <hjl.tools@gmail.com> wrote:
>> On Sun, Mar 29, 2015 at 7:34 PM, H.J. Lu <hjl.tools@gmail.com> wrote:
>>> On Sun, Mar 29, 2015 at 7:25 PM, H.J. Lu <hjl.tools@gmail.com> wrote:
>>>> We shouldn't call external function, __cpu_indicator_init, while an object
>>>> is being relocated since its .got.plt section hasn't been updated.  It
>>>> works for non-PIE since no update on .got.plt section is required.  This
>>>> patch hides __cpu_indicator_init/__cpu_model from linker to force linker
>>>> to resolve __cpu_indicator_init/__cpu_model to their hidden definitions
>>>> in libgcc.a while providing backward binary compatibility.
>>>>
>>>> OK for trunk, 4.9 and 4.9 branches?
>>>>
>>>> Thanks.
>>>>
>>>>
>>>> H.J.
>>>> ---
>>>> libgcc/
>>>>
>>>>         PR target/65612
>>>>         * config/i386/cpuinfo.c (__cpu_model): Initialize.
>>>>         (__cpu_indicator_init@GCC_4.8.0): New.
>>>>         (__cpu_model@GCC_4.8.0): Likewise.
>>>>
>>>> gcc/testsuite/
>>>>
>>>>         PR target/65612
>>>>         * g++.dg/ext/mv18.C: New test.
>>>>         * g++.dg/ext/mv19.C: Likewise.
>>>>         * g++.dg/ext/mv20.C: Likewise.
>>>
>>> It doesn' work for shared C++ library:
>>>
>>> /export/build/gnu/gcc-x32/release/usr/gcc-5.0.0-x32/bin/g++ -O2    -c
>>> -o main.o main.cc
>>> /export/build/gnu/gcc-x32/release/usr/gcc-5.0.0-x32/bin/g++ -shared
>>> -fPIC -O2  -o libmv20.so mv20.cc
>>> /export/build/gnu/gcc-x32/release/usr/gcc-5.0.0-x32/bin/g++ -O2  -o x
>>> main.o libmv20.so -Wl,-R,.
>>> /usr/local/bin/ld: x: hidden symbol `__cpu_model' in
>>> /export/build/gnu/gcc-x32/release/usr/gcc-5.0.0-x32/bin/../lib/gcc/x86_64-unknown-linux-gnu/5.0.0/libgcc.a(cpuinfo.o)
>>> is referenced by DSO
>>> /usr/local/bin/ld: final link failed: Bad value
>>> collect2: error: ld returned 1 exit status
>>> Makefile:12: recipe for target 'x' failed
>>> make: *** [x] Error 1
>>> [hjl@gnu-tools-1 pr65612]$
>>>
>>> --
>>> H.J.
>>
>> We need something like libgcc_nonshared.a, which contains cpuinfo.o, and
>> link together with -lgcc_s when creating executable or DSO.
>>
>
> I am testing it on Linux/x86-64.  OK for master if regression test
> passes?
>
> --
> H.J.
> --
> We shouldn't call external function, __cpu_indicator_init, while an object
> is being relocated since its .got.plt section hasn't been updated.  It
> works for non-PIE since no update on .got.plt section is required.  This
> patch hides __cpu_indicator_init/__cpu_model from linker to force linker
> to resolve __cpu_indicator_init/__cpu_model to their hidden definitions
> in libgcc_nonshared.a while providing backward binary compatibility.  The
> new libgcc_nonshared.a is always linked togther with -lgcc_s and -lgcc.
>
> gcc/
>
> PR target/65612
> * gcc.c (init_spec): Add -lgcc_nonshared/libgcc_nonshared.a%s
> to -lgcc_s/-lgcc/libgcc.a%s.
>
> gcc/testsuite/
>
> PR target/65612
> * g++.dg/ext/mv18.C: New test.
> * g++.dg/ext/mv19.C: Likewise.
> * g++.dg/ext/mv20.C: Likewise.
>
> libgcc/
>
> PR target/65612
> * Makefile.in (LIB2ADDSHARED): New.
> (LIB2ADDNONSHARED): Likewise.
> (libgcc-nonshared-objects): Likewise.
> (libgcc_nonshared.a): Likewise.
> (libgcc-s-objects): Add $(LIB2ADDSHARED).
> (all): Depend on libgcc_nonshared.a.
> ($(libgcc-nonshared-objects)): Depend on libgcc_tm.h.
> (install-leaf): Install libgcc_nonshared.a.
> * config/i386/cpuinfo.c (__cpu_model): Initialize.
> (__cpu_indicator_init@GCC_4.8.0): New.
> (__cpu_model@GCC_4.8.0): Likewise.
> * config/i386/t-cpuinfo (LIB2ADD): Renamed to ...
> (LIB2ADDSHARED): This.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]