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]

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);
 }


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