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
This commit is contained in:
Mark Mitchell 2005-04-27 20:35:54 +00:00 committed by Mark Mitchell
parent c7a5c62381
commit 380e5ca402
5 changed files with 78 additions and 0 deletions

View File

@ -1,3 +1,14 @@
2005-04-27 Mark Mitchell <mark@codesourcery.com>
* 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 <rguenth@gcc.gnu.org>
* fold-const.c (fold_binary): Use build_fold_addr_expr

View File

@ -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 <limits.h> header file. */
#undef HAVE_LIMITS_H

26
gcc/configure vendored
View File

@ -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

View File

@ -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",

View File

@ -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)