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

Chris Lattner clattner at apple.com
Tue Feb 3 13:03:52 PST 2009


On Feb 3, 2009, at 8:20 AM, Rafael Espindola wrote:
> 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.

Very nice Rafael,

Please use the LTDL_SUFFIX (or whatever) macro which indicates whether  
a dynamic library suffix is ".so" or ".dylib" or .somethingelse.  I  
know that gold currently only supports elf, but it would be nice to  
keep the code general.  Also, please make sure to wrap your llvm-gcc  
changes with "LLVM LOCAL" markers so that the changes don't get lost  
in merges.

Thanks!

-Chris

>
>
>
> 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);
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits




More information about the llvm-commits mailing list