* [committed] libstdc++: Add "futex" and "gthreads" effective-target keywords
@ 2020-11-26 16:25 Jonathan Wakely
2020-11-26 17:10 ` Jonathan Wakely
0 siblings, 1 reply; 3+ messages in thread
From: Jonathan Wakely @ 2020-11-26 16:25 UTC (permalink / raw)
To: libstdc++, gcc-patches
[-- Attachment #1: Type: text/plain, Size: 923 bytes --]
This adds a new "futex" effective-target keyword that can be used to
selectively enable/disable tests based on _GLIBCXX_HAVE_LINUX_FUTEX,
instead of checking for that macro in the code.
It also adds "gthreads" as another one, to make the result of the
dg-require-gthreads directive usable in target selectors.
With these new keywords two tests that are currently only run for linux
can also be run for targets using gthr-single.h (e.g. AIX single-thread
multilib, and targets without a gthreads implementation).
libstdc++-v3/ChangeLog:
* testsuite/18_support/96817.cc: Use new effective-target
keywords to select supported targets more effectively.
* testsuite/30_threads/call_once/66146.cc: Likewise.
* testsuite/lib/libstdc++.exp (check_effective_target_futex):
Define new proc.
(check_effective_target_gthreads): Define new proc to replace
dg-require-gthreads.
Tested powerpc64le-linux. Committed to trunk.
[-- Attachment #2: patch.txt --]
[-- Type: text/plain, Size: 4151 bytes --]
commit 10ee46adf44ae731fc4f9e9fdc25ad60c9d43a9c
Author: Jonathan Wakely <jwakely@redhat.com>
Date: Thu Nov 26 14:13:32 2020
libstdc++: Add "futex" and "gthreads" effective-target keywords
This adds a new "futex" effective-target keyword that can be used to
selectively enable/disable tests based on _GLIBCXX_HAVE_LINUX_FUTEX,
instead of checking for that macro in the code.
It also adds "gthreads" as another one, to make the result of the
dg-require-gthreads directive usable in target selectors.
With these new keywords two tests that are currently only run for linux
can also be run for targets using gthr-single.h (e.g. AIX single-thread
multilib, and targets without a gthreads implementation).
libstdc++-v3/ChangeLog:
* testsuite/18_support/96817.cc: Use new effective-target
keywords to select supported targets more effectively.
* testsuite/30_threads/call_once/66146.cc: Likewise.
* testsuite/lib/libstdc++.exp (check_effective_target_futex):
Define new proc.
(check_effective_target_gthreads): Define new proc to replace
dg-require-gthreads.
diff --git a/libstdc++-v3/testsuite/18_support/96817.cc b/libstdc++-v3/testsuite/18_support/96817.cc
index 4591a7288a57..7f35f0311c34 100644
--- a/libstdc++-v3/testsuite/18_support/96817.cc
+++ b/libstdc++-v3/testsuite/18_support/96817.cc
@@ -15,19 +15,18 @@
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
-// { dg-options "-pthread" }
-// { dg-do run { target *-*-linux-gnu } }
-// { dg-require-effective-target pthread }
+// { dg-do run }
+// { dg-additional-options "-pthread" { target pthread } }
+
+// Static init cannot detect recursion for gthreads targets without futexes
+// (and the futex case can only detect it if __libc_single_threaded==true).
+// { dg-skip-if "unsupported" { gthreads && { ! futex } } }
// PR libstdc++/96817
#include <exception>
#include <stdlib.h>
-#ifndef _GLIBCXX_HAVE_LINUX_FUTEX
-# error "This test requries futex support in the library"
-#endif
-
int init()
{
#if __has_include(<sys/single_threaded.h>)
diff --git a/libstdc++-v3/testsuite/30_threads/call_once/66146.cc b/libstdc++-v3/testsuite/30_threads/call_once/66146.cc
index b1ca0eb6fe8f..a9c99485fa06 100644
--- a/libstdc++-v3/testsuite/30_threads/call_once/66146.cc
+++ b/libstdc++-v3/testsuite/30_threads/call_once/66146.cc
@@ -16,9 +16,11 @@
// <http://www.gnu.org/licenses/>.
// { dg-do run { target c++11 } }
-// { dg-skip-if "" { pthread && { ! *-*-*linux* } } }
// { dg-additional-options "-pthread" { target pthread } }
+// Currently std::call_once is broken for gthreads targets without futexes:
+// { dg-skip-if "see PR 66146" { gthreads && { ! futex } } }
+
#include <mutex>
#include <cstdlib>
#include <testsuite_hooks.h>
diff --git a/libstdc++-v3/testsuite/lib/libstdc++.exp b/libstdc++-v3/testsuite/lib/libstdc++.exp
index fc1e8f242fd1..9ba4ced48830 100644
--- a/libstdc++-v3/testsuite/lib/libstdc++.exp
+++ b/libstdc++-v3/testsuite/lib/libstdc++.exp
@@ -1613,6 +1613,38 @@ proc check_effective_target_tbb-backend { } {
}]
}
+# Return 1 if futex syscall is available
+proc check_effective_target_futex { } {
+ return [check_v3_target_prop_cached et_futex {
+ # Set up and compile a C++ test program that depends on tbb
+ set src futex[pid].cc
+ set exe futex[pid].x
+
+ set f [open $src "w"]
+ puts $f "#include <bits/c++config.h>"
+ puts $f "#if ! _GLIBCXX_HAVE_LINUX_FUTEX"
+ puts $f "# error No futex syscall available"
+ puts $f "#endif"
+ close $f
+
+ set lines [v3_target_compile $src /dev/null preprocess ""]
+ file delete $src
+
+ if [string match "" $lines] {
+ # No error message, preprocessing succeeded.
+ verbose "check_v3_futex: `1'" 2
+ return 1
+ }
+ verbose "check_v3_futex: `0'" 2
+ return 0
+ }]
+}
+
+# Return 1 if futex syscall is available
+proc check_effective_target_gthreads { } {
+ return [check_v3_target_gthreads_timed]
+}
+
set additional_prunes ""
if { [info exists env(GCC_RUNTEST_PARALLELIZE_DIR)] \
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [committed] libstdc++: Add "futex" and "gthreads" effective-target keywords
2020-11-26 16:25 [committed] libstdc++: Add "futex" and "gthreads" effective-target keywords Jonathan Wakely
@ 2020-11-26 17:10 ` Jonathan Wakely
2020-11-26 22:56 ` Jonathan Wakely
0 siblings, 1 reply; 3+ messages in thread
From: Jonathan Wakely @ 2020-11-26 17:10 UTC (permalink / raw)
To: libstdc++, gcc-patches
On 26/11/20 16:25 +0000, Jonathan Wakely wrote:
>+# Return 1 if futex syscall is available
>+proc check_effective_target_gthreads { } {
>+ return [check_v3_target_gthreads_timed]
Oops, I've just noticed the comment is wrong and this calls the wrong
proc. It should be check_v3_target_gthreads not
check_v3_target_gthreads_timed.
I'm in the process of refactoring it anyway so will fix it.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [committed] libstdc++: Add "futex" and "gthreads" effective-target keywords
2020-11-26 17:10 ` Jonathan Wakely
@ 2020-11-26 22:56 ` Jonathan Wakely
0 siblings, 0 replies; 3+ messages in thread
From: Jonathan Wakely @ 2020-11-26 22:56 UTC (permalink / raw)
To: libstdc++, gcc-patches
[-- Attachment #1: Type: text/plain, Size: 552 bytes --]
On 26/11/20 17:10 +0000, Jonathan Wakely wrote:
>On 26/11/20 16:25 +0000, Jonathan Wakely wrote:
>>+# Return 1 if futex syscall is available
>>+proc check_effective_target_gthreads { } {
>>+ return [check_v3_target_gthreads_timed]
>
>Oops, I've just noticed the comment is wrong and this calls the wrong
>proc. It should be check_v3_target_gthreads not
>check_v3_target_gthreads_timed.
>
>I'm in the process of refactoring it anyway so will fix it.
The refactoring is gling slowly, so here the fix.
Tested powerpc64le-linux. Committed to trunk.
[-- Attachment #2: patch.txt --]
[-- Type: text/x-patch, Size: 1451 bytes --]
commit 1a00786414c7ee2f228562fab5c43491a13284c1
Author: Jonathan Wakely <jwakely@redhat.com>
Date: Thu Nov 26 21:41:15 2020
libstc++: Fix typo in new check_effective_target_gthreads proc
Also fix copy&pasted comments referring to the wrong things.
libstdc++-v3/ChangeLog:
* testsuite/lib/libstdc++.exp (check_effective_target_gthreads):
Call check_v3_target_gthreads not check_v3_target_gthreads_timed.
diff --git a/libstdc++-v3/testsuite/lib/libstdc++.exp b/libstdc++-v3/testsuite/lib/libstdc++.exp
index bde8cc0cc91f..b94116ff4ea5 100644
--- a/libstdc++-v3/testsuite/lib/libstdc++.exp
+++ b/libstdc++-v3/testsuite/lib/libstdc++.exp
@@ -1619,7 +1619,8 @@ proc check_effective_target_tbb-backend { } {
# Return 1 if futex syscall is available
proc check_effective_target_futex { } {
return [check_v3_target_prop_cached et_futex {
- # Set up and compile a C++ test program that depends on tbb
+ # Set up and compile a C++ test program that depends on futex
+ # being supported.
set src futex[pid].cc
set exe futex[pid].x
@@ -1643,9 +1644,10 @@ proc check_effective_target_futex { } {
}]
}
-# Return 1 if futex syscall is available
+# Return 1 if C++11 [threads] facilities are available via gthreads,
+# 0 otherwise.
proc check_effective_target_gthreads { } {
- return [check_v3_target_gthreads_timed]
+ return [check_v3_target_gthreads]
}
set additional_prunes ""
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-11-26 22:57 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-26 16:25 [committed] libstdc++: Add "futex" and "gthreads" effective-target keywords Jonathan Wakely
2020-11-26 17:10 ` Jonathan Wakely
2020-11-26 22:56 ` Jonathan Wakely
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).