Message ID | 1288352817-24819-2-git-send-email-andi@firstfloor.org |
---|---|
State | New |
Headers | show |
On Fri, Oct 29, 2010 at 1:46 PM, Andi Kleen <andi@firstfloor.org> wrote: > From: Andi Kleen <ak@linux.intel.com> > > binutils have LTO linker plugin support now, but it requires hardcoding > the path to gcc's libexec dir in the Makefile. Add an option to the > gcc driver instead to print the full file name to avoid this. > > This is especially useful for ar or nm. Is the reason for not using -print-file-name=liblto-plugin.so to not hardcode that name? (which you still did in the patch - not sure if it's that specific name on all hosts). Richard. > gcc/ > > 2010-10-02 Andi Kleen <ak@linux.intel.com> > > * common.opt (-print-lto-plugin): Add. > * doc/invoke.texi (-print-lto-plugin): Document. > * gcc.c (display_help): Describe -print-lto-plugin. > (main.c): Handle print_lto_plugin. > --- > gcc/common.opt | 6 ++++++ > gcc/doc/invoke.texi | 9 ++++++++- > gcc/gcc.c | 13 +++++++++++++ > 3 files changed, 27 insertions(+), 1 deletions(-) > > diff --git a/gcc/common.opt b/gcc/common.opt > index a74d60d..2b6c73b 100644 > --- a/gcc/common.opt > +++ b/gcc/common.opt > @@ -183,6 +183,9 @@ Driver JoinedOrMissing Alias(print-file-name=) > -print-libgcc-file-name > Driver Alias(print-libgcc-file-name) > > +-print-lto-plugin > +Driver Alias(print-lto-plugin) > + > -print-multi-directory > Driver Alias(print-multi-directory) > > @@ -1932,6 +1935,9 @@ Driver JoinedOrMissing Var(print_file_name) > print-libgcc-file-name > Driver > > +print-lto-plugin > +Driver Var(print_lto_plugin) > + > print-multi-directory > Driver Var(print_multi_directory) > > diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi > index 7ea042f..d6784ad 100644 > --- a/gcc/doc/invoke.texi > +++ b/gcc/doc/invoke.texi > @@ -322,7 +322,7 @@ Objective-C and Objective-C++ Dialects}. > -fdebug-prefix-map=@var{old}=@var{new} @gol > -femit-struct-debug-baseonly -femit-struct-debug-reduced @gol > -femit-struct-debug-detailed@r{[}=@var{spec-list}@r{]} @gol > --p -pg -print-file-name=@var{library} -print-libgcc-file-name @gol > +-p -pg -print-file-name=@var{library} -print-libgcc-file-name -print-lto-plugin @gol > -print-multi-directory -print-multi-lib -print-multi-os-directory @gol > -print-prog-name=@var{program} -print-search-dirs -Q @gol > -print-sysroot -print-sysroot-headers-suffix @gol > @@ -5725,6 +5725,13 @@ Same as @option{-print-file-name=libgcc.a}. > This is useful when you use @option{-nostdlib} or @option{-nodefaultlibs} > but you do want to link with @file{libgcc.a}. You can do > > +@item -print-lto-plugin > +@opindex print-lto-plugin > +Print the path name of the LTO linker plugin used by the compiler. > + > +This is useful to pass to ar, gold, ld or other binutils with linker > +plugin support. > + > @smallexample > gcc -nostdlib @var{files}@dots{} `gcc -print-libgcc-file-name` > @end smallexample > diff --git a/gcc/gcc.c b/gcc/gcc.c > index 13635d5..e6fc6d5 100644 > --- a/gcc/gcc.c > +++ b/gcc/gcc.c > @@ -2928,6 +2928,7 @@ display_help (void) > fputs (_(" -dumpmachine Display the compiler's target processor\n"), stdout); > fputs (_(" -print-search-dirs Display the directories in the compiler's search path\n"), stdout); > fputs (_(" -print-libgcc-file-name Display the name of the compiler's companion library\n"), stdout); > + fputs (_(" -print-lto-plugin Display the name of the compiler's LTO plugin\n"), stdout); > fputs (_(" -print-file-name=<lib> Display the full path to library <lib>\n"), stdout); > fputs (_(" -print-prog-name=<prog> Display the full path to compiler component <prog>\n"), stdout); > fputs (_(" -print-multi-directory Display the root directory for versions of libgcc\n"), stdout); > @@ -3222,6 +3223,7 @@ driver_handle_option (struct gcc_options *opts, > case OPT_print_sysroot: > case OPT_print_multi_os_directory: > case OPT_print_sysroot_headers_suffix: > + case OPT_print_lto_plugin: > case OPT_time: > case OPT_wrapper: > /* These options set the variables specified in common.opt > @@ -6536,6 +6538,17 @@ main (int argc, char **argv) > fatal_error ("not configured with sysroot headers suffix"); > } > > + if (print_lto_plugin) > + { > + char *plugin; > + > + plugin = find_a_file (&exec_prefixes, "liblto_plugin.so", R_OK, false); > + if (!plugin) > + fatal_error ("-print-lto-plugin specified, but no plugin found"); > + printf ("%s\n", plugin); > + return (0); > + } > + > if (print_help_list) > { > display_help (); > -- > 1.7.1 > >
On Fri, Oct 29, 2010 at 03:39:42PM +0200, Richard Guenther wrote: > On Fri, Oct 29, 2010 at 1:46 PM, Andi Kleen <andi@firstfloor.org> wrote: > > From: Andi Kleen <ak@linux.intel.com> > > > > binutils have LTO linker plugin support now, but it requires hardcoding > > the path to gcc's libexec dir in the Makefile. Add an option to the > > gcc driver instead to print the full file name to avoid this. > > > > This is especially useful for ar or nm. > > Is the reason for not using -print-file-name=liblto-plugin.so to not hardcode > that name? (which you still did in the patch - not sure if it's that specific > name on all hosts). Yes, David Korn pointed out that doesn't work on Windows because of the postfix. His COFF work is not merged yet, but he can simply switch the file name around in gcc. on Windows when that gets merged. That's better than having special cases everywhere in makefiles or in the wrappers. -Andi
On Fri, Oct 29, 2010 at 4:46 AM, Andi Kleen <andi@firstfloor.org> wrote: > From: Andi Kleen <ak@linux.intel.com> > > binutils have LTO linker plugin support now, but it requires hardcoding > the path to gcc's libexec dir in the Makefile. Add an option to the > gcc driver instead to print the full file name to avoid this. > > This is especially useful for ar or nm. > There is [hjl@gnu-6 gcc]$ grep LTOPLUGINSONAME configure.ac AC_DEFINE_UNQUOTED(LTOPLUGINSONAME,"${host_lto_plugin_soname}", [hjl@gnu-6 gcc]$ Why not add LTOPLUGINSONAME to Makefile? Then you can use "gcc --print ...=$(LTOPLUGINSONAME)" to generate your scripts?
> [hjl@gnu-6 gcc]$ grep LTOPLUGINSONAME configure.ac > AC_DEFINE_UNQUOTED(LTOPLUGINSONAME,"${host_lto_plugin_soname}", > [hjl@gnu-6 gcc]$ > > Why not add LTOPLUGINSONAME to Makefile? Then you can use > "gcc --print ...=$(LTOPLUGINSONAME)" to generate your scripts? To which Makefile? The scripts should be called from arbitary projects, not just the gcc makefile. I'm not sure why you're so against that option anyways, gcc has a couple of similar options to solve similar problems, why not have one more that is convenient? -Andi
On Fri, Oct 29, 2010 at 7:35 AM, Andi Kleen <andi@firstfloor.org> wrote: >> [hjl@gnu-6 gcc]$ grep LTOPLUGINSONAME configure.ac >> AC_DEFINE_UNQUOTED(LTOPLUGINSONAME,"${host_lto_plugin_soname}", >> [hjl@gnu-6 gcc]$ >> >> Why not add LTOPLUGINSONAME to Makefile? Then you can use >> "gcc --print ...=$(LTOPLUGINSONAME)" to generate your scripts? > > To which Makefile? The scripts should be called from arbitary > projects, not just the gcc makefile. You can use $(LTOPLUGINSONAME) when you generate your LTO wrappers: http://gcc.gnu.org/ml/gcc-patches/2010-10/msg02472.html > I'm not sure why you're so against that option anyways, > gcc has a couple of similar options to solve similar problems, > why not have one more that is convenient? > I don't think it is necessary, especially with your LTO wrappers.
diff --git a/gcc/common.opt b/gcc/common.opt index a74d60d..2b6c73b 100644 --- a/gcc/common.opt +++ b/gcc/common.opt @@ -183,6 +183,9 @@ Driver JoinedOrMissing Alias(print-file-name=) -print-libgcc-file-name Driver Alias(print-libgcc-file-name) +-print-lto-plugin +Driver Alias(print-lto-plugin) + -print-multi-directory Driver Alias(print-multi-directory) @@ -1932,6 +1935,9 @@ Driver JoinedOrMissing Var(print_file_name) print-libgcc-file-name Driver +print-lto-plugin +Driver Var(print_lto_plugin) + print-multi-directory Driver Var(print_multi_directory) diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index 7ea042f..d6784ad 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -322,7 +322,7 @@ Objective-C and Objective-C++ Dialects}. -fdebug-prefix-map=@var{old}=@var{new} @gol -femit-struct-debug-baseonly -femit-struct-debug-reduced @gol -femit-struct-debug-detailed@r{[}=@var{spec-list}@r{]} @gol --p -pg -print-file-name=@var{library} -print-libgcc-file-name @gol +-p -pg -print-file-name=@var{library} -print-libgcc-file-name -print-lto-plugin @gol -print-multi-directory -print-multi-lib -print-multi-os-directory @gol -print-prog-name=@var{program} -print-search-dirs -Q @gol -print-sysroot -print-sysroot-headers-suffix @gol @@ -5725,6 +5725,13 @@ Same as @option{-print-file-name=libgcc.a}. This is useful when you use @option{-nostdlib} or @option{-nodefaultlibs} but you do want to link with @file{libgcc.a}. You can do +@item -print-lto-plugin +@opindex print-lto-plugin +Print the path name of the LTO linker plugin used by the compiler. + +This is useful to pass to ar, gold, ld or other binutils with linker +plugin support. + @smallexample gcc -nostdlib @var{files}@dots{} `gcc -print-libgcc-file-name` @end smallexample diff --git a/gcc/gcc.c b/gcc/gcc.c index 13635d5..e6fc6d5 100644 --- a/gcc/gcc.c +++ b/gcc/gcc.c @@ -2928,6 +2928,7 @@ display_help (void) fputs (_(" -dumpmachine Display the compiler's target processor\n"), stdout); fputs (_(" -print-search-dirs Display the directories in the compiler's search path\n"), stdout); fputs (_(" -print-libgcc-file-name Display the name of the compiler's companion library\n"), stdout); + fputs (_(" -print-lto-plugin Display the name of the compiler's LTO plugin\n"), stdout); fputs (_(" -print-file-name=<lib> Display the full path to library <lib>\n"), stdout); fputs (_(" -print-prog-name=<prog> Display the full path to compiler component <prog>\n"), stdout); fputs (_(" -print-multi-directory Display the root directory for versions of libgcc\n"), stdout); @@ -3222,6 +3223,7 @@ driver_handle_option (struct gcc_options *opts, case OPT_print_sysroot: case OPT_print_multi_os_directory: case OPT_print_sysroot_headers_suffix: + case OPT_print_lto_plugin: case OPT_time: case OPT_wrapper: /* These options set the variables specified in common.opt @@ -6536,6 +6538,17 @@ main (int argc, char **argv) fatal_error ("not configured with sysroot headers suffix"); } + if (print_lto_plugin) + { + char *plugin; + + plugin = find_a_file (&exec_prefixes, "liblto_plugin.so", R_OK, false); + if (!plugin) + fatal_error ("-print-lto-plugin specified, but no plugin found"); + printf ("%s\n", plugin); + return (0); + } + if (print_help_list) { display_help ();
From: Andi Kleen <ak@linux.intel.com> binutils have LTO linker plugin support now, but it requires hardcoding the path to gcc's libexec dir in the Makefile. Add an option to the gcc driver instead to print the full file name to avoid this. This is especially useful for ar or nm. gcc/ 2010-10-02 Andi Kleen <ak@linux.intel.com> * common.opt (-print-lto-plugin): Add. * doc/invoke.texi (-print-lto-plugin): Document. * gcc.c (display_help): Describe -print-lto-plugin. (main.c): Handle print_lto_plugin. --- gcc/common.opt | 6 ++++++ gcc/doc/invoke.texi | 9 ++++++++- gcc/gcc.c | 13 +++++++++++++ 3 files changed, 27 insertions(+), 1 deletions(-)