Hello! Attached patch improves detection of working -fsanitize=thread option. Check for working -fsanitize=thread option timeouts with older glibcs, so tsan_init detects this case and sets default compile flags to compile.
Recently Eric changed check_effective_target_fsanitize_thread to a runtime test, and we *again* unnecessarily waste 5 minutes of test time here, waiting for a test to timeout. Attached patch moves the detection to check_effective_target_fsanitize_thread function. Now, the function first checks if the compiler is able to create executable (and exits early if not) and later in the function sets what to do by default, depending on the outcome of the runtime test. BTW: The dg-do-what-default link was chosen to avoid the testsuite error due to the usage of additional-sources in some testcases). Also, we don't need additional compile flags for check_no_compiler_messages and check_runtime since TEST_ALWAYS_FLAG is always set. 2016-02-03 Uros Bizjak <ubiz...@gmail.com> * lib/tsan-dg.exp (tsan_init): Move check if tsan executable works from here ... (check_effective_target_fsanitize_thread): ... to here. Do not specify additional compile flags for the test source. * lib/asan-dg.exp (check_effective_target_fsanitize_address): Do not specify additional compile flags for the test source. Patch was tested on x86_64-linux-gnu (CentOS 5.11 and Fedora 23). OK for mainline? Uros.
diff --git a/gcc/testsuite/lib/asan-dg.exp b/gcc/testsuite/lib/asan-dg.exp index 994160e..a1198c0 100644 --- a/gcc/testsuite/lib/asan-dg.exp +++ b/gcc/testsuite/lib/asan-dg.exp @@ -20,7 +20,7 @@ proc check_effective_target_fsanitize_address {} { return [check_no_compiler_messages fsanitize_address executable { int main (void) { return 0; } - } "-fsanitize=address"] + }] } proc asan_include_flags {} { diff --git a/gcc/testsuite/lib/tsan-dg.exp b/gcc/testsuite/lib/tsan-dg.exp index eb1f3a9..5745fe7 100644 --- a/gcc/testsuite/lib/tsan-dg.exp +++ b/gcc/testsuite/lib/tsan-dg.exp @@ -15,12 +15,30 @@ # <http://www.gnu.org/licenses/>. # Return 1 if compilation with -fsanitize=thread is error-free for trivial -# code, 0 otherwise. +# code, 0 otherwise. Also set what to do by default here. proc check_effective_target_fsanitize_thread {} { - return [check_runtime fsanitize_thread { + global individual_timeout + global dg-do-what-default + + if ![check_no_compiler_messages fsanitize_thread executable { int main (void) { return 0; } - } "-fsanitize=thread"] + }] { + return 0 + } + + # Lower timeout value in case test does not terminate properly. + set individual_timeout 20 + if [check_runtime_nocache tsan_works { + int main () { return 0; } + }] { + set dg-do-what-default run + } else { + set dg-do-what-default link + } + unset individual_timeout + + return 1 } # @@ -101,22 +119,6 @@ proc tsan_init { args } { set TEST_ALWAYS_FLAGS "$link_flags -fsanitize=thread -g" } } - - set dg-do-what-default run - if { $link_flags != "" } { - global individual_timeout - - # Lower timeout value in case test does not terminate properly. - set individual_timeout 20 - if [check_runtime_nocache tsan_works { - int main () { return 0; } - } "-fsanitize=thread -g"] { - set dg-do-what-default run - } else { - set dg-do-what-default compile - } - unset individual_timeout - } } #