]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
testsuite: Fix weak_undefined handling on Darwin
authorRainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
Tue, 28 Mar 2023 08:40:05 +0000 (10:40 +0200)
committerIain Sandoe <iain@sandoe.co.uk>
Mon, 22 Apr 2024 13:10:38 +0000 (14:10 +0100)
The patch that introduced the weak_undefined effective-target keyword
and corresponding dg-add-options support

commit 378ec7b87a5265dbe2d489c245fac98ef37fa638
Author: Alexandre Oliva <oliva@adacore.com>
Date:   Thu Mar 23 00:45:05 2023 -0300

    [testsuite] test for weak_undefined support and add options

badly broke the affected tests on macOS like so:

ERROR: gcc.dg/addr_equal-1.c: unknown dg option: 89 for " dg-add-options 5 weak_undefined "
ERROR: gcc.dg/addr_equal-1.c: unknown dg option: 89 for " dg-add-options 5 weak_undefined "

add_options_for_weak_undefined tries to call an non-existant proc "89".
Even after fixing this by escaping the brackets, two tests still failed to
link since they lacked the corresponding calls do dg-add-options
weak_undefined.

Tested on x86_64-apple-darwin20.6.0 and i386-pc-solaris2.11.

2023-03-27  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

gcc/testsuite:
* lib/target-supports.exp (add_options_for_weak_undefined): Escape
brackets.
* gcc.dg/visibility-22.c: Add weak_undefined options.

(cherry picked from commit 8443f42f05f9026dadad1236b9e44ec294c70337)

gcc/testsuite/gcc.dg/visibility-22.c
gcc/testsuite/lib/target-supports.exp

index e2b78d1c7fdedb8e91811b9b370089f4711e4e96..9123b350b2e4b00050e7b5a5f0233a3c84edbc45 100644 (file)
@@ -3,6 +3,7 @@
 /* { dg-require-visibility "" } */
 /* { dg-require-effective-target weak_undefined } */
 /* { dg-options "-O2 -fPIC" { target fpic } } */
+/* { dg-add-options weak_undefined } */
 
 extern void foo () __attribute__((weak,visibility("hidden")));
 int
index a09606e449701749401155124b6eb8f0309be600..63a5f5579be6a95668fe2de32f875bbdd0749cfc 100644 (file)
@@ -348,6 +348,18 @@ proc check_weak_available { } {
     }
 }
 
+# return options to add to enable weak undefined symbols.
+
+proc add_options_for_weak_undefined { flags } {
+    if { [istarget *-*-darwin*] } {
+       lappend flags "-Wl,-undefined,dynamic_lookup"
+       if { [istarget *-*-darwin\[89\]*] } {
+           lappend flags "-Wl,-flat_namespace"
+       }
+    }
+    return $flags
+}
+
 # return 1 if weak undefined symbols are supported.
 
 proc check_effective_target_weak_undefined { } {