Attached patch adds a possibility to add additional build steps after linking. Without this patch only possibility is to redefine entire LINK_COMMAND_SPEC. Currently only DJGPP seems to need it
2013-11-05 Andris Pavenis <andris.pave...@iki.fi> * gcc/gcc.c: Add macro POST_LINK SPEC for specifying additional steps to invoke after linking * gcc/doc/tm.texi.in: (POST_LINK_SPEC): new * gcc/doc/tm.texi: regenerate Bootstrapped and tested on Linux x86_64 (Fedora 19) Andris
>From 3dd27dc54f3fd38d2b1e9b7fb53938be4df8da7c Mon Sep 17 00:00:00 2001 From: Andris Pavenis <andris.pave...@iki.fi> Date: Tue, 5 Nov 2013 11:52:17 +0200 Subject: [PATCH] POST_LINK_SPEC: new define for additional steps after linking This allows to avoid redefining LINK_COMMAND_SPEC when additional steps are needed after linking An example: invoking stubify after linking for DJGPP --- gcc/doc/tm.texi | 6 ++++++ gcc/doc/tm.texi.in | 6 ++++++ gcc/gcc.c | 8 +++++++- 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi index 72daf09..692f675 100644 --- a/gcc/doc/tm.texi +++ b/gcc/doc/tm.texi @@ -402,6 +402,12 @@ the target makefile fragment or if none of the options listed in @xref{Target Fragment}. @end defmac +@defmac POST_LINK_SPEC +A C string constant giving complete commands needed to execute after linker. +This macro allows to avoid redefining LINK_COMMAND_SPEC when additional +steps are needed after invoking linker. The default value is empty string. +@end defmac + @defmac RELATIVE_PREFIX_NOT_LINKDIR Define this macro to tell @command{gcc} that it should only translate a @option{-B} prefix into a @option{-L} linker option if the prefix diff --git a/gcc/doc/tm.texi.in b/gcc/doc/tm.texi.in index 2828361..edc2b9d 100644 --- a/gcc/doc/tm.texi.in +++ b/gcc/doc/tm.texi.in @@ -400,6 +400,12 @@ the target makefile fragment or if none of the options listed in @xref{Target Fragment}. @end defmac +@defmac POST_LINK_SPEC +A C string constant giving complete commands needed to execute after linker. +This macro allows to avoid redefining LINK_COMMAND_SPEC when additional +steps are needed after invoking linker. The default value is empty string. +@end defmac + @defmac RELATIVE_PREFIX_NOT_LINKDIR Define this macro to tell @command{gcc} that it should only translate a @option{-B} prefix into a @option{-L} linker option if the prefix diff --git a/gcc/gcc.c b/gcc/gcc.c index 2298249..cc0ac29 100644 --- a/gcc/gcc.c +++ b/gcc/gcc.c @@ -745,6 +745,10 @@ proper position among the other output files. */ %{fvtable-verify=preinit: -lvtv -u_vtable_map_vars_start -u_vtable_map_vars_end}}" #endif +#ifndef POST_LINK_SPEC +#define POST_LINK_SPEC "" +#endif + /* -u* was put back because both BSD and SysV seem to support it. */ /* %{static:} simply prevents an error message if the target machine doesn't handle -static. */ @@ -770,7 +774,7 @@ proper position among the other output files. */ %(mflib) " STACK_SPLIT_SPEC "\ %{fprofile-arcs|fprofile-generate*|coverage:-lgcov} " SANITIZER_SPEC " \ %{!nostdlib:%{!nodefaultlibs:%(link_ssp) %(link_gcc_c_sequence)}}\ - %{!nostdlib:%{!nostartfiles:%E}} %{T*} }}}}}}" + %{!nostdlib:%{!nostartfiles:%E}} %{T*} \n%(post_link) }}}}}}" #endif #ifndef LINK_LIBGCC_SPEC @@ -812,6 +816,7 @@ static const char *linker_name_spec = LINKER_NAME; static const char *linker_plugin_file_spec = ""; static const char *lto_wrapper_spec = ""; static const char *lto_gcc_spec = ""; +static const char *post_link_spec = POST_LINK_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; @@ -1304,6 +1309,7 @@ static struct spec_list static_specs[] = INIT_STATIC_SPEC ("linker_plugin_file", &linker_plugin_file_spec), INIT_STATIC_SPEC ("lto_wrapper", <o_wrapper_spec), INIT_STATIC_SPEC ("lto_gcc", <o_gcc_spec), + INIT_STATIC_SPEC ("post_link", &post_link_spec), INIT_STATIC_SPEC ("link_libgcc", &link_libgcc_spec), INIT_STATIC_SPEC ("md_exec_prefix", &md_exec_prefix), INIT_STATIC_SPEC ("md_startfile_prefix", &md_startfile_prefix), -- 1.8.3.1