|
View:
New views
9 Messages
—
Rating Filter:
Alert me
|
|
|
PATCH: Add --with-plugin-ldHi,
This patch adds --with-plugin-ld to specify the plugin linker, which may be different from ld. Any comments? H.J. ---- 2009-11-03 H.J. Lu <hongjiu.lu@...> * collect2.c (main): Search PLUGIN_LD for plugin linker. * configure.ac (--with-plugin-ld): New. Default to ld. * configure: Regenerated. * config.in: Likewise. * exec-tool.in (ORIGINAL_PLUGIN_LD_FOR_TARGET): New. (collect-ld): Use ORIGINAL_PLUGIN_LD_FOR_TARGET for -plugin. diff --git a/gcc/collect2.c b/gcc/collect2.c index 03300f3..b259f09 100644 --- a/gcc/collect2.c +++ b/gcc/collect2.c @@ -1100,6 +1100,7 @@ int main (int argc, char **argv) { static const char *const ld_suffix = "ld"; + static const char *const plugin_ld_suffix = PLUGIN_LD; static const char *const real_ld_suffix = "real-ld"; static const char *const collect_ld_suffix = "collect-ld"; static const char *const nm_suffix = "nm"; @@ -1118,6 +1119,8 @@ main (int argc, char **argv) const char *const full_ld_suffix = concat(target_machine, "-", ld_suffix, NULL); + const char *const full_plugin_ld_suffix = + concat(target_machine, "-", plugin_ld_suffix, NULL); const char *const full_nm_suffix = concat (target_machine, "-", nm_suffix, NULL); const char *const full_gnm_suffix = @@ -1132,6 +1135,7 @@ main (int argc, char **argv) concat (target_machine, "-", gstrip_suffix, NULL); #else const char *const full_ld_suffix = ld_suffix; + const char *const full_plugin_ld_suffix = plugin_ld_suffix; const char *const full_nm_suffix = nm_suffix; const char *const full_gnm_suffix = gnm_suffix; #ifdef LDD_SUFFIX @@ -1152,6 +1156,7 @@ main (int argc, char **argv) const char **c_ptr; char **ld1_argv; const char **ld1; + bool use_plugin = false; /* The kinds of symbols we will have to consider when scanning the outcome of a first pass link. This is ALL to start with, then might @@ -1217,7 +1222,6 @@ main (int argc, char **argv) what LTO mode we are in. */ { int i; - bool use_plugin = false; for (i = 1; argv[i] != NULL; i ++) { @@ -1329,11 +1333,17 @@ main (int argc, char **argv) /* Search the compiler directories for `ld'. We have protection against recursive calls in find_a_file. */ if (ld_file_name == 0) - ld_file_name = find_a_file (&cpath, ld_suffix); + ld_file_name = find_a_file (&cpath, + use_plugin + ? plugin_ld_suffix + : ld_suffix); /* Search the ordinary system bin directories for `ld' (if native linking) or `TARGET-ld' (if cross). */ if (ld_file_name == 0) - ld_file_name = find_a_file (&path, full_ld_suffix); + ld_file_name = find_a_file (&path, + use_plugin + ? full_plugin_ld_suffix + : full_ld_suffix); #ifdef REAL_NM_FILE_NAME nm_file_name = find_a_file (&path, REAL_NM_FILE_NAME); diff --git a/gcc/config.in b/gcc/config.in index a3e9069..fbc9fbb 100644 --- a/gcc/config.in +++ b/gcc/config.in @@ -1550,6 +1550,12 @@ #endif +/* Specify plugin linker */ +#ifndef USED_FOR_TARGET +#undef PLUGIN_LD +#endif + + /* Define to PREFIX/include if cpp should also search that directory. */ #ifndef USED_FOR_TARGET #undef PREFIX_INCLUDE_DIR diff --git a/gcc/configure b/gcc/configure index 292b3dc..f49cdb7 100755 --- a/gcc/configure +++ b/gcc/configure @@ -822,6 +822,7 @@ gcc_cv_objdump ORIGINAL_NM_FOR_TARGET gcc_cv_nm ORIGINAL_LD_FOR_TARGET +ORIGINAL_PLUGIN_LD_FOR_TARGET gcc_cv_ld ORIGINAL_AS_FOR_TARGET gcc_cv_as @@ -1036,6 +1037,7 @@ enable_static with_pic enable_fast_install enable_libtool_lock +with_plugin_ld enable_gnu_unique_object enable_linker_build_id with_long_double_128 @@ -1780,6 +1782,7 @@ Optional Packages: --with-pic try to use only PIC/non-PIC objects [default=use both] --with-gnu-ld assume the C compiler uses GNU ld [default=no] + --with-plugin-ld=[ARG] specify the plugin linker --with-long-double-128 Use 128-bit long double by default. --with-gc={page,zone} choose the garbage collection mechanism to use with the compiler @@ -11572,13 +11575,13 @@ if test "${lt_cv_nm_interface+set}" = set; then : else lt_cv_nm_interface="BSD nm" echo "int some_variable = 0;" > conftest.$ac_ext - (eval echo "\"\$as_me:11575: $ac_compile\"" >&5) + (eval echo "\"\$as_me:11578: $ac_compile\"" >&5) (eval "$ac_compile" 2>conftest.err) cat conftest.err >&5 - (eval echo "\"\$as_me:11578: $NM \\\"conftest.$ac_objext\\\"\"" >&5) + (eval echo "\"\$as_me:11581: $NM \\\"conftest.$ac_objext\\\"\"" >&5) (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out) cat conftest.err >&5 - (eval echo "\"\$as_me:11581: output\"" >&5) + (eval echo "\"\$as_me:11584: output\"" >&5) cat conftest.out >&5 if $GREP 'External.*some_variable' conftest.out > /dev/null; then lt_cv_nm_interface="MS dumpbin" @@ -12783,7 +12786,7 @@ ia64-*-hpux*) ;; *-*-irix6*) # Find out which ABI we are using. - echo '#line 12786 "configure"' > conftest.$ac_ext + echo '#line 12789 "configure"' > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? @@ -14443,11 +14446,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:14446: $lt_compile\"" >&5) + (eval echo "\"\$as_me:14449: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:14450: \$? = $ac_status" >&5 + echo "$as_me:14453: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -14782,11 +14785,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:14785: $lt_compile\"" >&5) + (eval echo "\"\$as_me:14788: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:14789: \$? = $ac_status" >&5 + echo "$as_me:14792: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -14887,11 +14890,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:14890: $lt_compile\"" >&5) + (eval echo "\"\$as_me:14893: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:14894: \$? = $ac_status" >&5 + echo "$as_me:14897: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -14942,11 +14945,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:14945: $lt_compile\"" >&5) + (eval echo "\"\$as_me:14948: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:14949: \$? = $ac_status" >&5 + echo "$as_me:14952: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -17324,7 +17327,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 17327 "configure" +#line 17330 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -17420,7 +17423,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 17423 "configure" +#line 17426 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -19376,11 +19379,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:19379: $lt_compile\"" >&5) + (eval echo "\"\$as_me:19382: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:19383: \$? = $ac_status" >&5 + echo "$as_me:19386: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -19475,11 +19478,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:19478: $lt_compile\"" >&5) + (eval echo "\"\$as_me:19481: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:19482: \$? = $ac_status" >&5 + echo "$as_me:19485: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -19527,11 +19530,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:19530: $lt_compile\"" >&5) + (eval echo "\"\$as_me:19533: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:19534: \$? = $ac_status" >&5 + echo "$as_me:19537: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -20686,6 +20689,24 @@ fi fi fi +ORIGINAL_PLUGIN_LD_FOR_TARGET=$gcc_cv_ld +PLUGIN_LD=`basename $gcc_cv_ld` + +# Check whether --with-plugin-ld was given. +if test "${with_plugin_ld+set}" = set; then : + withval=$with_plugin_ld; if test x"$withval" != x; then + ORIGINAL_PLUGIN_LD_FOR_TARGET="$withval" + PLUGIN_LD="$withval" + fi +fi + + + +cat >>confdefs.h <<_ACEOF +#define PLUGIN_LD "$PLUGIN_LD" +_ACEOF + + ORIGINAL_LD_FOR_TARGET=$gcc_cv_ld case "$ORIGINAL_LD_FOR_TARGET" in diff --git a/gcc/configure.ac b/gcc/configure.ac index dd3b7e8..dfc7299 100644 --- a/gcc/configure.ac +++ b/gcc/configure.ac @@ -1915,6 +1915,17 @@ else AC_PATH_PROG(gcc_cv_ld, $LD_FOR_TARGET) fi]) +ORIGINAL_PLUGIN_LD_FOR_TARGET=$gcc_cv_ld +PLUGIN_LD=`basename $gcc_cv_ld` +AC_ARG_WITH(plugin-ld, +[ --with-plugin-ld=[[ARG]] specify the plugin linker], +[if test x"$withval" != x; then + ORIGINAL_PLUGIN_LD_FOR_TARGET="$withval" + PLUGIN_LD="$withval" + fi]) +AC_SUBST(ORIGINAL_PLUGIN_LD_FOR_TARGET) +AC_DEFINE_UNQUOTED(PLUGIN_LD, "$PLUGIN_LD", [Specify plugin linker]) + ORIGINAL_LD_FOR_TARGET=$gcc_cv_ld AC_SUBST(ORIGINAL_LD_FOR_TARGET) case "$ORIGINAL_LD_FOR_TARGET" in diff --git a/gcc/exec-tool.in b/gcc/exec-tool.in index f585163..ceab0c0 100644 --- a/gcc/exec-tool.in +++ b/gcc/exec-tool.in @@ -21,6 +21,7 @@ ORIGINAL_AS_FOR_TARGET="@ORIGINAL_AS_FOR_TARGET@" ORIGINAL_LD_FOR_TARGET="@ORIGINAL_LD_FOR_TARGET@" +ORIGINAL_PLUGIN_LD_FOR_TARGET="@ORIGINAL_PLUGIN_LD_FOR_TARGET@" ORIGINAL_NM_FOR_TARGET="@ORIGINAL_NM_FOR_TARGET@" exeext=@host_exeext@ fast_install=@enable_fast_install@ @@ -34,7 +35,11 @@ case "$invoked" in dir=gas ;; collect-ld) - original=$ORIGINAL_LD_FOR_TARGET + if test x"$1" = "x-plugin"; then + original=$ORIGINAL_PLUGIN_LD_FOR_TARGET + else + original=$ORIGINAL_LD_FOR_TARGET + fi prog=ld-new$exeext dir=ld ;; |
|
|
Re: PATCH: Add --with-plugin-ld2009/11/3 H.J. Lu <hongjiu.lu@...>:
> Hi, > > This patch adds --with-plugin-ld to specify the plugin linker, which > may be different from ld. Any comments? I assume this is because you have a case where you don't want to use gold as the regular linker, but only when handling LTO files. Is that the case? > > H.J. Cheers, -- Rafael Ávila de Espíndola |
|
|
Re: PATCH: Add --with-plugin-ldOn Tue, Nov 3, 2009 at 2:05 PM, Rafael Espindola <espindola@...> wrote:
> 2009/11/3 H.J. Lu <hongjiu.lu@...>: >> Hi, >> >> This patch adds --with-plugin-ld to specify the plugin linker, which >> may be different from ld. Any comments? > > I assume this is because you have a case where you don't want to use > gold as the regular linker, but only when handling LTO files. Is that > the case? > My regular linker isn't gold. I do have gold with a different name. I want gcc to use ld by default. But when -fuse-linker-plugin is used, I want gcc to use gold, not ld, for plugin process. -- H.J. |
|
|
Re: PATCH: Add --with-plugin-ld> My regular linker isn't gold. I do have gold with a different name.
> I want gcc to use ld by default. But when -fuse-linker-plugin is > used, I want gcc to use gold, not ld, for plugin process. May I ask why you need this gcc to use the GNU ld by default? I am OK with the idea of patch if there is some missing feature in gold, but I don't think I can approve changes to collect2. > > -- > H.J. > Cheers, -- Rafael Ávila de Espíndola |
|
|
Re: PATCH: Add --with-plugin-ldOn Tue, Nov 3, 2009 at 2:31 PM, Rafael Espindola <espindola@...> wrote:
>> My regular linker isn't gold. I do have gold with a different name. >> I want gcc to use ld by default. But when -fuse-linker-plugin is >> used, I want gcc to use gold, not ld, for plugin process. > > May I ask why you need this gcc to use the GNU ld by default? The reasons are 1. Gold doesn't support ia64. 2. Gold doesn't support STT_GNU_IFUNC. 3. Gold has problems with some packages. Gold is only required for plugin. I install both linkers and use gold only when needed. > I am OK with the idea of patch if there is some missing feature in > gold, but I don't think I can approve changes to collect2. -- H.J. |
|
|
Re: PATCH: Add --with-plugin-ld> 1. Gold doesn't support ia64.
Are you trying to use the linker plugin on ia64? That is not going to work until gold itself does. > 2. Gold doesn't support STT_GNU_IFUNC. > 3. Gold has problems with some packages. True. With you patch the same compiler would be able to work with all packages that GNU ld can link and would be able to use the linker plugin on packages that gold works with. > -- > H.J. > Cheers, -- Rafael Ávila de Espíndola |
|
|
Re: PATCH: Add --with-plugin-ldOn Tue, Nov 3, 2009 at 2:55 PM, Rafael Espindola <espindola@...> wrote:
>> 1. Gold doesn't support ia64. > > Are you trying to use the linker plugin on ia64? That is not going to > work until gold itself does. I don't plan to use plugin on ia64. >> 2. Gold doesn't support STT_GNU_IFUNC. >> 3. Gold has problems with some packages. > > True. With you patch the same compiler would be able to work with all > packages that GNU ld can link and would be able to use the linker > plugin on packages that gold works with. > Exactly. Thanks. -- H.J. |
|
|
Re: PATCH: Add --with-plugin-ldOn Tue, Nov 3, 2009 at 11:05 PM, H.J. Lu <hjl.tools@...> wrote:
> On Tue, Nov 3, 2009 at 2:55 PM, Rafael Espindola <espindola@...> wrote: >>> 1. Gold doesn't support ia64. >> >> Are you trying to use the linker plugin on ia64? That is not going to >> work until gold itself does. > > I don't plan to use plugin on ia64. > >>> 2. Gold doesn't support STT_GNU_IFUNC. >>> 3. Gold has problems with some packages. >> >> True. With you patch the same compiler would be able to work with all >> packages that GNU ld can link and would be able to use the linker >> plugin on packages that gold works with. >> > > Exactly. I like the patch - it's certainly cleaner than the hack I use locally. The collec2 changes are ok, but the configure bits should be reviewed by somebody else. Thanks, Richard. > Thanks. > > > -- > H.J. > |
|
|
Re: PATCH: Add --with-plugin-ld"H.J. Lu" <hongjiu.lu@...> writes:
> 2009-11-03 H.J. Lu <hongjiu.lu@...> > > * collect2.c (main): Search PLUGIN_LD for plugin linker. > > * configure.ac (--with-plugin-ld): New. Default to ld. > * configure: Regenerated. > * config.in: Likewise. > > * exec-tool.in (ORIGINAL_PLUGIN_LD_FOR_TARGET): New. > (collect-ld): Use ORIGINAL_PLUGIN_LD_FOR_TARGET for -plugin. > collect-ld) > - original=$ORIGINAL_LD_FOR_TARGET > + if test x"$1" = "x-plugin"; then > + original=$ORIGINAL_PLUGIN_LD_FOR_TARGET > + else > + original=$ORIGINAL_LD_FOR_TARGET > + fi This needs a comment, something like "when using a linker plugin, gcc will always pass '-plugin' as the first option to the linker." This is OK with that change. Thanks. Ian |
| Free embeddable forum powered by Nabble | Forum Help |