From 380e5ca402e4dc6441a903de5ff88593f92f71d7 Mon Sep 17 00:00:00 2001 From: Mark Mitchell Date: Wed, 27 Apr 2005 20:35:54 +0000 Subject: [PATCH] configure.ac: Check for ld --sysroot support. * 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. From-SVN: r98880 --- gcc/ChangeLog | 11 +++++++++++ gcc/config.in | 3 +++ gcc/configure | 26 ++++++++++++++++++++++++++ gcc/configure.ac | 17 +++++++++++++++++ gcc/gcc.c | 21 +++++++++++++++++++++ 5 files changed, 78 insertions(+) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 4d31978..c02765c 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,14 @@ +2005-04-27 Mark Mitchell + + * 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. + 2005-04-27 Richard Guenther * fold-const.c (fold_binary): Use build_fold_addr_expr diff --git a/gcc/config.in b/gcc/config.in index 6e4026b..eae8b54 100644 --- a/gcc/config.in +++ b/gcc/config.in @@ -461,6 +461,9 @@ /* Define if your linker supports -Bstatic/-Bdynamic option. */ #undef HAVE_LD_STATIC_DYNAMIC +/* Define if your linker supports --sysroot. */ +#undef HAVE_LD_SYSROOT + /* Define to 1 if you have the header file. */ #undef HAVE_LIMITS_H diff --git a/gcc/configure b/gcc/configure index 98639db..bf9966f 100755 --- a/gcc/configure +++ b/gcc/configure @@ -15050,6 +15050,32 @@ _ACEOF ;; esac +echo "$as_me:$LINENO: checking linker --sysroot support" >&5 +echo $ECHO_N "checking linker --sysroot support... $ECHO_C" >&6 +if test "${gcc_cv_ld_sysroot+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + gcc_cv_ld_sysroot=no + if test $in_tree_ld = yes ; then + if test "$gcc_cv_gld_major_version" -eq 2 -a "$gcc_cv_gld_minor_version" -ge 16 -o "$gcc_cv_gld_major_version" -gt 2 ; then + gcc_cv_ld_sysroot = yes + fi + elif test x$gcc_cv_ld != x; then + if $gcc_cv_ld --help 2>/dev/null | grep sysroot > /dev/null; then + gcc_cv_ld_sysroot=yes + fi + fi +fi +echo "$as_me:$LINENO: result: $gcc_cv_ld_sysroot" >&5 +echo "${ECHO_T}$gcc_cv_ld_sysroot" >&6 +if test x"$gcc_cv_ld_sysroot" = xyes; then + +cat >>confdefs.h <<\_ACEOF +#define HAVE_LD_SYSROOT 1 +_ACEOF + +fi + if test x$with_sysroot = x && test x$host = x$target \ && test "$prefix" != "/usr" && test "x$prefix" != "x$local_prefix" ; then diff --git a/gcc/configure.ac b/gcc/configure.ac index efa758c..23c914d 100644 --- a/gcc/configure.ac +++ b/gcc/configure.ac @@ -3024,6 +3024,23 @@ EOF ;; esac +AC_CACHE_CHECK(linker --sysroot support, + gcc_cv_ld_sysroot, + [gcc_cv_ld_sysroot=no + if test $in_tree_ld = yes ; then + if test "$gcc_cv_gld_major_version" -eq 2 -a "$gcc_cv_gld_minor_version" -ge 16 -o "$gcc_cv_gld_major_version" -gt 2 ; then + gcc_cv_ld_sysroot = yes + fi + elif test x$gcc_cv_ld != x; then + if $gcc_cv_ld --help 2>/dev/null | grep sysroot > /dev/null; then + gcc_cv_ld_sysroot=yes + fi + fi]) +if test x"$gcc_cv_ld_sysroot" = xyes; then + AC_DEFINE(HAVE_LD_SYSROOT, 1, + [Define if your linker supports --sysroot.]) +fi + if test x$with_sysroot = x && test x$host = x$target \ && test "$prefix" != "/usr" && test "x$prefix" != "x$local_prefix" ; then AC_DEFINE_UNQUOTED(PREFIX_INCLUDE_DIR, "$prefix/include", diff --git a/gcc/gcc.c b/gcc/gcc.c index 632e937..1a0418d 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) -- 2.7.4