aboutsummaryrefslogtreecommitdiff
path: root/gcc/gcc.c
diff options
context:
space:
mode:
authorMark Mitchell <mark@codesourcery.com>2005-04-27 20:35:54 +0000
committerMark Mitchell <mark@codesourcery.com>2005-04-27 20:35:54 +0000
commit72c845691cedc1da906ebb7333441c0c9817cf24 (patch)
treee35f58f5c5ef495d2de849689e0398b292c98c9c /gcc/gcc.c
parentee4353c76f381077a4d528a6d36ea1bcab029633 (diff)
* configure.ac: Check for ld --sysroot support.
* gcc.c: Document %R specifier for specs. (SYSROOT_SPEC): New macro. (sysroot_spec): New variable. (static_specs): Add sysroot_spec. (main): Pass the sysroot spec to the linker if appropriate. * configure: Regenerated. * config.in: Likewise. git-svn-id: https://gcc.gnu.org/svn/gcc/trunk@98880 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/gcc.c')
-rw-r--r--gcc/gcc.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/gcc/gcc.c b/gcc/gcc.c
index 632e93749dc..1a0418d9ed0 100644
--- a/gcc/gcc.c
+++ b/gcc/gcc.c
@@ -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)