public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Iain D Sandoe <iains@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r11-11389] Darwin: Correct handling of weak crts.
Date: Sun, 28 Apr 2024 14:39:08 +0000 (GMT)	[thread overview]
Message-ID: <20240428143908.7F4F83858D20@sourceware.org> (raw)

https://gcc.gnu.org/g:61d0cd29f9f107bee1d193b75b87d0ebe0766ede

commit r11-11389-g61d0cd29f9f107bee1d193b75b87d0ebe0766ede
Author: Iain Sandoe <iain@sandoe.co.uk>
Date:   Thu Mar 21 14:34:44 2024 +0000

    Darwin: Correct handling of weak crts.
    
    Backport part of 506e74f53a5 from trunk.
    
    We need the weak crts to be considered ahead of GCC target libraries
    (except libgcc_s) to avoid spurious dependencies on otherwise unused
    libs.
    
    gcc/ChangeLog:
    
            * config/darwin.h (LINK_COMMAND_SPEC_A): Handle weak crts
            before other objects. (REAL_LIBGCC_SPEC): Remove weak crts
            from here.  (DARWIN_WEAK_CRTS): New.
    
    Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>

Diff:
---
 gcc/config/darwin.h | 37 ++++++++++++++++++++++---------------
 1 file changed, 22 insertions(+), 15 deletions(-)

diff --git a/gcc/config/darwin.h b/gcc/config/darwin.h
index e2aa6b745d0..1fded756c60 100644
--- a/gcc/config/darwin.h
+++ b/gcc/config/darwin.h
@@ -351,7 +351,9 @@ extern GTY(()) int darwin_ms_struct;
     %{e*} %{r} \
     %{o*}%{!o:-o a.out} \
     %{!r:%{!nostdlib:%{!nostartfiles:%S}}} \
-    %{L*} %(link_libgcc) %o \
+    %{L*} %(link_libgcc) \
+    %{!r:%{!nostdlib:%{!nodefaultlibs: " DARWIN_WEAK_CRTS "}}} \
+    %o \
     %{!r:%{!nostdlib:%{!nodefaultlibs:\
       %{fprofile-arcs|fprofile-generate*|coverage:-lgcov} \
       %{fopenacc|fopenmp|%:gt(%{ftree-parallelize-loops=*:%*} 1): \
@@ -365,15 +367,15 @@ extern GTY(()) int darwin_ms_struct;
       %(link_ssp) \
       %:version-compare(>< 10.6 10.7 mmacosx-version-min= -ld10-uwfef) \
       %(link_gcc_c_sequence) \
-      %{!nodefaultexport:%{dylib|dynamiclib|bundle: \
-	%:version-compare(>= 10.11 asm_macosx_version_min= -U) \
-	%:version-compare(>= 10.11 asm_macosx_version_min= ___emutls_get_address) \
-	%:version-compare(>= 10.11 asm_macosx_version_min= -exported_symbol) \
-	%:version-compare(>= 10.11 asm_macosx_version_min= ___emutls_get_address) \
-	%:version-compare(>= 10.11 asm_macosx_version_min= -U) \
-	%:version-compare(>= 10.11 asm_macosx_version_min= ___emutls_register_common) \
-	%:version-compare(>= 10.11 asm_macosx_version_min= -exported_symbol) \
-	%:version-compare(>= 10.11 asm_macosx_version_min= ___emutls_register_common) \
+      %{!nodefaultexport: \
+	%{%:version-compare(>= 10.11 asm_macosx_version_min= -U): \
+	   ___emutls_get_address -exported_symbol ___emutls_get_address \
+	  -U ___emutls_register_common \
+	  -exported_symbol ___emutls_register_common \
+	  -U ___gcc_nested_func_ptr_created \
+	  -exported_symbol ___gcc_nested_func_ptr_created \
+	  -U ___gcc_nested_func_ptr_deleted \
+	  -exported_symbol ___gcc_nested_func_ptr_deleted \
       }} \
     }}}\
     %{!r:%{!nostdlib:%{!nostartfiles:%E}}} %{T*} %{F*} "\
@@ -500,17 +502,22 @@ extern GTY(()) int darwin_ms_struct;
 #undef REAL_LIBGCC_SPEC
 #define REAL_LIBGCC_SPEC \
 "%{static-libgcc|static:						  \
-    %:version-compare(!> 10.6 mmacosx-version-min= -lgcc_eh)		  \
-    %:version-compare(>= 10.6 mmacosx-version-min= -lemutls_w);		  \
+    %:version-compare(!> 10.6 mmacosx-version-min= -lgcc_eh);		  \
    shared-libgcc|fexceptions|fobjc-exceptions|fgnu-runtime:		  \
     %:version-compare(!> 10.11 mmacosx-version-min= -lgcc_s.1.1)	  \
-    %:version-compare(>= 10.11 mmacosx-version-min= -lemutls_w)		  \
     %:version-compare(!> 10.3.9 mmacosx-version-min= -lgcc_eh)		  \
     %:version-compare(>< 10.3.9 10.5 mmacosx-version-min= -lgcc_s.10.4)   \
-    %:version-compare(>< 10.5 10.6 mmacosx-version-min= -lgcc_s.10.5);	  \
-   : -lemutls_w								  \
+    %:version-compare(>< 10.5 10.6 mmacosx-version-min= -lgcc_s.10.5)	  \
   } -lgcc "
 
+#define DARWIN_WEAK_CRTS \
+"%{static-libgcc|static:						  \
+   %:version-compare(>= 10.6 mmacosx-version-min= -lemutls_w) ; \
+   shared-libgcc|fexceptions|fobjc-exceptions|fgnu-runtime: \
+     %:version-compare(>= 10.11 mmacosx-version-min= -lemutls_w) ; \
+   : -lemutls_w \
+  }"
+
 /* We specify crt0.o as -lcrt0.o so that ld will search the library path.  */
 
 #undef  STARTFILE_SPEC

                 reply	other threads:[~2024-04-28 14:39 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240428143908.7F4F83858D20@sourceware.org \
    --to=iains@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).