From 9a37bc079dd8e0d3d649b5e38464a5e5977d7baa Mon Sep 17 00:00:00 2001 From: Dave Korn Date: Tue, 23 Nov 2010 19:18:39 +0000 Subject: [PATCH] re PR driver/42690 (Undefined reference errors with -flto -fuse-linker-plugin) PR driver/42690 * gcc.c (LINK_COMMAND_SPEC): Remove hard-coded pass-through plugin options, replace by call of pass-through-libs spec function to process link_gcc_c_sequence spec. (lto_libgcc_spec): Delete variable. (static_specs[]): Remove related entry. (static_spec_functions[]): Add new entry for pass-through-libs. (main): Don't generate deleted lto_libgcc_spec. (pass_through_libs_spec_func): New function to implement the new pass-through-libs spec function. * doc/invoke.texi (pass-through-libs): Document new spec function. From-SVN: r167091 --- gcc/ChangeLog | 14 ++++++++++++ gcc/doc/invoke.texi | 12 ++++++++++ gcc/gcc.c | 55 +++++++++++++++++++++++++++++++++++++-------- 3 files changed, 72 insertions(+), 9 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index c65a0545f9a..db6f8ab0424 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,17 @@ +2010-11-23 Dave Korn + + PR driver/42690 + * gcc.c (LINK_COMMAND_SPEC): Remove hard-coded pass-through plugin + options, replace by call of pass-through-libs spec function to process + link_gcc_c_sequence spec. + (lto_libgcc_spec): Delete variable. + (static_specs[]): Remove related entry. + (static_spec_functions[]): Add new entry for pass-through-libs. + (main): Don't generate deleted lto_libgcc_spec. + (pass_through_libs_spec_func): New function to implement the new + pass-through-libs spec function. + * doc/invoke.texi (pass-through-libs): Document new spec function. + 2010-11-23 Joseph Myers * doc/options.texi (Warning, Optimization): Document. diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index e8d1d1dac22..c2ffea85abd 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -9690,6 +9690,18 @@ its usage: %:remove-outfile(-lm) @end smallexample +@item @code{pass-through-libs} +The @code{pass-through-libs} spec function takes any number of arguments. It +finds any @option{-l} options and any non-options ending in ".a" (which it +assumes are the names of linker input library archive files) and returns a +result containing all the found arguments each prepended by +@option{-plugin-opt=-pass-through=} and joined by spaces. This list is +intended to be passed to the LTO linker plugin. + +@smallexample +%:pass-through-libs(%G %L %G) +@end smallexample + @item @code{print-asm-header} The @code{print-asm-header} function takes no arguments and simply prints a banner like: diff --git a/gcc/gcc.c b/gcc/gcc.c index 99d4f480d56..c2998bd96b8 100644 --- a/gcc/gcc.c +++ b/gcc/gcc.c @@ -284,6 +284,7 @@ static const char *print_asm_header_spec_function (int, const char **); static const char *compare_debug_dump_opt_spec_function (int, const char **); static const char *compare_debug_self_opt_spec_function (int, const char **); static const char *compare_debug_auxbase_opt_spec_function (int, const char **); +static const char *pass_through_libs_spec_func (int, const char **); /* The Specs Language @@ -656,8 +657,7 @@ proper position among the other output files. */ -plugin %(linker_plugin_file) \ -plugin-opt=%(lto_wrapper) \ -plugin-opt=-fresolution=%u.res \ - %{static|static-libgcc:-plugin-opt=-pass-through=%(lto_libgcc)} \ - %{static:-plugin-opt=-pass-through=-lc} \ + %{!nostdlib:%{!nodefaultlibs:%:pass-through-libs(%(link_gcc_c_sequence))}} \ } \ %{flto*:%= argc) + break; + else if (!*lopt) + lopt = argv[n]; + prepended = concat (prepended, "-plugin-opt=-pass-through=-l", + lopt, " ", NULL); + } + else if (!strcmp (".a", argv[n] + strlen (argv[n]) - 2)) + { + prepended = concat (prepended, "-plugin-opt=-pass-through=", + argv[n], " ", NULL); + } + if (prepended != old) + free (old); + } + return prepended; +}