1 # Copyright
(C
) 2013-2014 Free Software Foundation
, Inc.
3 # This
program is free software
; you can redistribute it and
/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation
; either version
3 of the License
, or
6 #
(at your option
) any later version.
8 # This
program is distributed in the hope that it will be useful
,
9 # but WITHOUT
ANY WARRANTY
; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License
for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with GCC
; see the file COPYING3.
If not see
15 #
<http
://www.gnu.org
/licenses
/>.
17 #
Return 1 if compilation with
-fsanitize
=thread is error
-free
for trivial
20 proc check_effective_target_fthread_sanitizer
{} {
21 return [check_no_compiler_messages faddress_sanitizer object
{
23 } "-fPIE -pie -fsanitize=thread"]
27 # tsan_link_flags
-- compute library path and flags to find libtsan.
28 #
(originally from g
++.exp
)
31 proc tsan_link_flags
{ paths
} {
33 global ld_library_path
39 set shlib_ext
[get_shlib_extension
]
41 if { $gccpath
!= "" } {
42 if { [file
exists "${gccpath}/libsanitizer/tsan/.libs/libtsan.a"]
43 ||
[file
exists "${gccpath}/libsanitizer/tsan/.libs/libtsan.${shlib_ext}"] } {
44 append flags
" -B${gccpath}/libsanitizer/tsan/ "
45 append flags
" -L${gccpath}/libsanitizer/tsan/.libs "
46 append ld_library_path
":${gccpath}/libsanitizer/tsan/.libs"
51 set libtsan
[lookfor_file $
{tool_root_dir
} libtsan
]
52 if { $libtsan
!= "" } {
53 append flags
"-L${libtsan} "
54 append ld_library_path
":${libtsan}"
58 set_ld_library_path_env_vars
64 # tsan_init
-- called at the start of each subdir of tests
67 proc tsan_init
{ args } {
68 global TEST_ALWAYS_FLAGS
69 global ALWAYS_CXXFLAGS
71 global tsan_saved_TEST_ALWAYS_FLAGS
72 global dg
-do-what
-default
73 global tsan_saved_dg
-do-what
-default
76 if ![is_remote host
] {
77 if [info exists TOOL_OPTIONS
] {
78 set link_flags
"[tsan_link_flags [get_multilibs ${TOOL_OPTIONS}]]"
80 set link_flags
"[tsan_link_flags [get_multilibs]]"
84 if [info exists dg
-do-what
-default
] {
85 set tsan_saved_dg
-do-what
-default $
{dg
-do-what
-default
}
87 if [info exists TEST_ALWAYS_FLAGS
] {
88 set tsan_saved_TEST_ALWAYS_FLAGS $TEST_ALWAYS_FLAGS
90 if [info exists ALWAYS_CXXFLAGS
] {
91 set ALWAYS_CXXFLAGS
[concat
"{ldflags=$link_flags}" $ALWAYS_CXXFLAGS]
92 set ALWAYS_CXXFLAGS
[concat
"{additional_flags=-fPIE -pie -fsanitize=thread -g}" $ALWAYS_CXXFLAGS]
94 if [info exists TEST_ALWAYS_FLAGS
] {
95 set TEST_ALWAYS_FLAGS
"$link_flags -fPIE -pie -fsanitize=thread -g $TEST_ALWAYS_FLAGS"
97 set TEST_ALWAYS_FLAGS
"$link_flags -fPIE -pie -fsanitize=thread -g"
100 if { $link_flags
!= "" } {
101 global individual_timeout
103 # Lower timeout value in case test does not terminate properly.
104 set individual_timeout
20
105 if [check_runtime_nocache tsan_works
{
106 int main
() { return 0; }
107 } "-fPIE -pie -fsanitize=thread -g"] {
108 set dg
-do-what
-default run
110 set dg
-do-what
-default
compile
112 unset individual_timeout
119 # tsan_finish
-- called at the end of each subdir of tests
122 proc tsan_finish
{ args } {
123 global TEST_ALWAYS_FLAGS
124 global tsan_saved_TEST_ALWAYS_FLAGS
125 global dg
-do-what
-default
126 global tsan_saved_dg
-do-what
-default
128 if [info exists tsan_saved_TEST_ALWAYS_FLAGS
] {
129 set TEST_ALWAYS_FLAGS $tsan_saved_TEST_ALWAYS_FLAGS
131 unset TEST_ALWAYS_FLAGS
133 if [info exists tsan_saved_dg
-do-what
-default
] {
134 set dg
-do-what
-default $
{tsan_saved_dg
-do-what
-default
}
136 unset dg
-do-what
-default