Commit eb89c82f by Iain Sandoe Committed by Iain Sandoe

[Darwin, config] Arrange for ld64 to be detected as Darwin's linker.

 This is an initial patch in a series that converts Darwin's configury
 to detect ld64 features, rather than the current process of hard-coding
 them on target system version.

 A ld64-compatible linker is currently required and assumed by Darwin.
 If a DEFAULT_LINKER is set via --with-ld= then this will be tested to
 see if it is ld64.

 The ld64 version is determined for the chosen ld and this is exported for
 use in setting a default value for -mtarget-linker (needed for run-time
 code-gen changes to section choices).
 The support for -rdynamic is converted to be detected at config time, or
 by the ld64 version if that is found.

gcc/

2016-11-27  Iain Sandoe  <iain@codesourcery.com>

	PR target/71767
	* configure.ac (with-ld64): New var, set for Darwin, set on
	detection of ld64, gcc_cv_ld64_export_dynamic: New, New test.
	* config/darwin.h: Use LD64_HAS_DYNAMIC export. DEF_LD64: New,
	define.
	* config/darwin10.h(DEF_LD64): Update for this target version.
	* config/darwin12.h(LINK_GCC_C_SEQUENCE_SPEC): Remove rdynamic
	test.  (DEF_LD64): Update for this target version.
	* configure: Regenerated.
	* config.in: Regenerated.

