]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
testsuite,c,c++, Darwin: Allow LTO test link symbols to be undefined. master trunk
authorIain Sandoe <iain@sandoe.co.uk>
Fri, 14 Aug 2026 19:53:19 +0000 (20:53 +0100)
committerIain Sandoe <iain@sandoe.co.uk>
Mon, 17 Aug 2026 21:38:33 +0000 (22:38 +0100)
We had, for some time, a bug in the target supports that meant that
Darwin was not running tests that required -shared.  Since that was
fixed, we have failed a number of LTO tests.  It turns out that this
had nothing to do with LTO - but was a consequence of the tests
producing DSOs with undefined symbols.  Darwin's linker defaults to
requiring all symbols to be defined at link time unless individually
(-U) or generally (-undefined dynamic_lookup) allowed. For one or two
symbols -U is preferable - but most of these cases have several and
dynamic lookup is a shorter fix.  The extra_ld_flags option is not
additive - and so we must override for Darwin placing that second.

gcc/testsuite/ChangeLog:

* g++.dg/lto/pr108772_0.C: Allow undefined symbols on Darwin.
* g++.dg/lto/pr114790_0.C: Likewise.
* g++.dg/lto/pr119614_0.C: Likewise.
* g++.dg/lto/pr85405_0.C: Likewise.
* g++.dg/lto/pr85405b_0.C: Likewise.
* g++.dg/lto/pr85655_0.C: Likewise.
* g++.dg/lto/pr86523-3_0.C: Likewise.
* g++.dg/lto/pr86585_0.C: Likewise.
* g++.dg/lto/pr87906_0.C: Likewise.
* g++.dg/lto/pr88046_0.C: Likewise.
* g++.dg/lto/pr88758_0.C: Likewise.
* g++.dg/lto/pr89330_0.C: Likewise.
* g++.dg/lto/pr91574_0.C: Likewise.
* g++.dg/lto/pr92609_0.C: Likewise.
* g++.dg/lto/pr93166_0.C: Likewise.
* gcc.dg/lto/pr61526_0.c: Likewise.
* g++.dg/lto/pr87295_0.C: Skip on Darwin.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
17 files changed:
gcc/testsuite/g++.dg/lto/pr108772_0.C
gcc/testsuite/g++.dg/lto/pr114790_0.C
gcc/testsuite/g++.dg/lto/pr119614_0.C
gcc/testsuite/g++.dg/lto/pr85405_0.C
gcc/testsuite/g++.dg/lto/pr85405b_0.C
gcc/testsuite/g++.dg/lto/pr85655_0.C
gcc/testsuite/g++.dg/lto/pr86523-3_0.C
gcc/testsuite/g++.dg/lto/pr86585_0.C
gcc/testsuite/g++.dg/lto/pr87295_0.C
gcc/testsuite/g++.dg/lto/pr87906_0.C
gcc/testsuite/g++.dg/lto/pr88046_0.C
gcc/testsuite/g++.dg/lto/pr88758_0.C
gcc/testsuite/g++.dg/lto/pr89330_0.C
gcc/testsuite/g++.dg/lto/pr91574_0.C
gcc/testsuite/g++.dg/lto/pr92609_0.C
gcc/testsuite/g++.dg/lto/pr93166_0.C
gcc/testsuite/gcc.dg/lto/pr61526_0.c

index 81f15a90a3e62336846a1f6c6258a2461602facc..28ed330eabde125db3eda8af0569eb5589a04598 100644 (file)
@@ -3,6 +3,7 @@
 // { dg-require-effective-target fpic }
 // { dg-lto-options { "-flto -fPIC -shared -O1 -fimplicit-constexpr -g1" } }
 // { dg-extra-ld-options "-shared" }
