diff options
Diffstat (limited to 'gcc/gcc.c')
-rw-r--r-- | gcc/gcc.c | 21 |
1 files changed, 21 insertions, 0 deletions
@@ -460,6 +460,8 @@ or with constant text in a single argument. %l process LINK_SPEC as a spec. %L process LIB_SPEC as a spec. %G process LIBGCC_SPEC as a spec. + %R Output the concatenation of target_system_root and + target_sysroot_suffix. %S process STARTFILE_SPEC as a spec. A capital S is actually used here. %E process ENDFILE_SPEC as a spec. A capital E is actually used here. %C process CPP_SPEC as a spec. @@ -701,6 +703,10 @@ proper position among the other output files. */ # define STARTFILE_PREFIX_SPEC "" #endif +#ifndef SYSROOT_SPEC +# define SYSROOT_SPEC "--sysroot=%R" +#endif + #ifndef SYSROOT_SUFFIX_SPEC # define SYSROOT_SUFFIX_SPEC "" #endif @@ -728,6 +734,7 @@ static const char *linker_name_spec = LINKER_NAME; 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; +static const char *sysroot_spec = SYSROOT_SPEC; static const char *sysroot_suffix_spec = SYSROOT_SUFFIX_SPEC; static const char *sysroot_hdrs_suffix_spec = SYSROOT_HEADERS_SUFFIX_SPEC; @@ -1532,6 +1539,7 @@ static struct spec_list static_specs[] = INIT_STATIC_SPEC ("md_startfile_prefix", &md_startfile_prefix), INIT_STATIC_SPEC ("md_startfile_prefix_1", &md_startfile_prefix_1), INIT_STATIC_SPEC ("startfile_prefix_spec", &startfile_prefix_spec), + INIT_STATIC_SPEC ("sysroot_spec", &sysroot_spec), INIT_STATIC_SPEC ("sysroot_suffix_spec", &sysroot_suffix_spec), INIT_STATIC_SPEC ("sysroot_hdrs_suffix_spec", &sysroot_hdrs_suffix_spec), }; @@ -6148,6 +6156,19 @@ main (int argc, const char **argv) target_sysroot_suffix = xstrdup (argbuf[argbuf_index -1]); } +#ifdef HAVE_LD_SYSROOT + /* Pass the --sysroot option to the linker, if it supports that. If + there is a sysroot_suffix_spec, it has already been processed by + this point, so target_system_root really is the system root we + should be using. */ + if (target_system_root) + { + obstack_grow (&obstack, "%(sysroot_spec) ", strlen ("%(sysroot_spec) ")); + obstack_grow0 (&obstack, link_spec, strlen (link_spec)); + set_spec ("link", obstack_finish (&obstack)); + } +#endif + /* Process sysroot_hdrs_suffix_spec. */ if (*sysroot_hdrs_suffix_spec != 0 && do_spec_2 (sysroot_hdrs_suffix_spec) == 0) |