From-SVN: r242894
parent 7881b63f
2016-11-27 Iain Sandoe <iain@codesourcery.com> 2016-11-27 Iain Sandoe <iain@codesourcery.com>
PR target/71767 PR target/71767
* configure.ac (with-ld64): New var, set for Darwin, set on
detection of ld64, gcc_cv_ld64_export_dynamic: New, New test.
* config/darwin.h: Use LD64_HAS_DYNAMIC export. DEF_LD64: New,
define.
* config/darwin10.h(DEF_LD64): Update for this target version.
* config/darwin12.h(LINK_GCC_C_SEQUENCE_SPEC): Remove rdynamic
test. (DEF_LD64): Update for this target version.
* configure: Regenerated.
* config.in: Regenerated.
2016-11-27 Iain Sandoe <iain@codesourcery.com>
PR target/71767
* config/darwin.c (imachopic_indirection_name): Make data * config/darwin.c (imachopic_indirection_name): Make data
section indirections linker-visible. section indirections linker-visible.
* config/darwin.h (ASM_GENERATE_INTERNAL_LABEL): Make local * config/darwin.h (ASM_GENERATE_INTERNAL_LABEL): Make local
...@@ -1946,6 +1946,18 @@ ...@@ -1946,6 +1946,18 @@
#endif #endif
/* Define to 1 if ld64 supports '-export_dynamic'. */
#ifndef USED_FOR_TARGET
#undef LD64_HAS_EXPORT_DYNAMIC
#endif
/* Define to ld64 version. */
#ifndef USED_FOR_TARGET
#undef LD64_VERSION
#endif
/* Define to the linker option to ignore unused dependencies. */ /* Define to the linker option to ignore unused dependencies. */
#ifndef USED_FOR_TARGET #ifndef USED_FOR_TARGET
#undef LD_AS_NEEDED_OPTION #undef LD_AS_NEEDED_OPTION
......
...@@ -165,6 +165,12 @@ extern GTY(()) int darwin_ms_struct; ...@@ -165,6 +165,12 @@ extern GTY(()) int darwin_ms_struct;
specifying the handling of options understood by generic Unix specifying the handling of options understood by generic Unix
linkers, and for positional arguments like libraries. */ linkers, and for positional arguments like libraries. */
#if LD64_HAS_EXPORT_DYNAMIC
#define DARWIN_EXPORT_DYNAMIC " %{rdynamic:-export_dynamic}"
#else
#define DARWIN_EXPORT_DYNAMIC " %{rdynamic: %nrdynamic is not supported}"
#endif
#define LINK_COMMAND_SPEC_A \ #define LINK_COMMAND_SPEC_A \
"%{!fdump=*:%{!fsyntax-only:%{!c:%{!M:%{!MM:%{!E:%{!S:\ "%{!fdump=*:%{!fsyntax-only:%{!c:%{!M:%{!MM:%{!E:%{!S:\
%(linker)" \ %(linker)" \
...@@ -185,7 +191,9 @@ extern GTY(()) int darwin_ms_struct; ...@@ -185,7 +191,9 @@ extern GTY(()) int darwin_ms_struct;
%{!nostdlib:%{!nodefaultlibs:\ %{!nostdlib:%{!nodefaultlibs:\
%{%:sanitize(address): -lasan } \ %{%:sanitize(address): -lasan } \
%{%:sanitize(undefined): -lubsan } \ %{%:sanitize(undefined): -lubsan } \
%(link_ssp) %(link_gcc_c_sequence)\ %(link_ssp) \
" DARWIN_EXPORT_DYNAMIC " %<rdynamic \
%(link_gcc_c_sequence) \
}}\ }}\
%{!nostdlib:%{!nostartfiles:%E}} %{T*} %{F*} }}}}}}}" %{!nostdlib:%{!nostartfiles:%E}} %{T*} %{F*} }}}}}}}"
...@@ -932,4 +940,10 @@ extern void darwin_driver_init (unsigned int *,struct cl_decoded_option **); ...@@ -932,4 +940,10 @@ extern void darwin_driver_init (unsigned int *,struct cl_decoded_option **);
fall-back default. */ fall-back default. */
#define DEF_MIN_OSX_VERSION "10.5" #define DEF_MIN_OSX_VERSION "10.5"
#ifndef LD64_VERSION
#define LD64_VERSION "85.2"
#else
#define DEF_LD64 LD64_VERSION
#endif
#endif /* CONFIG_DARWIN_H */ #endif /* CONFIG_DARWIN_H */
...@@ -32,3 +32,8 @@ along with GCC; see the file COPYING3. If not see ...@@ -32,3 +32,8 @@ along with GCC; see the file COPYING3. If not see
#undef DEF_MIN_OSX_VERSION #undef DEF_MIN_OSX_VERSION
#define DEF_MIN_OSX_VERSION "10.6" #define DEF_MIN_OSX_VERSION "10.6"
#ifndef LD64_VERSION
#undef DEF_LD64
#define DEF_LD64 "97.7"
#endif
...@@ -21,10 +21,15 @@ along with GCC; see the file COPYING3. If not see ...@@ -21,10 +21,15 @@ along with GCC; see the file COPYING3. If not see
#undef LINK_GCC_C_SEQUENCE_SPEC #undef LINK_GCC_C_SEQUENCE_SPEC
#define LINK_GCC_C_SEQUENCE_SPEC \ #define LINK_GCC_C_SEQUENCE_SPEC \
"%:version-compare(>= 10.6 mmacosx-version-min= -no_compact_unwind) \ "%:version-compare(>= 10.6 mmacosx-version-min= -no_compact_unwind) \
%{rdynamic:-export_dynamic} %{!static:%{!static-libgcc: \ %{!static:%{!static-libgcc: \
%:version-compare(>= 10.6 mmacosx-version-min= -lSystem) } } \ %:version-compare(>= 10.6 mmacosx-version-min= -lSystem) } } \
%{fno-pic|fno-PIC|fno-pie|fno-PIE|fapple-kext|mkernel|static|mdynamic-no-pic: \ %{fno-pic|fno-PIC|fno-pie|fno-PIE|fapple-kext|mkernel|static|mdynamic-no-pic: \
%:version-compare(>= 10.7 mmacosx-version-min= -no_pie) } %G %L" %:version-compare(>= 10.7 mmacosx-version-min= -no_pie) } %G %L"
#undef DEF_MIN_OSX_VERSION #undef DEF_MIN_OSX_VERSION
#define DEF_MIN_OSX_VERSION "10.8" #define DEF_MIN_OSX_VERSION "10.8"
#ifndef LD64_VERSION
#undef DEF_LD64
#define DEF_LD64 "236.4"
#endif
...@@ -3639,6 +3639,11 @@ else ...@@ -3639,6 +3639,11 @@ else
fi fi
case $target in
*darwin*) ld64_flag=yes;; # Darwin can only use a ld64-compatible linker.
*) ld64_flag=no;;
esac
# With pre-defined ld # With pre-defined ld
# Check whether --with-ld was given. # Check whether --with-ld was given.
...@@ -3651,6 +3656,8 @@ if test x"${DEFAULT_LINKER+set}" = x"set"; then ...@@ -3651,6 +3656,8 @@ if test x"${DEFAULT_LINKER+set}" = x"set"; then
as_fn_error "cannot execute: $DEFAULT_LINKER: check --with-ld or env. var. DEFAULT_LINKER" "$LINENO" 5 as_fn_error "cannot execute: $DEFAULT_LINKER: check --with-ld or env. var. DEFAULT_LINKER" "$LINENO" 5
elif $DEFAULT_LINKER -v < /dev/null 2>&1 | grep GNU > /dev/null; then elif $DEFAULT_LINKER -v < /dev/null 2>&1 | grep GNU > /dev/null; then
gnu_ld_flag=yes gnu_ld_flag=yes
elif $DEFAULT_LINKER -v < /dev/null 2>&1 | grep ld64- > /dev/null; then
ld64_flag=yes
fi fi
cat >>confdefs.h <<_ACEOF cat >>confdefs.h <<_ACEOF
...@@ -18423,7 +18430,7 @@ else ...@@ -18423,7 +18430,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF cat > conftest.$ac_ext <<_LT_EOF
#line 18426 "configure" #line 18433 "configure"
#include "confdefs.h" #include "confdefs.h"
#if HAVE_DLFCN_H #if HAVE_DLFCN_H
...@@ -18529,7 +18536,7 @@ else ...@@ -18529,7 +18536,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF cat > conftest.$ac_ext <<_LT_EOF
#line 18532 "configure" #line 18539 "configure"
#include "confdefs.h" #include "confdefs.h"
#if HAVE_DLFCN_H #if HAVE_DLFCN_H
...@@ -28287,6 +28294,71 @@ _ACEOF ...@@ -28287,6 +28294,71 @@ _ACEOF
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_ld_compress_debug" >&5 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_ld_compress_debug" >&5
$as_echo "$gcc_cv_ld_compress_debug" >&6; } $as_echo "$gcc_cv_ld_compress_debug" >&6; }
if test x"$ld64_flag" = x"yes"; then
# Set defaults for possibly untestable items.
gcc_cv_ld64_export_dynamic=0
if test "$build" = "$host"; then
darwin_try_test=1
else
darwin_try_test=0
fi
# On Darwin, because of FAT library support, it is often possible to execute
# exes from compatible archs even when the host differs from the build system.
case "$build","$host" in
x86_64-*-darwin*,i?86-*-darwin* | powerpc64*-*-darwin*,powerpc*-*-darwin*)
darwin_try_test=1;;
*) ;;
esac
# If the configurer specified a minimum ld64 version to be supported, then use
# that to determine feature support.
if test x"${gcc_cv_ld64_version}" != x; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking ld64 major version" >&5
$as_echo_n "checking ld64 major version... " >&6; }
IFS=. read gcc_cv_ld64_major gcc_cv_ld64_minor <<< "${gcc_cv_ld64_version}"
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_ld64_major" >&5
$as_echo "$gcc_cv_ld64_major" >&6; }
if test "$gcc_cv_ld64_major" -ge 236; then
gcc_cv_ld64_export_dynamic=1
fi
elif test -x "$gcc_cv_ld" -a "$darwin_try_test" -eq 1; then
# If the version was not specified, try to find it.
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking linker version" >&5
$as_echo_n "checking linker version... " >&6; }
if test x"${gcc_cv_ld64_version}" = x; then
gcc_cv_ld64_version=`$gcc_cv_ld -v 2>&1 | grep ld64 | sed s/.*ld64-// | awk '{print $1}'`
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_ld64_version" >&5
$as_echo "$gcc_cv_ld64_version" >&6; }
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking linker for -export_dynamic support" >&5
$as_echo_n "checking linker for -export_dynamic support... " >&6; }
gcc_cv_ld64_export_dynamic=1
if $gcc_cv_ld -export_dynamic < /dev/null 2>&1 | grep 'unknown option' > /dev/null; then
gcc_cv_ld64_export_dynamic=0
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_ld64_export_dynamic" >&5
$as_echo "$gcc_cv_ld64_export_dynamic" >&6; }
fi
if test x"${gcc_cv_ld64_version}" != x; then
cat >>confdefs.h <<_ACEOF
#define LD64_VERSION "${gcc_cv_ld64_version}"
_ACEOF
fi
cat >>confdefs.h <<_ACEOF
#define LD64_HAS_EXPORT_DYNAMIC $gcc_cv_ld64_export_dynamic
_ACEOF
fi
# -------- # --------
# UNSORTED # UNSORTED
# -------- # --------
......
...@@ -274,6 +274,11 @@ AC_ARG_WITH(gnu-ld, ...@@ -274,6 +274,11 @@ AC_ARG_WITH(gnu-ld,
gnu_ld_flag="$with_gnu_ld", gnu_ld_flag="$with_gnu_ld",
gnu_ld_flag=no) gnu_ld_flag=no)
case $target in
*darwin*) ld64_flag=yes;; # Darwin can only use a ld64-compatible linker.
*) ld64_flag=no;;
esac
# With pre-defined ld # With pre-defined ld
AC_ARG_WITH(ld, AC_ARG_WITH(ld,
[AS_HELP_STRING([--with-ld], [arrange to use the specified ld (full pathname)])], [AS_HELP_STRING([--with-ld], [arrange to use the specified ld (full pathname)])],
...@@ -283,6 +288,8 @@ if test x"${DEFAULT_LINKER+set}" = x"set"; then ...@@ -283,6 +288,8 @@ if test x"${DEFAULT_LINKER+set}" = x"set"; then
AC_MSG_ERROR([cannot execute: $DEFAULT_LINKER: check --with-ld or env. var. DEFAULT_LINKER]) AC_MSG_ERROR([cannot execute: $DEFAULT_LINKER: check --with-ld or env. var. DEFAULT_LINKER])
elif $DEFAULT_LINKER -v < /dev/null 2>&1 | grep GNU > /dev/null; then elif $DEFAULT_LINKER -v < /dev/null 2>&1 | grep GNU > /dev/null; then
gnu_ld_flag=yes gnu_ld_flag=yes
elif $DEFAULT_LINKER -v < /dev/null 2>&1 | grep ld64- > /dev/null; then
ld64_flag=yes
fi fi
AC_DEFINE_UNQUOTED(DEFAULT_LINKER,"$DEFAULT_LINKER", AC_DEFINE_UNQUOTED(DEFAULT_LINKER,"$DEFAULT_LINKER",
[Define to enable the use of a default linker.]) [Define to enable the use of a default linker.])
...@@ -5266,6 +5273,59 @@ AC_DEFINE_UNQUOTED(LD_COMPRESS_DEBUG_OPTION, "$gcc_cv_ld_compress_debug_option", ...@@ -5266,6 +5273,59 @@ AC_DEFINE_UNQUOTED(LD_COMPRESS_DEBUG_OPTION, "$gcc_cv_ld_compress_debug_option",
[Define to the linker option to enable compressed debug sections.]) [Define to the linker option to enable compressed debug sections.])
AC_MSG_RESULT($gcc_cv_ld_compress_debug) AC_MSG_RESULT($gcc_cv_ld_compress_debug)
if test x"$ld64_flag" = x"yes"; then
# Set defaults for possibly untestable items.
gcc_cv_ld64_export_dynamic=0
if test "$build" = "$host"; then
darwin_try_test=1
else
darwin_try_test=0
fi
# On Darwin, because of FAT library support, it is often possible to execute
# exes from compatible archs even when the host differs from the build system.
case "$build","$host" in
x86_64-*-darwin*,i?86-*-darwin* | powerpc64*-*-darwin*,powerpc*-*-darwin*)
darwin_try_test=1;;
*) ;;
esac
# If the configurer specified a minimum ld64 version to be supported, then use
# that to determine feature support.
if test x"${gcc_cv_ld64_version}" != x; then
AC_MSG_CHECKING(ld64 major version)
IFS=. read gcc_cv_ld64_major gcc_cv_ld64_minor <<< "${gcc_cv_ld64_version}"
AC_MSG_RESULT($gcc_cv_ld64_major)
if test "$gcc_cv_ld64_major" -ge 236; then
gcc_cv_ld64_export_dynamic=1
fi
elif test -x "$gcc_cv_ld" -a "$darwin_try_test" -eq 1; then
# If the version was not specified, try to find it.
AC_MSG_CHECKING(linker version)
if test x"${gcc_cv_ld64_version}" = x; then
gcc_cv_ld64_version=`$gcc_cv_ld -v 2>&1 | grep ld64 | sed s/.*ld64-// | awk '{print $1}'`
fi
AC_MSG_RESULT($gcc_cv_ld64_version)
AC_MSG_CHECKING(linker for -export_dynamic support)
gcc_cv_ld64_export_dynamic=1
if $gcc_cv_ld -export_dynamic < /dev/null 2>&1 | grep 'unknown option' > /dev/null; then
gcc_cv_ld64_export_dynamic=0
fi
AC_MSG_RESULT($gcc_cv_ld64_export_dynamic)
fi
if test x"${gcc_cv_ld64_version}" != x; then
AC_DEFINE_UNQUOTED(LD64_VERSION, "${gcc_cv_ld64_version}",
[Define to ld64 version.])
fi
AC_DEFINE_UNQUOTED(LD64_HAS_EXPORT_DYNAMIC, $gcc_cv_ld64_export_dynamic,
[Define to 1 if ld64 supports '-export_dynamic'.])
fi
# -------- # --------
# UNSORTED # UNSORTED
# -------- # --------
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment