[llvm-commits] [llvm-gcc-4.2] r63633 - /llvm-gcc-4.2/trunk/gcc/gcc.c

Rafael Espindola rafael.espindola at gmail.com
Tue Feb 3 08:20:22 PST 2009


Author: rafael
Date: Tue Feb  3 10:20:19 2009
New Revision: 63633

URL: http://llvm.org/viewvc/llvm-project?rev=63633&view=rev
Log:
One difference of the way the Apple ld and gold implement plugins is that gold
doesn't search for the plugin. It must be passed with the -plugin option.

This patch makes gcc search for the plugin in the same way it searches for cc1.
The search only happens if the -use-gold-plugin option is used. If the plugin
is found, it is passed to gold.


Modified:
    llvm-gcc-4.2/trunk/gcc/gcc.c

Modified: llvm-gcc-4.2/trunk/gcc/gcc.c
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/gcc.c?rev=63633&r1=63632&r2=63633&view=diff

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/gcc.c (original)
+++ llvm-gcc-4.2/trunk/gcc/gcc.c Tue Feb  3 10:20:19 2009
@@ -713,10 +713,12 @@
    scripts which exist in user specified directories, or in standard
    directories.  */
 /* APPLE LOCAL begin add fcreate-profile */
+/* LLVM LOCAL begin add use-gold-plugin */
 #ifndef LINK_COMMAND_SPEC
 #define LINK_COMMAND_SPEC "\
 %{!fsyntax-only:%{!c:%{!M:%{!MM:%{!E:%{!S:\
-    %(linker) %l " LINK_PIE_SPEC "%X %{o*} %{A} %{d} %{e*} %{m} %{N} %{n} %{r}\
+    %(linker) %{use-gold-plugin: -plugin %(gold_plugin_file)} \
+    %l " LINK_PIE_SPEC "%X %{o*} %{A} %{d} %{e*} %{m} %{N} %{n} %{r}\
     %{s} %{t} %{u*} %{x} %{z} %{Z} %{!A:%{!nostdlib:%{!nostartfiles:%S}}}\
     %{static:} %{L*} %(mfwrap) %(link_libgcc) %o\
     %{fopenmp:%:include(libgomp.spec)%(link_gomp)} %(mflib)\
@@ -765,6 +767,7 @@
 static const char *startfile_spec = STARTFILE_SPEC;
 static const char *switches_need_spaces = SWITCHES_NEED_SPACES;
 static const char *linker_name_spec = LINKER_NAME;
+static const char *gold_plugin_file_spec = "";
 static const char *link_command_spec = LINK_COMMAND_SPEC;
 static const char *link_libgcc_spec = LINK_LIBGCC_SPEC;
 static const char *startfile_prefix_spec = STARTFILE_PREFIX_SPEC;
@@ -1637,6 +1640,7 @@
   INIT_STATIC_SPEC ("linker",			&linker_name_spec),
   INIT_STATIC_SPEC ("link_libgcc",		&link_libgcc_spec),
   /* LLVM LOCAL */
+  INIT_STATIC_SPEC ("gold_plugin_file",		&gold_plugin_file_spec),
   INIT_STATIC_SPEC ("llvm_options",		&llvm_options),
   INIT_STATIC_SPEC ("md_exec_prefix",		&md_exec_prefix),
   INIT_STATIC_SPEC ("md_startfile_prefix",	&md_startfile_prefix),
@@ -7138,6 +7142,7 @@
   if (num_linker_inputs > 0 && error_count == 0)
     {
       int tmp = execution_count;
+      const char *use_gold_plugin = "use-gold-plugin";
 
       /* We'll use ld if we can't find collect2.  */
       if (! strcmp (linker_name_spec, "collect2"))
@@ -7146,6 +7151,17 @@
 	  if (s == NULL)
 	    linker_name_spec = "ld";
 	}
+
+      if (switch_matches (use_gold_plugin,
+			  use_gold_plugin + strlen (use_gold_plugin), 0))
+	{
+	  gold_plugin_file_spec = find_a_file (&exec_prefixes,
+					       "libLLVMgold.so", X_OK,
+					       false);
+	  if (!gold_plugin_file_spec)
+	    fatal ("-use-gold-plugin, but libLLVMgold.so not found.");
+	}
+
       /* Rebuild the COMPILER_PATH and LIBRARY_PATH environment variables
 	 for collect.  */
       putenv_from_prefixes (&exec_prefixes, "COMPILER_PATH", false);





More information about the llvm-commits mailing list