]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
testsuite: Add tls_link effective target
authorChristophe Lyon <christophe.lyon@linaro.org>
Thu, 17 Apr 2025 15:55:14 +0000 (15:55 +0000)
committerChristophe Lyon <christophe.lyon@linaro.org>
Mon, 2 Jun 2025 08:03:24 +0000 (08:03 +0000)
Some tests have 'dg-do link' but currently require 'tls' which is a
compile-only check.

In some configurations of arm-none-eabi, the 'tls' effective-target
can be successful although these tests fail to link with
undefined reference to `__aeabi_read_tp'

This patch as a new tls_link effective target which makes sure we can
build an executable.

gcc/testsuite/ChangeLog:

* lib/target-supports.exp (check_effective_target_tls_link): New.
* g++.dg/tls/pr102496-1.C: Require tls_link.
* g++.dg/tls/pr77285-1.C: Likewise.

gcc/ChangeLog:

* doc/sourcebuild.texi (tls_link): Add documentation.

gcc/doc/sourcebuild.texi
gcc/testsuite/g++.dg/tls/pr102496-1.C
gcc/testsuite/g++.dg/tls/pr77285-1.C
gcc/testsuite/lib/target-supports.exp

index 90430028eb8692265fea7933b35d6cdf1624a7ea..6c5586e4b034d91052cf178a525123536428ca56 100644 (file)
@@ -1976,6 +1976,9 @@ at plain @option{-O2}.
 @item tls
 Target supports thread-local storage.
 
+@item tls_link
+Target supports linking TLS executables.
+
 @item tls_native
 Target supports native (rather than emulated) thread-local storage.
 
index 8220e1e663ac5e7b624b51e15eaf3f8cfc92a98c..e015ae95eab57433b7aeea98f1d8ce6f12a9df03 100644 (file)
@@ -1,6 +1,6 @@
 // PR c++/102496
 // { dg-do link { target c++11 } }
-// { dg-require-effective-target tls }
+// { dg-require-effective-target tls_link }
 // { dg-add-options tls }
 // { dg-additional-sources pr102496-2.C }
 
index 7a9341429d7059f5c26df0fa14511999d536b6af..340c88be77bc2e3ad82762adf1f287563e6c1596 100644 (file)
@@ -1,5 +1,5 @@
 // { dg-do link { target c++11 } }
-// { dg-require-effective-target tls }
+// { dg-require-effective-target tls_link }
 // { dg-add-options tls }
 // { dg-additional-sources pr77285-2.C }
 
index 75d723c63275988b0b4644ae3473d7e6a2e72f60..dfffe3adfbdd0a12aefa25730e1ae7fb912c3f3b 100644 (file)
@@ -1098,6 +1098,16 @@ proc check_effective_target_tls {} {
     }]
 }
 
+# Return 1 if we can link using TLS, 0 otherwise.
+
+proc check_effective_target_tls_link {} {
+    return [check_no_compiler_messages tls_link executable {
+       __thread int i;
+       int main (void) { return i; }
+       void g (int j) { i = j; }
+    }]
+}
+
 # Return 1 if *native* thread local storage (TLS) is supported, 0 otherwise.
 
 proc check_effective_target_tls_native {} {