public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [pushed] testsuite, Darwin: Allow for undefined symbols in shared test.
@ 2024-02-02 15:49 Iain Sandoe
  0 siblings, 0 replies; only message in thread
From: Iain Sandoe @ 2024-02-02 15:49 UTC (permalink / raw)
  To: gcc-patches

tested on i686, x86_64 Darwin, x86_64, aarch64 linux, pushed to trunk,
thanks,
Iain

--- 8< ---

Darwin's linker defaults to error on undefined (which makes it look as
if we do not support shared, leading to tests being marked incorrectly
as unsupported).

This fixes the issue by allowing the symbols used in the target
supports test to be undefined.

gcc/testsuite/ChangeLog:

	* lib/target-supports.exp (check_effective_target_shared):
	Allow the external symbols referenced in the test to be undefined.
---
 gcc/testsuite/lib/target-supports.exp | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp
index 8aefb320d8c..f66dcaac7b8 100644
--- a/gcc/testsuite/lib/target-supports.exp
+++ b/gcc/testsuite/lib/target-supports.exp
@@ -1385,6 +1385,13 @@ proc check_effective_target_aarch64_tlsle32 { } {
 # emitted, 0 otherwise.
 
 proc check_effective_target_shared { } {
+    # Darwin's linker defaults to error on undefined (which makes it look as
+    # if we do not support shared) but we can tell it to allow the symbols used
+    # here to be undefined.
+    set extra_flags ""
+    if { [istarget *-*-darwin\[912\]*] } {
+      set extra_flags "-Wl,-U,_foo,-U,_bar"
+    }
     # Note that M68K has a multilib that supports -fpic but not
     # -fPIC, so we need to check both.  We test with a program that
     # requires GOT references, and with a libc symbol that would
@@ -1397,7 +1404,7 @@ proc check_effective_target_shared { } {
 	char *baz (void) {
 	    return foo () + (char*) malloc (bar);
 	}
-    } "-shared -fpic"]
+    } "-shared -fpic $extra_flags"]
 }
 
 # Return 1 if -pie, -fpie and -fPIE are supported, 0 otherwise.
-- 
2.39.2 (Apple Git-143)


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2024-02-02 15:49 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-02 15:49 [pushed] testsuite, Darwin: Allow for undefined symbols in shared test Iain Sandoe

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