diff options
author | Iain Sandoe <iain@sandoe.co.uk> | 2023-07-21 19:32:28 +0100 |
---|---|---|
committer | Iain Sandoe <iain@sandoe.co.uk> | 2025-08-13 18:26:14 +0100 |
commit | 90238c0f172b9ea7189cf295584632217792b55a (patch) | |
tree | eacb3efda466906c164b97a07c42e2d2040101c3 /gcc | |
parent | 4db9571488eb9f39f0b06435a8642a4f11e82dcf (diff) | |
download | gcc-90238c0f172b9ea7189cf295584632217792b55a.zip gcc-90238c0f172b9ea7189cf295584632217792b55a.tar.gz gcc-90238c0f172b9ea7189cf295584632217792b55a.tar.bz2 |
Darwin: Handle linker '-no_deduplicate' option.
Newer linker support an option to disable deduplication of entities.
This speeds up linking and can improve debug experience. Adopting the
same criteria as clang in adding the option.
Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
gcc/ChangeLog:
* config.in: Regenerate.
* config/darwin.h (DARWIN_LD_NO_DEDUPLICATE): New.
(LINK_SPEC): Handle -no_deduplicate.
* configure: Regenerate.
* configure.ac: Detect linker support for -no_deduplicate.
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/config.in | 6 | ||||
-rw-r--r-- | gcc/config/darwin.h | 28 | ||||
-rwxr-xr-x | gcc/configure | 19 | ||||
-rw-r--r-- | gcc/configure.ac | 14 |
4 files changed, 60 insertions, 7 deletions
diff --git a/gcc/config.in b/gcc/config.in index 353d1bc..183d0dfc 100644 --- a/gcc/config.in +++ b/gcc/config.in @@ -2375,6 +2375,12 @@ #endif +/* Define to 1 if ld64 supports '-no_deduplicate'. */ +#ifndef USED_FOR_TARGET +#undef LD64_HAS_NO_DEDUPLICATE +#endif + + /* Define to 1 if ld64 supports '-platform_version'. */ #ifndef USED_FOR_TARGET #undef LD64_HAS_PLATFORM_VERSION diff --git a/gcc/config/darwin.h b/gcc/config/darwin.h index ccfe01e..c3e28e2 100644 --- a/gcc/config/darwin.h +++ b/gcc/config/darwin.h @@ -287,6 +287,19 @@ extern GTY(()) int darwin_ms_struct; #define DARWIN_RDYNAMIC "%{rdynamic:%nrdynamic is not supported}" #endif +#if LD64_HAS_NO_DEDUPLICATE +/* What we want is "when the optimization level is debug OR when it is + a compile & link job with implied O0 optimization". */ +#define DARWIN_LD_NO_DEDUPLICATE \ + "%{O0|O1|O|Og: -no_deduplicate} \ + %{!O*:\ + %{.c|.cc|.C|.cpp|.cp|.c++|.cxx|.CPP|.m|.mm|.s|.S|.i|.ii|.mi|.mii|\ + .f|.for|.ftn|.fpp|.f90|.f95|.f03|.f08|.f77|.F|.F90|.F95|.F03|.F08|\ + .d|.mod: -no_deduplicate }} " +#else +#define DARWIN_LD_NO_DEDUPLICATE "" +#endif + #if LD64_HAS_MACOS_VERSION_MIN # define DARWIN_PLATFORM_ID \ "%{mmacosx-version-min=*:-macos_version_min %*} " @@ -403,10 +416,14 @@ extern GTY(()) int darwin_ms_struct; %(linker)" \ DARWIN_LD_DEMANGLE \ LINK_PLUGIN_SPEC \ + DARWIN_LD_NO_DEDUPLICATE \ "%{flto*:%<fcompare-debug*} \ %{flto} %{fno-lto} %{flto=*} \ - %l " \ + %{static}%{!static:%{!dynamic:-dynamic}} \ + %{force_cpusubtype_ALL:-arch %(darwin_arch)} \ + %{!force_cpusubtype_ALL:-arch %(darwin_subarch)} "\ DARWIN_PLATFORM_ID \ + " %l " \ LINK_COMPRESS_DEBUG_SPEC \ "%X %{s} %{t} %{Z} %{u*} \ %{e*} %{r} \ @@ -493,9 +510,8 @@ extern GTY(()) int darwin_ms_struct; Note that options taking arguments may appear multiple times on a command line with different arguments each time, so put a * after their names so all of them get passed. */ -#define LINK_SPEC \ - "%{static}%{!static:%{!dynamic:-dynamic}} \ - %:remove-outfile(-ldl) \ +#define LINK_SPEC \ + "%:remove-outfile(-ldl) \ %:remove-outfile(-lm) \ %:remove-outfile(-lpthread) \ %{fgnu-runtime: %{static|static-libgcc: \ @@ -511,9 +527,7 @@ extern GTY(()) int darwin_ms_struct; %{static|static-libgm2:%:replace-outfile(-lm2iso libm2iso.a%s)}\ %{static|static-libgm2:%:replace-outfile(-lm2min libm2min.a%s)}\ %{static|static-libgm2:%:replace-outfile(-lm2log libm2log.a%s)}\ - %{static|static-libgm2:%:replace-outfile(-lm2cor libm2cor.a%s)}\ - %{force_cpusubtype_ALL:-arch %(darwin_arch)} \ - %{!force_cpusubtype_ALL:-arch %(darwin_subarch)} "\ + %{static|static-libgm2:%:replace-outfile(-lm2cor libm2cor.a%s)} "\ LINK_SYSROOT_SPEC \ "%{!multiply_defined*:%{shared-libgcc: \ %:version-compare(< 10.5 mmacosx-version-min= -multiply_defined) \ diff --git a/gcc/configure b/gcc/configure index eb57959..4a751d9 100755 --- a/gcc/configure +++ b/gcc/configure @@ -32722,6 +32722,7 @@ if test x"$ld64_flag" = x"yes"; then gcc_cv_ld64_platform_version=0 gcc_cv_ld64_macos_version_min=0 gcc_cv_ld64_demangle=0 + gcc_cv_ld64_no_deduplicate=0 if test "$build" = "$host"; then darwin_try_test=1 @@ -32751,6 +32752,9 @@ $as_echo "$gcc_cv_ld64_major" >&6; } if test "$gcc_cv_ld64_major" -ge 236; then gcc_cv_ld64_export_dynamic=1 fi + if test "$gcc_cv_ld64_major" -ge 262; then + gcc_cv_ld64_no_deduplicate=1 + fi if test "$gcc_cv_ld64_major" -ge 512; then gcc_cv_ld64_platform_version=1 gcc_cv_ld64_macos_version_min=1 @@ -32785,6 +32789,15 @@ $as_echo_n "checking linker for -export_dynamic support... " >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_ld64_export_dynamic" >&5 $as_echo "$gcc_cv_ld64_export_dynamic" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking linker for -no_deduplicate support" >&5 +$as_echo_n "checking linker for -no_deduplicate support... " >&6; } + gcc_cv_ld64_no_deduplicate=1 + if $gcc_cv_ld -no_deduplicate < /dev/null 2>&1 | grep 'unknown option' > /dev/null; then + gcc_cv_ld64_no_deduplicate=0 + fi + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_ld64_no_deduplicate" >&5 +$as_echo "$gcc_cv_ld64_no_deduplicate" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking linker for -platform_version support" >&5 $as_echo_n "checking linker for -platform_version support... " >&6; } gcc_cv_ld64_platform_version=1 @@ -32826,6 +32839,12 @@ _ACEOF cat >>confdefs.h <<_ACEOF +#define LD64_HAS_NO_DEDUPLICATE $gcc_cv_ld64_no_deduplicate +_ACEOF + + + +cat >>confdefs.h <<_ACEOF #define LD64_HAS_PLATFORM_VERSION $gcc_cv_ld64_platform_version _ACEOF diff --git a/gcc/configure.ac b/gcc/configure.ac index ac1f0e9..4532c5c 100644 --- a/gcc/configure.ac +++ b/gcc/configure.ac @@ -6392,6 +6392,7 @@ if test x"$ld64_flag" = x"yes"; then gcc_cv_ld64_platform_version=0 gcc_cv_ld64_macos_version_min=0 gcc_cv_ld64_demangle=0 + gcc_cv_ld64_no_deduplicate=0 if test "$build" = "$host"; then darwin_try_test=1 @@ -6419,6 +6420,9 @@ if test x"$ld64_flag" = x"yes"; then if test "$gcc_cv_ld64_major" -ge 236; then gcc_cv_ld64_export_dynamic=1 fi + if test "$gcc_cv_ld64_major" -ge 262; then + gcc_cv_ld64_no_deduplicate=1 + fi if test "$gcc_cv_ld64_major" -ge 512; then gcc_cv_ld64_platform_version=1 gcc_cv_ld64_macos_version_min=1 @@ -6447,6 +6451,13 @@ if test x"$ld64_flag" = x"yes"; then fi AC_MSG_RESULT($gcc_cv_ld64_export_dynamic) + AC_MSG_CHECKING(linker for -no_deduplicate support) + gcc_cv_ld64_no_deduplicate=1 + if $gcc_cv_ld -no_deduplicate < /dev/null 2>&1 | grep 'unknown option' > /dev/null; then + gcc_cv_ld64_no_deduplicate=0 + fi + AC_MSG_RESULT($gcc_cv_ld64_no_deduplicate) + AC_MSG_CHECKING(linker for -platform_version support) gcc_cv_ld64_platform_version=1 if $gcc_cv_ld -platform_version macos 10.5 0.0 < /dev/null 2>&1 | grep 'unknown option' > /dev/null; then @@ -6473,6 +6484,9 @@ if test x"$ld64_flag" = x"yes"; then AC_DEFINE_UNQUOTED(LD64_HAS_EXPORT_DYNAMIC, $gcc_cv_ld64_export_dynamic, [Define to 1 if ld64 supports '-export_dynamic'.]) + AC_DEFINE_UNQUOTED(LD64_HAS_NO_DEDUPLICATE, $gcc_cv_ld64_no_deduplicate, + [Define to 1 if ld64 supports '-no_deduplicate'.]) + AC_DEFINE_UNQUOTED(LD64_HAS_PLATFORM_VERSION, $gcc_cv_ld64_platform_version, [Define to 1 if ld64 supports '-platform_version'.]) |