From patchwork Fri Nov 27 15:54:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Wakely X-Patchwork-Id: 1407312 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gcc.gnu.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=xR6hlbb+; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4CjK2139Tqz9s0b for ; Sat, 28 Nov 2020 02:54:32 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 7DFF6397306B; Fri, 27 Nov 2020 15:54:29 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7DFF6397306B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1606492469; bh=yJSn0LYpUtTB8KRGINM4hQfe1oVkGkyJOrN/mYv9+A0=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=xR6hlbb+BkecOAggaiy2KVrzVmFxEPVgffveWLq7y2/CtQ+zfRHC7QR7MPeSM5jq8 DfN+/V89MzYU2HtrwQ1RJJjm4K9ZlIlbdOSJKqMG/pYPTsk8go7heK/zbW5KJhX/Yo dUi5r2jTxT0Wxhx1QMINhg94WZtv0YImRRRNxoNc= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by sourceware.org (Postfix) with ESMTP id A7B343973053 for ; Fri, 27 Nov 2020 15:54:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org A7B343973053 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-338-CzNsmLiOOzu4KIUVlfjGGg-1; Fri, 27 Nov 2020 10:54:22 -0500 X-MC-Unique: CzNsmLiOOzu4KIUVlfjGGg-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A5EED107AD34; Fri, 27 Nov 2020 15:54:21 +0000 (UTC) Received: from localhost (unknown [10.33.37.15]) by smtp.corp.redhat.com (Postfix) with ESMTP id 29527100164C; Fri, 27 Nov 2020 15:54:20 +0000 (UTC) Date: Fri, 27 Nov 2020 15:54:20 +0000 To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [committed] libstdc++: Refactor dejagnu effective-target checks Message-ID: <20201127155420.GA2303801@redhat.com> MIME-Version: 1.0 X-Clacks-Overhead: GNU Terry Pratchett X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4, 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: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Jonathan Wakely via Gcc-patches From: Jonathan Wakely Reply-To: Jonathan Wakely Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" This introduces two new procs to replace boilerplate in the effective-target checks. libstdc++-v3/ChangeLog: * testsuite/lib/libstdc++.exp (v3_try_preprocess): Define new proc to preprocess a chunk of code. (v3_check_preprocessor_condition): Define new proc to test a preprocessor condition depending on GCC or libstdc++ macros. (check_v3_target_debug_mode, check_v3_target_normal_mode): Use v3_try_preprocess. (check_v3_target_normal_namespace) (check_v3_target_parallel_mode, check_v3_target_cstdint) (check_v3_target_cmath, check_v3_target_atomic_builtins) (check_v3_target_gthreads, check_v3_target_gthreads_timed) (check_v3_target_sleep, check_v3_target_sched_yield) (check_v3_target_string_conversions, check_v3_target_swprintf) (check_v3_target_binary_io, check_v3_target_nprocs): Use v3_check_preprocessor_condition. (check_effective_target_cxx11): Likewise. (check_effective_target_random_device): Likewise. (check_effective_target_tbb-backend): Likewise. (check_effective_target_futex): Likewise. (check_v3_target_little_endian) Call check_effective_target_le. (check_effective_target_atomic-builtins): New proc to define new effective-target keyword. (check_effective_target_gthreads-timed): Likewise. Tested powerpc64le-linux, sparc-solaris2.11, powerpc-aix (with no changes to test results, i.e. the same set are UNSUPPORTED). Committed to trunk. commit e8f83fa4fcf4f7e97046ef6b521b78dcd25c95b7 Author: Jonathan Wakely Date: Fri Nov 27 00:21:52 2020 libstdc++: Refactor dejagnu effective-target checks This introduces two new procs to replace boilerplate in the effective-target checks. libstdc++-v3/ChangeLog: * testsuite/lib/libstdc++.exp (v3_try_preprocess): Define new proc to preprocess a chunk of code. (v3_check_preprocessor_condition): Define new proc to test a preprocessor condition depending on GCC or libstdc++ macros. (check_v3_target_debug_mode, check_v3_target_normal_mode): Use v3_try_preprocess. (check_v3_target_normal_namespace) (check_v3_target_parallel_mode, check_v3_target_cstdint) (check_v3_target_cmath, check_v3_target_atomic_builtins) (check_v3_target_gthreads, check_v3_target_gthreads_timed) (check_v3_target_sleep, check_v3_target_sched_yield) (check_v3_target_string_conversions, check_v3_target_swprintf) (check_v3_target_binary_io, check_v3_target_nprocs): Use v3_check_preprocessor_condition. (check_effective_target_cxx11): Likewise. (check_effective_target_random_device): Likewise. (check_effective_target_tbb-backend): Likewise. (check_effective_target_futex): Likewise. (check_v3_target_little_endian) Call check_effective_target_le. (check_effective_target_atomic-builtins): New proc to define new effective-target keyword. (check_effective_target_gthreads-timed): Likewise. diff --git a/libstdc++-v3/testsuite/lib/libstdc++.exp b/libstdc++-v3/testsuite/lib/libstdc++.exp index b94116ff4ea5..e000dba968f7 100644 --- a/libstdc++-v3/testsuite/lib/libstdc++.exp +++ b/libstdc++-v3/testsuite/lib/libstdc++.exp @@ -945,85 +945,97 @@ proc check_v3_target_namedlocale { args } { }] } +# Returns 1 if the tokens in CODE can be preprocessed successfully using FLAGS, +# returns 0 otherwise. +proc v3_try_preprocess { name code flags } { + global tool + global cxxflags + + # Set up and preprocess a C++ translation unit. + set src $name[pid].cc + + set f [open $src "w"] + puts $f $code + close $f + + set cxxflags_saved $cxxflags + set cxxflags "$flags" + + set lines [v3_target_compile $src /dev/null preprocess ""] + set cxxflags $cxxflags_saved + file delete $src + + if [string match "" $lines] { + verbose "v3_try_preprocess $name: preprocessing passed" 3 + # No error message, preprocessing succeeded. + return 1 + } + verbose "v3_try_preprocess $name: preprocessing failed" 2 + return 0 +} + +# Return 1 if COND evaluates to true in the preprocessor, 0 otherwise. +# The config header is included. +proc v3_check_preprocessor_condition { name cond } { + global cxxflags + global DEFAULT_CXXFLAGS + + set code " + #include + #if ! ($cond) + #error '$cond' is false + #endif + " + set flags "$cxxflags $DEFAULT_CXXFLAGS -Werror" + + return [v3_try_preprocess name $code $flags] +} + +# Return 1 if Debug Mode is active, 0 otherwise. proc check_v3_target_debug_mode { } { + global cxxflags return [check_v3_target_prop_cached et_debug_mode { - global tool - # Set up and preprocess a C++ test program that depends - # on debug mode activated. - set src debug_mode[pid].cc - - set f [open $src "w"] - puts $f "#ifndef _GLIBCXX_DEBUG" - puts $f "# error No debug mode" - 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. - return 1 - } - return 0 + set code " + #if ! defined _GLIBCXX_DEBUG + # error no debug mode + #endif + " + return [v3_try_preprocess debug_mode $code $cxxflags] }] } +# Return 1 if normal mode is active, 0 otherwise. +# i.e. neither Debug Mode nor Parallel Mode is active. proc check_v3_target_normal_mode { } { + global cxxflags return [check_v3_target_prop_cached et_normal_mode { - global tool - # Set up and compile a C++ test program that depends - # on normal mode activated. - set src normal_mode[pid].cc - - set f [open $src "w"] - puts $f "#include " - puts $f "#if defined(_GLIBCXX_DEBUG) || defined(_GLIBCXX_PARALLEL)" - puts $f "# error No normal mode" - puts $f "#endif" - close $f - - set lines [v3_target_compile $src /dev/null preprocess ""] - file delete $src - - if [string match "" $lines] { - # No error message, compilation succeeded. - return 1 - } - return 0 + set code " + #if defined _GLIBCXX_DEBUG + # error debug mode + #endif + #if defined _GLIBCXX_PARALLEL + # error parallel mode + #endif + " + return [v3_try_preprocess normal_mode $code $cxxflags] }] } +# Return 1 if unversioned namespace is in use, 0 otherwise. +# i.e. the library uses namespace std:: not std::__8:: or similar. proc check_v3_target_normal_namespace { } { return [check_v3_target_prop_cached et_normal_namespace { - global tool - # Set up and compile a C++ test program that depends - # on normal std namespace. - set src normal_namespace[pid].cc - - set f [open $src "w"] - puts $f "#include " - puts $f "#if _GLIBCXX_INLINE_VERSION" - puts $f "# error No normal namespace" - puts $f "#endif" - close $f - - set lines [v3_target_compile $src /dev/null preprocess ""] - file delete $src - - if [string match "" $lines] { - # No error message, compilation succeeded. - return 1 - } - return 0 + set cond "!_GLIBCXX_INLINE_VERSION" + return [v3_check_preprocessor_condition normal_namespace $cond] }] } +# Return 1 if the libgomp is being used, 0 otherwise. proc check_v3_target_parallel_mode { } { return [check_v3_target_prop_cached et_parallel_mode { global cxxflags global v3-libgomp - # If 'make check-parallel' is running the test succeeds. + # If 'make check-parallel' is running then the test succeeds. if { ${v3-libgomp} == 1 && [regexp "libgomp" $cxxflags] } { return 1 } @@ -1031,67 +1043,19 @@ proc check_v3_target_parallel_mode { } { }] } +# Return 1 if the C99 stdint facilities are available, 0 otherwise. proc check_v3_target_cstdint { } { return [check_v3_target_prop_cached et_cstdint { - global DEFAULT_CXXFLAGS - global cxxflags - # Set up and preprocess a C++0x test program that depends - # on the C99 stdint facilities to be available. - set src cstdint[pid].cc - - set f [open $src "w"] - puts $f "#include " - puts $f "#ifndef _GLIBCXX_USE_C99_STDINT_TR1" - puts $f "# error No C99 stdint" - puts $f "#endif" - close $f - - set cxxflags_saved $cxxflags - set cxxflags "$cxxflags $DEFAULT_CXXFLAGS -Werror" - - set lines [v3_target_compile $src /dev/null preprocess ""] - set cxxflags $cxxflags_saved - file delete $src - - if [string match "" $lines] { - # No error message, preprocess succeeded. - return 1 - } else { - verbose "check_v3_target_cstdint: compilation failed" 2 - return 0 - } + set cond "defined _GLIBCXX_USE_C99_STDINT_TR1" + return [v3_check_preprocessor_condition cstdint $cond] }] } +# Return 1 if the C99 math facilities are available, 0 otherwise. proc check_v3_target_cmath { } { return [check_v3_target_prop_cached et_c99_math { - global cxxflags - global DEFAULT_CXXFLAGS - # Set up and preprocess a C++0x test program that depends - # on the C99 math facilities to be available. - set src c99_math[pid].cc - - set f [open $src "w"] - puts $f "#include " - puts $f "#ifndef _GLIBCXX_USE_C99_MATH_TR1" - puts $f "# error No C99 math" - puts $f "#endif" - close $f - - set cxxflags_saved $cxxflags - set cxxflags "$cxxflags $DEFAULT_CXXFLAGS -Werror" - - set lines [v3_target_compile $src /dev/null preprocess ""] - set cxxflags $cxxflags_saved - file delete $src - - if [string match "" $lines] { - # No error message, preprocess succeeded. - return 1 - } else { - verbose "check_v3_target_c99_math: compilation failed" 2 - return 0 - } + set cond "defined _GLIBCXX_USE_C99_MATH_TR1" + return [v3_check_preprocessor_condition cmath $cond] }] } @@ -1100,15 +1064,16 @@ proc check_v3_target_thread_fence { } { global cxxflags global DEFAULT_CXXFLAGS - # Set up and preprocess a C++11 test program that depends + # Set up and link a C++11 test program that depends # on the thread fence to be available. set src thread_fence[pid].cc set f [open $src "w"] - puts $f "int main() {" - puts $f "__atomic_thread_fence (__ATOMIC_SEQ_CST);" - puts $f "return 0;" - puts $f "}" + puts $f " + int main() { + __atomic_thread_fence (__ATOMIC_SEQ_CST); + return 0; + }" close $f set cxxflags_saved $cxxflags @@ -1128,309 +1093,106 @@ proc check_v3_target_thread_fence { } { }] } +# Return 1 if atomics_bool and atomic_int are always lock-free, 0 otherwise. proc check_v3_target_atomic_builtins { } { return [check_v3_target_prop_cached et_atomic_builtins { - global cxxflags - global DEFAULT_CXXFLAGS - - # Set up and preprocess a C++11 test program that depends - # on the atomic builtin facilities to be available. - set src atomic_builtins[pid].cc - - set f [open $src "w"] - puts $f "#if __GCC_ATOMIC_BOOL_LOCK_FREE < 2" - puts $f "# error No atomic bool" - puts $f "#endif" - puts $f "#if __GCC_ATOMIC_INT_LOCK_FREE < 2" - puts $f "# error No atomic int" - puts $f "#endif" - close $f - - set cxxflags_saved $cxxflags - set cxxflags "$cxxflags $DEFAULT_CXXFLAGS -Werror -std=gnu++11" - - set lines [v3_target_compile $src /dev/null preprocess ""] - set cxxflags $cxxflags_saved - file delete $src - - if [string match "" $lines] { - # No error message, preprocess succeeded. - return 1 - } else { - verbose "check_v3_target_atomic_builtins: compilation failed" 2 - return 0 - } + set cond "__GCC_ATOMIC_BOOL_LOCK_FREE > 1 && __GCC_ATOMIC_INT_LOCK_FREE > 1" + return [v3_check_preprocessor_condition atomic_builtins $cond] }] } +# Define "atomic-builtins" as an effective-target keyword. +proc check_effective_target_atomic-builtins { } { + return [check_v3_target_atomic_builtins] +} + +# Return 1 if C++11 [threads] facilities are available via gthreads, +# 0 otherwise. proc check_v3_target_gthreads { } { return [check_v3_target_prop_cached et_gthreads { - global cxxflags - global DEFAULT_CXXFLAGS - - # Set up and preprocess a C++0x test program that depends - # on the gthreads facilities to be available. - set src gthreads[pid].cc - - set f [open $src "w"] - puts $f "#include " - puts $f "#ifndef _GLIBCXX_HAS_GTHREADS" - puts $f "# error No gthread" - puts $f "#endif" - close $f - - set cxxflags_saved $cxxflags - set cxxflags "$cxxflags $DEFAULT_CXXFLAGS -Werror" - - set lines [v3_target_compile $src /dev/null preprocess ""] - set cxxflags $cxxflags_saved - file delete $src - - if [string match "" $lines] { - # No error message, preprocessing succeeded. - return 1 - } else { - verbose "check_v3_target_gthreads: compilation failed" 2 - return 0 - } + set cond "defined _GLIBCXX_HAS_GTHREADS" + return [v3_check_preprocessor_condition gthreads $cond] }] } +# Define "gthreads" as an effective-target keyword. +proc check_effective_target_gthreads { } { + return [check_v3_target_gthreads] +} + +# Return 1 if C++11 timed mutexes are available via gthreads, 0 otherwise. proc check_v3_target_gthreads_timed { } { return [check_v3_target_prop_cached et_gthreads_timed { - global cxxflags - global DEFAULT_CXXFLAGS - # Set up and preprocess a C++0x test program that depends - # on the gthreads timed mutex facilities to be available. - set src gthreads_timed[pid].cc - - set f [open $src "w"] - puts $f "#include " - puts $f "#ifndef _GLIBCXX_HAS_GTHREADS" - puts $f "# error No gthread" - puts $f "#endif" - puts $f "#if !_GTHREAD_USE_MUTEX_TIMEDLOCK" - puts $f "# error No gthread timed mutexes" - puts $f "#endif" - close $f - - set cxxflags_saved $cxxflags - set cxxflags "$cxxflags $DEFAULT_CXXFLAGS -Werror" - - set lines [v3_target_compile $src /dev/null preprocess ""] - set cxxflags $cxxflags_saved - file delete $src - - if [string match "" $lines] { - # No error message, preprocessing succeeded. - return 1 + if [check_v3_target_gthreads] { + set cond "defined _GTHREAD_USE_MUTEX_TIMEDLOCK" + return [v3_check_preprocessor_condition gthreads_timed $cond] } else { - verbose "check_v3_target_gthreads_timed: compilation failed" 2 return 0 } }] } +# Define "gthreads-timed" as an effective-target keyword. +proc check_effective_target_gthreads-timed { } { + return [check_v3_target_gthreads_timed] +} + +# Return 1 if either nanosleep or sleep is available, 0 otherwise. proc check_v3_target_sleep { } { return [check_v3_target_prop_cached et_sleep { - global cxxflags - global DEFAULT_CXXFLAGS - # Set up and preprocess a C++11 test program that depends - # on the sleep facilities to be available. - set src sleep[pid].cc - - set f [open $src "w"] - puts $f "#include " - puts $f "#ifndef _GLIBCXX_USE_NANOSLEEP" - puts $f "# ifndef _GLIBCXX_HAVE_SLEEP" - puts $f "# error No nanosleep or sleep" - puts $f "# endif" - puts $f "#endif" - close $f - - set cxxflags_saved $cxxflags - set cxxflags "$cxxflags $DEFAULT_CXXFLAGS -Werror" - - set lines [v3_target_compile $src /dev/null preprocess ""] - set cxxflags $cxxflags_saved - file delete $src - - if [string match "" $lines] { - # No error message, preprocessing succeeded. - return 1 - } else { - verbose "check_v3_target_sleep: compilation failed" 2 - return 0 - } + set cond "defined _GLIBCXX_USE_NANOSLEEP || defined _GLIBCXX_HAVE_SLEEP" + return [v3_check_preprocessor_condition sleep $cond] }] } +# Return 1 if __gthread_yield is available, 0 otherwise. proc check_v3_target_sched_yield { } { return [check_v3_target_prop_cached et_sched_yield { - global cxxflags - global DEFAULT_CXXFLAGS - - # Set up and preprocess a C++0x test program that depends - # on the sched_yield facility to be available. - set src sched_yield[pid].cc - - set f [open $src "w"] - puts $f "#include " - puts $f "#ifndef _GLIBCXX_USE_SCHED_YIELD" - puts $f "# error No sched yield" - puts $f "#endif" - close $f - - set cxxflags_saved $cxxflags - set cxxflags "$cxxflags $DEFAULT_CXXFLAGS -Werror" - - set lines [v3_target_compile $src /dev/null preprocess ""] - set cxxflags $cxxflags_saved - file delete $src - - if [string match "" $lines] { - # No error message, preprocessing succeeded. - return 1 - } else { - verbose "check_v3_target_sched_yield: compilation failed" 2 - return 0 - } + set cond "defined _GLIBCXX_USE_SCHED_YIELD" + return [v3_check_preprocessor_condition sched_yield $cond] }] } +# Return 1 if the [string.conversions] facilities are available, 0 otherwise. proc check_v3_target_string_conversions { } { return [check_v3_target_prop_cached et_string_conversions { - global cxxflags - global DEFAULT_CXXFLAGS - # Set up and preprocess a C++0x test program that depends - # on the string_conversions facilities to be available. - set src string_conversions[pid].cc - - set f [open $src "w"] - puts $f "#include " - puts $f "#if !(_GLIBCXX_USE_C99_STDIO && _GLIBCXX_USE_C99_STDLIB && _GLIBCXX_USE_C99_WCHAR) || defined(_GLIBCXX_HAVE_BROKEN_VSWPRINTF)" - puts $f "# error No string conversions" - puts $f "#endif" - close $f - - set cxxflags_saved $cxxflags - set cxxflags "$cxxflags $DEFAULT_CXXFLAGS -Werror" - - set lines [v3_target_compile $src /dev/null preprocess ""] - set cxxflags $cxxflags_saved - file delete $src - - if [string match "" $lines] { - # No error message, preprocessing succeeded. - return 1 - } else { - verbose "check_v3_target_string_conversions: compilation failed" 2 - return 0 - } + set cond "_GLIBCXX_USE_C99_STDIO && _GLIBCXX_USE_C99_STDLIB" + set cond "$cond && _GLIBCXX_USE_C99_WCHAR" + set cond "$cond && !defined _GLIBCXX_HAVE_BROKEN_VSWPRINTF" + return [v3_check_preprocessor_condition string_conversions $cond] }] } +# Return 1 if a standard-conforming swprintf is available, 0 otherwise. proc check_v3_target_swprintf { } { return [check_v3_target_prop_cached et_swprintf { - global cxxflags - global DEFAULT_CXXFLAGS - # Set up and preprocess a C++0x test program that depends - # on a standard swprintf function to be available. - set src swprintf[pid].cc - - set f [open $src "w"] - puts $f "#include " - puts $f "#if defined(_GLIBCXX_HAVE_BROKEN_VSWPRINTF)" - puts $f "# error No swprintf" - puts $f "#endif" - close $f - - set cxxflags_saved $cxxflags - set cxxflags "$cxxflags $DEFAULT_CXXFLAGS -Werror" - - set lines [v3_target_compile $src /dev/null preprocess ""] - set cxxflags $cxxflags_saved - file delete $src - - if [string match "" $lines] { - # No error message, preprocessing succeeded. - return 1 - } else { - verbose "check_v3_target_swprintf: compilation failed" 2 - return 0 - } + set cond "! defined _GLIBCXX_HAVE_BROKEN_VSWPRINTF" + return [v3_check_preprocessor_condition swprintf $cond] }] } +# Return 1 if text and binary I/O are the same, 0 otherwise. proc check_v3_target_binary_io { } { return [check_v3_target_prop_cached et_binary_io { - global cxxflags - global DEFAULT_CXXFLAGS - # Set up and preprocess a C++0x test program that depends - # on text and binary I/O being the same. - set src binary_io[pid].cc - - set f [open $src "w"] - puts $f "#include " - puts $f "#if defined(_GLIBCXX_HAVE_DOS_BASED_FILESYSTEM)" - puts $f "# error No binary io" - puts $f "#endif" - close $f - - set cxxflags_saved $cxxflags - set cxxflags "$cxxflags $DEFAULT_CXXFLAGS -Werror" - - set lines [v3_target_compile $src /dev/null preprocess ""] - set cxxflags $cxxflags_saved - file delete $src - - if [string match "" $lines] { - # No error message, preprocessing succeeded. - return 1 - } else { - verbose "check_v3_target_binary_io: compilation failed" 2 - return 0 - } + set cond "! defined _GLIBCXX_HAVE_DOS_BASED_FILESYSTEM" + return [v3_check_preprocessor_condition binary_io $cond] }] } +# Return 1 if get_nprocs or pthreads_num_processors_np or a suitable sysconf +# is available, 0 otherwise. proc check_v3_target_nprocs { } { return [check_v3_target_prop_cached et_nprocs { - global cxxflags - global DEFAULT_CXXFLAGS - # Set up and preprocess a C++0x test program that depends - # on either get_nprocs or sysconf to be available. - set src nprocs[pid].cc - - set f [open $src "w"] - puts $f "#include " - puts $f "#if defined(_GLIBCXX_USE_GET_NPROCS)" - puts $f "#elif defined(_GLIBCXX_USE_PTHREADS_NUM_PROCESSORS_NP)" - puts $f "#elif defined(_GLIBCXX_USE_SYSCTL_HW_NCPU)" - puts $f "#elif defined(_GLIBCXX_USE_SC_NPROCESSORS_ONLN)" - puts $f "#elif defined(_GLIBCXX_USE_SC_NPROC_ONLN)" - puts $f "#else" - puts $f "# error hardware_concurrency not implemented" - puts $f "#endif" - close $f - - set cxxflags_saved $cxxflags - set cxxflags "$cxxflags $DEFAULT_CXXFLAGS -Werror" - - set lines [v3_target_compile $src /dev/null preprocess ""] - set cxxflags $cxxflags_saved - file delete $src - - if [string match "" $lines] { - # No error message, preprocess succeeded. - return 1 - } else { - verbose "check_v3_target_nprocs: compilation failed" 2 - return 0 - } + set cond "defined _GLIBCXX_USE_GET_NPROCS" + set cond "$cond || defined _GLIBCXX_USE_PTHREADS_NUM_PROCESSORS_NP" + set cond "$cond || defined _GLIBCXX_USE_SYSCTL_HW_NCPU" + set cond "$cond || defined _GLIBCXX_USE_SC_NPROCESSORS_ONLN" + set cond "$cond || defined _GLIBCXX_USE_SC_NPROC_ONLN" + return [v3_check_preprocessor_condition nprocs $cond] }] } +# Return 1 if linking with -static-libstdc++ works, 0 otherwise. proc check_v3_target_static_libstdcxx { } { return [check_v3_target_prop_cached et_static_libstdcxx { global cxxflags @@ -1466,32 +1228,7 @@ proc check_v3_target_static_libstdcxx { } { } proc check_v3_target_little_endian { } { - return [check_v3_target_prop_cached et_little_endian { - global cxxflags - global DEFAULT_CXXFLAGS - set src little_endian[pid].cc - - set f [open $src "w"] - puts $f "#if __BYTE_ORDER__ != __ORDER_LITTLE_ENDIAN__" - puts $f "# error Not little endian" - puts $f "#endif" - close $f - - set cxxflags_saved $cxxflags - set cxxflags "$cxxflags $DEFAULT_CXXFLAGS -Werror" - - set lines [v3_target_compile $src /dev/null preprocess ""] - set cxxflags $cxxflags_saved - file delete $src - - if [string match "" $lines] { - # No error message, preprocessing succeeded. - return 1 - } else { - verbose "check_v3_target_little_endian: compilation failed" 2 - return 0 - } - }] + return [check_effective_target_le] } # Return 1 if the Filesystem TS is supported, 0 otherwise. @@ -1530,61 +1267,18 @@ proc check_v3_target_filesystem_ts { } { # Any flags provided by RUNTESTFLAGS or a target board will be used here. # Flags added in the test by dg-options or dg-add-options will not be used. proc check_effective_target_cxx11-abi { } { - global cxxflags - - # Set up and preprocess a C++ test program that depends - # on the new ABI being enabled. - set src cxx11_abi[pid].cc - - set f [open $src "w"] - puts $f "#include " - puts $f "#if ! _GLIBCXX_USE_CXX11_ABI" - puts $f "# error old ABI in use" - 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_cxx11_abi: `1'" 2 - return 1 - } - - verbose "check_v3_cxx11_abi: `0'" 2 - return 0 + set cond "_GLIBCXX_USE_CXX11_ABI" + return [v3_check_preprocessor_condition cxx11_abi $cond] } -# Return 1 if std::random_device should be usable using the current flags, 0 otherwise. +# Return 1 if std::random_device should be usable using the current flags, +# 0 otherwise. proc check_effective_target_random_device { } { - global cxxflags - - # Set up and preprocess a C++ test program that depends - # on std::random_device being usable. - set src random_device[pid].cc - - set f [open $src "w"] - puts $f "#include " - puts $f "#if ! _GLIBCXX_USE_RANDOM_TR1" - puts $f "# error No working std::random_device 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_random_device: `1'" 2 - return 1 - } - - verbose "check_v3_random_device: `0'" 2 - return 0 + set cond "_GLIBCXX_USE_RANDOM_TR1" + return [v3_check_preprocessor_condition random_device $cond] } -# Return 1 if tbb parallel backend is available +# Return 1 if tbb parallel backend is available, 0 otherwise. proc check_effective_target_tbb-backend { } { return [check_v3_target_prop_cached et_tbb { # Set up and compile a C++ test program that depends on tbb @@ -1619,37 +1313,11 @@ 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 futex - # being supported. - 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 + set cond "_GLIBCXX_HAVE_LINUX_FUTEX" + return [v3_check_preprocessor_condition futex $cond] }] } -# Return 1 if C++11 [threads] facilities are available via gthreads, -# 0 otherwise. -proc check_effective_target_gthreads { } { - return [check_v3_target_gthreads] -} - set additional_prunes "" if { [info exists env(GCC_RUNTEST_PARALLELIZE_DIR)] \