This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Fix -fPIC issue with GNU LD and LTO
- From: Jan Hubicka <hubicka at ucw dot cz>
- To: gcc-patches at gcc dot gnu dot org, rguenther at suse dot de, tglek at mozilla dot com
- Date: Wed, 5 Jan 2011 14:15:25 +0100
- Subject: Fix -fPIC issue with GNU LD and LTO
Hi,
this patch enables us to get past failure with LTO mozilla build using GNU LD.
Mozilla invoke link as
/abuild/jh/trunk-install/bin/gcc -O3 -flto -flto-partition=none
-fuse-linker-plugin -shared -Wl,-soname -Wl,libplds4.so -o libplds4.so
./plarena.o ./plhash.o ./plvrsion.o -L/abuild/jh/build-mozilla-new7/dist/lib
-lnspr4
that leads us to build PC32 relocations to external symbols. This is because flag_shlib
is not set. Normally -fPIC imply flag_shlib via finalize_options, but since -fPIC
is issued only later due to lto_reissue_options, we never get around setting it.
The following patch fixes it by adding logic to lto_reissue_options. Hacky, but the
whole thing is a hack and I can't think of anything better.
OK?
Bootstrapped/regtested x86_64-linux.
PR lto/45375
* lto-opt.c (lto_reissue_options): Set flag_shlib.
Index: lto-opts.c
===================================================================
--- lto-opts.c (revision 168506)
+++ lto-opts.c (working copy)
@@ -420,5 +420,9 @@
gcc_unreachable ();
}
+ /* Flag_shlib is usually set by finish_options, but we are issing flag_pic
+ too late. */
+ if (flag_pic && !flag_pie)
+ flag_shlib = 1;
VEC_free (opt_t, heap, opts);
}