From patchwork Sat Oct 2 21:24:34 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andi Kleen X-Patchwork-Id: 66586 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 27C9FB70CB for ; Sun, 3 Oct 2010 08:24:47 +1100 (EST) Received: (qmail 18846 invoked by alias); 2 Oct 2010 21:24:46 -0000 Received: (qmail 18836 invoked by uid 22791); 2 Oct 2010 21:24:45 -0000 X-SWARE-Spam-Status: No, hits=-1.9 required=5.0 tests=AWL, BAYES_00, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from one.firstfloor.org (HELO one.firstfloor.org) (213.235.205.2) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sat, 02 Oct 2010 21:24:40 +0000 Received: from basil.firstfloor.org (p5B3C8AA2.dip0.t-ipconnect.de [91.60.138.162]) by one.firstfloor.org (Postfix) with ESMTP id 9B0731A9804F; Sat, 2 Oct 2010 23:24:37 +0200 (CEST) Received: by basil.firstfloor.org (Postfix, from userid 1000) id 35066B2532; Sat, 2 Oct 2010 23:24:37 +0200 (CEST) From: Andi Kleen To: gcc-patches@gcc.gnu.org Cc: Andi Kleen Subject: [PATCH] Add -print-lto-plugin Date: Sat, 2 Oct 2010 23:24:34 +0200 Message-Id: <1286054674-20295-1-git-send-email-andi@firstfloor.org> Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org From: Andi Kleen 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. Passes bootstrap and test on x86-64. Ok to commit? 2010-10-02 Andi Kleen * 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 44a3de8..fe8e718 100644 --- a/gcc/common.opt +++ b/gcc/common.opt @@ -157,6 +157,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) @@ -1902,6 +1905,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 057ae7d..530d4dc 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 @@ -5715,6 +5715,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 ef637e9..ea0987a 100644 --- a/gcc/gcc.c +++ b/gcc/gcc.c @@ -2937,6 +2937,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= Display the full path to library \n"), stdout); fputs (_(" -print-prog-name= Display the full path to compiler component \n"), stdout); fputs (_(" -print-multi-directory Display the root directory for versions of libgcc\n"), stdout); @@ -3229,6 +3230,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 @@ -6534,6 +6536,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 ();