+// { dg-extra-ld-options "-shared -Wl,-undefined,dynamic_lookup" { target *-*-darwin* } }
 
 namespace std {
 struct _Sp_counted_base {
index eed112df3897076d78a8d68095e0891c7010e18e..5c097a74efe9b064c00f772434d93906b3320fdb 100644 (file)
@@ -1,5 +1,6 @@
 // { dg-lto-do link }
 // { dg-lto-options { { -w -flto -g -flto-partition=1to1 -O2 -shared -fPIC -fvisibility=hidden} } }
+// { dg-extra-ld-options "-Wl,-undefined,dynamic_lookup" { target *-*-darwin* } }
 // { dg-require-effective-target fpic }
 // { dg-require-effective-target shared }
 struct APITracerContext {
index 09c07fbf566739f5a4fc7c62d5e273cfa8ec08cf..f51b55fb360a1f8c7219be146bdfb037ad7376c1 100644 (file)
@@ -5,6 +5,7 @@
 // { dg-require-effective-target fpic }
 // { dg-require-effective-target musttail }
 // { dg-extra-ld-options "-shared" }
+// { dg-extra-ld-options "-shared -Wl,-undefined,dynamic_lookup" { target *-*-darwin* } }
 
 struct S {} b;
 char *foo ();
index 09b70fca189ebc44191961b3cf84f617e4b19736..7ace032519f6b202f5a2b8e83bb20092abad0926 100644 (file)
@@ -2,6 +2,7 @@
 // { dg-require-effective-target shared }
 // { dg-require-effective-target fpic }
 // { dg-lto-options {{-fPIC -shared -flto}} }
+// { dg-extra-ld-options "-Wl,-undefined,dynamic_lookup" { target *-*-darwin* } }
 
 class VclReferenceBase {
   int mnRefCnt;
index 201142bc1a3efdb927b8b8af940df25c2e8e1879..114ecd9b3101ae371d58594ccdb3ac4449606ad6 100644 (file)
@@ -2,6 +2,7 @@
 // { dg-require-effective-target shared }
 // { dg-require-effective-target fpic }
 // { dg-lto-options {{-fPIC -shared -flto}} }
+// { dg-extra-ld-options "-Wl,-undefined,dynamic_lookup" { target *-*-darwin* } }
 
 class VclReferenceBase { 
   int mnRefCnt;
index d3bbd8f40363ac05ea5ae0b9652ad3d65ff477f2..52e5e7881d8b3710dfa64020c5b15ea98d9e5094 100644 (file)
@@ -2,6 +2,7 @@
 // { dg-require-effective-target shared }
 // { dg-require-effective-target fpic }
 // { dg-lto-options {{-O2 -fPIC -shared -flto}} }
+// { dg-extra-ld-options "-Wl,-undefined,dynamic_lookup" { target *-*-darwin* } }
 
 int a;
 void b(...);
index 31063b8773a9c20909632b87faadb0eecd087c31..cad36994a0dffe4dd23ddb010d98ed5a928f0991 100644 (file)
@@ -2,6 +2,7 @@
 // { dg-require-effective-target fpic }
 // { dg-require-effective-target shared }
 // { dg-lto-options { { -fPIC -flto -g -shared } } }
+// { dg-extra-ld-options "-Wl,-undefined,dynamic_lookup" { target *-*-darwin* } }
 class a {
     int b;
 };
index 2c3ae9da414d78789616c4346dedf904edb934bb..15c45b5d162ebb1c0248a2d8c384c74e53a0c90d 100644 (file)
@@ -2,6 +2,7 @@
 // { dg-require-effective-target fpic }
 // { dg-require-effective-target shared }
 // { dg-lto-options { { -flto -g -nostdlib -shared -fPIC } } }
+// { dg-extra-ld-options "-Wl,-undefined,dynamic_lookup -lSystem" { target *-*-darwin* } }
 namespace Inkscape {
     class a;
 }
index a063b23d8d41f17bd0ad32d15dfc9b202d3b3fa7..2abf0c315e9da0e9b06b7e13455f62792254b545 100644 (file)
@@ -1,6 +1,6 @@
 // { dg-lto-do assemble }
 // { dg-lto-options { { -flto -ffat-lto-objects -fdebug-types-section -g -std=gnu++17 } } }
-
+// { dg-skip-if "no fdebug-types-section"  { *-*-darwin* } }
 template<typename _Tp, _Tp __v>
 struct integral_constant
 {
index 623c29ca007aed526744c3761da9ad9aa7112e4d..038ba0bbbf8602d9b488d0fddaadb681d239f05a 100644 (file)
@@ -4,6 +4,7 @@
 // { dg-require-effective-target shared }
 // { dg-lto-options { { -O -fPIC -flto } } }
 // { dg-extra-ld-options "-shared -nostdlib" }
+// { dg-extra-ld-options "-shared -nostdlib -Wl,-undefined,dynamic_lookup -lSystem" { target *-*-darwin* } }
 
 namespace com {
 namespace moon {
index 99224b5011f82dc67e203c11078cc83751d3cde3..f1b54958233d72d0ebad67bccd1cdb8bb724d4eb 100644 (file)
@@ -4,6 +4,7 @@
 // { dg-require-effective-target shared }
 // { dg-require-effective-target fpic }
 // { dg-extra-ld-options "-shared -g" }
+// { dg-extra-ld-options "-shared -g -Wl,-undefined,dynamic_lookup" { target *-*-darwin* } }
 
 class a {};
 class b : virtual a {
index eccbf63c358b62674a5bebe8c4275f9c0ab63e33..025ea05ebbdc672cd8ac9383c7093098f1855baf 100644 (file)
@@ -2,6 +2,7 @@
 // { dg-require-effective-target fpic }
 // { dg-require-effective-target shared }
 // { dg-lto-options { { -O3 -fPIC -flto -shared } } }
+// { dg-extra-ld-options "-Wl,-undefined,dynamic_lookup" { target *-*-darwin* } }
 
 void PreEvaluate(void);
 int main() { PreEvaluate(); return 0; }
index 9f06556754af4a5b25f62460c63868c9887b5528..6ab7dc8c5b4210aaf07daf851c0d675f9207f17b 100644 (file)
@@ -2,6 +2,7 @@
 // { dg-lto-options { { -O3 -g -flto -shared -fPIC -Wno-odr } } }
 // { dg-require-effective-target fpic }
 // { dg-require-effective-target shared }
+// { dg-extra-ld-options "-Wl,-undefined,dynamic_lookup" { target *-*-darwin* } }
 
 namespace Inkscape {
 class Anchored {};
index 346a8015c98a2d285f64e14fad4c52561739ced5..70cb2900b7a0a3fd619905be2966b2dd43949b28 100644 (file)
@@ -4,6 +4,7 @@
 // { dg-require-effective-target shared }
 // { dg-require-effective-target fpic }
 // { dg-extra-ld-options "-shared" }
+// { dg-extra-ld-options "-shared -Wl,-undefined,dynamic_lookup" { target *-*-darwin* } }
 
 class A
 {
index 3cce1811d1e00a9ccf659153df17b29b8a8a038f..74e8a12e061e2b1a5587aa8e0b9975632958895f 100644 (file)
@@ -4,6 +4,7 @@
 // { dg-require-effective-target shared }
 // { dg-require-effective-target fpic }
 // { dg-extra-ld-options "-shared" }
+// { dg-extra-ld-options "-shared -Wl,-undefined,dynamic_lookup" { target *-*-darwin* } }
 
 namespace std {
 inline namespace __cxx11 {}
index a83ba6e0400c90c6621c5a3b3c2d1f147810486d..58f97b394970ffe366e12f74933aa6ce1dceb376 100644 (file)
@@ -5,6 +5,7 @@
 // { dg-require-effective-target fpic }
 // { dg-extra-ld-options "-shared" }
 // { dg-require-visibility "" }
+// { dg-extra-ld-options "-shared -Wl,-undefined,dynamic_lookup" { target *-*-darwin* } }
 
 namespace Qt {
 enum DropAction {};
index d3e2c8008dbe5fdc58d0332bc2745803b09ad196..f80d2dab86a630b7d2c42c159cdf1e962f1112e5 100644 (file)
@@ -3,6 +3,7 @@
 /* { dg-lto-do link } */
 /* { dg-lto-options { { -fPIC -flto -flto-partition=1to1 } } } */
 /* { dg-extra-ld-options { -shared } } */
+/* { dg-extra-ld-options "-shared -Wl,-undefined,dynamic_lookup" { target *-*-darwin* } } */
 
 static void *master;
 void *foo () { return master; }