From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by sourceware.org (Postfix) with ESMTP id A88F7385E83A for ; Thu, 26 Nov 2020 16:25:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org A88F7385E83A Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-455-8ZEn4IayOCu0O9GYU7mvhg-1; Thu, 26 Nov 2020 11:25:07 -0500 X-MC-Unique: 8ZEn4IayOCu0O9GYU7mvhg-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id EF6D9185E4A2; Thu, 26 Nov 2020 16:25:05 +0000 (UTC) Received: from localhost (unknown [10.33.37.15]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9DB601A262; Thu, 26 Nov 2020 16:25:05 +0000 (UTC) Date: Thu, 26 Nov 2020 16:25:04 +0000 From: Jonathan Wakely To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [committed] libstdc++: Add "futex" and "gthreads" effective-target keywords Message-ID: <20201126162504.GA2154347@redhat.com> MIME-Version: 1.0 X-Clacks-Overhead: GNU Terry Pratchett X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: multipart/mixed; boundary="zYM0uCDKw75PZbzx" Content-Disposition: inline X-Spam-Status: No, score=-14.0 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libstdc++@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libstdc++ mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 26 Nov 2020 16:25:11 -0000 --zYM0uCDKw75PZbzx Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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. --zYM0uCDKw75PZbzx Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="patch.txt" commit 10ee46adf44ae731fc4f9e9fdc25ad60c9d43a9c Author: Jonathan Wakely 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 // . -// { 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 #include -#ifndef _GLIBCXX_HAVE_LINUX_FUTEX -# error "This test requries futex support in the library" -#endif - int init() { #if __has_include() 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 @@ // . // { 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 #include #include 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 " + 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)] \ --zYM0uCDKw75PZbzx--