+2014-10-02 Andrew Pinski <apinski@cavium.com>
+ Max Ostapenko <m.ostapenko@partner.samsung.com>
+
+ * lib/ubsan-dg.exp
+ (check_effective_target_fsanitize_address): New function.
+ (ubsan_init): Save off ALWAYS_CXXFLAGS.
+ (ubsan_finish): Restore ALWAYS_CXXFLAGS correctly.
+ * lib/asan-dg.exp
+ (check_effective_target_faddress_sanitizer): Rename to ...
+ (check_effective_target_fsanitize_address): ... this. Change to creating
+ an executable.
+ (asan_init): Save off ALWAYS_CXXFLAGS.
+ (asan_finish): Restore ALWAYS_CXXFLAGS correctly.
+ * lib/tsan-dg.exp
+ (check_effective_target_fthread_sanitizer): Rename to ...
+ (check_effective_target_fsanitize_thread): ... this. Change to creating
+ an executable.
+ (tsan_init): Save off ALWAYS_CXXFLAGS.
+ (tsan_finish): Restore ALWAYS_CXXFLAGS correctly. Set dg-do-what-default
+ to run as a default behaviour.
+ * gcc.dg/ubsan/ubsan.exp: Don't check the return value of ubsan_init.
+ Check check_effective_target_fsanitize_undefined before running the
+ tests.
+ * g++.dg/ubsan/ubsan.exp: Likewise.
+ * gcc.dg/asan/asan.exp: Don't check the return value of asan_init.
+ check_effective_target_fsanitize_address too early.
+ Check check_effective_target_fsanitize_address before running the tests.
+ * g++.dg/asan/asan.exp: Likewise.
+ * gcc.dg/tsan/tsan.exp: Don't check the return value of tsan_init.
+ check_effective_target_fsanitize_thread too early.
+ Check check_effective_target_fsanitize_thread before running the tests.
+ * g++.dg/tsan/tsan.exp: Likewise.
+
2014-10-01 Segher Boessenkool <segher@kernel.crashing.org>
* gcc.dg/combine-clobber.c: New.
load_lib g++-dg.exp
load_lib asan-dg.exp
-if ![check_effective_target_faddress_sanitizer] {
- return
-}
-
# Initialize `dg'.
dg-init
-if [asan_init] {
+asan_init
# Main loop.
-gcc-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.C $srcdir/c-c++-common/asan/*.c]] "" ""
-
+if [check_effective_target_fsanitize_address] {
+ gcc-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.C $srcdir/c-c++-common/asan/*.c]] "" ""
}
# All done.
load_lib tsan-dg.exp
load_lib torture-options.exp
-if ![check_effective_target_fthread_sanitizer] {
- return
-}
-
# Initialize `dg'.
dg-init
torture-init
{ -O0 } \
{ -O2 } ]
-if [tsan_init] {
+tsan_init
# Main loop.
-gcc-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.C $srcdir/c-c++-common/tsan/*.c]] "" ""
-
+if [check_effective_target_fsanitize_thread] {
+ gcc-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.C $srcdir/c-c++-common/tsan/*.c]] "" ""
}
# All done.
# Initialize `dg'.
dg-init
-if [ubsan_init] {
+ubsan_init
# Main loop.
-gcc-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.C $srcdir/c-c++-common/ubsan/*.c]] "" ""
-
+if [check_effective_target_fsanitize_undefined] {
+ gcc-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.C $srcdir/c-c++-common/ubsan/*.c]] "" ""
}
# All done.
load_lib gcc-dg.exp
load_lib asan-dg.exp
-if ![check_effective_target_faddress_sanitizer] {
- return
-}
-
# Initialize `dg'.
dg-init
-if [asan_init] {
+asan_init
# Main loop.
-gcc-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.c $srcdir/c-c++-common/asan/*.c]] "" ""
-
+if [check_effective_target_fsanitize_address] {
+ gcc-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.c $srcdir/c-c++-common/asan/*.c]] "" ""
}
# All done.
load_lib tsan-dg.exp
load_lib torture-options.exp
-if ![check_effective_target_fthread_sanitizer] {
- return
-}
-
# Initialize `dg'.
dg-init
torture-init
{ -O0 } \
{ -O2 } ]
-if [tsan_init] {
+tsan_init
# Main loop.
-gcc-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.c $srcdir/c-c++-common/tsan/*.c]] "" ""
-
+if [check_effective_target_fsanitize_thread] {
+ gcc-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.c $srcdir/c-c++-common/tsan/*.c]] "" ""
}
# All done.
# Initialize `dg'.
dg-init
-if [ubsan_init] {
+ubsan_init
# Main loop.
-gcc-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.c $srcdir/c-c++-common/ubsan/*.c]] "" ""
-
+if [check_effective_target_fsanitize_undefined] {
+ gcc-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.c $srcdir/c-c++-common/ubsan/*.c]] "" ""
}
# All done.
# Return 1 if compilation with -fsanitize=address is error-free for trivial
# code, 0 otherwise.
-proc check_effective_target_faddress_sanitizer {} {
- return [check_no_compiler_messages faddress_sanitizer object {
- void foo (void) { }
+proc check_effective_target_fsanitize_address {} {
+ return [check_no_compiler_messages fsanitize_address executable {
+ int main (void) { return 0; }
} "-fsanitize=address"]
}
global ALWAYS_CXXFLAGS
global TOOL_OPTIONS
global asan_saved_TEST_ALWAYS_FLAGS
+ global asan_saved_ALWAYS_CXXFLAGS
set link_flags ""
if ![is_remote host] {
set asan_saved_TEST_ALWAYS_FLAGS $TEST_ALWAYS_FLAGS
}
if [info exists ALWAYS_CXXFLAGS] {
+ set asan_saved_ALWAYS_CXXFLAGS $ALWAYS_CXXFLAGS
set ALWAYS_CXXFLAGS [concat "{ldflags=$link_flags}" $ALWAYS_CXXFLAGS]
set ALWAYS_CXXFLAGS [concat "{additional_flags=-fsanitize=address -g $include_flags}" $ALWAYS_CXXFLAGS]
} else {
set TEST_ALWAYS_FLAGS "$link_flags -fsanitize=address -g $include_flags"
}
}
- if { $link_flags != "" } {
- return 1
- }
- return 0
}
#
proc asan_finish { args } {
global TEST_ALWAYS_FLAGS
global asan_saved_TEST_ALWAYS_FLAGS
+ global asan_saved_ALWAYS_CXXFLAGS
- if [info exists asan_saved_TEST_ALWAYS_FLAGS] {
- set TEST_ALWAYS_FLAGS $asan_saved_TEST_ALWAYS_FLAGS
+ if [info exists asan_saved_ALWAYS_CXXFLAGS ] {
+ set ALWAYS_CXXFLAGS $asan_saved_ALWAYS_CXXFLAGS
} else {
- unset TEST_ALWAYS_FLAGS
+ if [info exists asan_saved_TEST_ALWAYS_FLAGS] {
+ set TEST_ALWAYS_FLAGS $asan_saved_TEST_ALWAYS_FLAGS
+ } else {
+ unset TEST_ALWAYS_FLAGS
+ }
}
+ restore_ld_library_path_env_vars
}
# Symbolize lines like
# Return 1 if compilation with -fsanitize=thread is error-free for trivial
# code, 0 otherwise.
-proc check_effective_target_fthread_sanitizer {} {
- return [check_no_compiler_messages faddress_sanitizer object {
- void foo (void) { }
+proc check_effective_target_fsanitize_thread {} {
+ return [check_no_compiler_messages fanitize_thread executable {
+ int main (void) { return 0; }
} "-fPIE -pie -fsanitize=thread"]
}
global ALWAYS_CXXFLAGS
global TOOL_OPTIONS
global tsan_saved_TEST_ALWAYS_FLAGS
+ global tsan_saved_ALWAYS_CXXFLAGS
global dg-do-what-default
global tsan_saved_dg-do-what-default
set tsan_saved_TEST_ALWAYS_FLAGS $TEST_ALWAYS_FLAGS
}
if [info exists ALWAYS_CXXFLAGS] {
+ set tsan_saved_ALWAYS_CXXFLAGS $ALWAYS_CXXFLAGS
set ALWAYS_CXXFLAGS [concat "{ldflags=$link_flags}" $ALWAYS_CXXFLAGS]
set ALWAYS_CXXFLAGS [concat "{additional_flags=-fPIE -pie -fsanitize=thread -g}" $ALWAYS_CXXFLAGS]
} else {
set TEST_ALWAYS_FLAGS "$link_flags -fPIE -pie -fsanitize=thread -g"
}
}
+
+ set dg-do-what-default run
if { $link_flags != "" } {
global individual_timeout
set dg-do-what-default compile
}
unset individual_timeout
- return 1
}
- return 0
}
#
proc tsan_finish { args } {
global TEST_ALWAYS_FLAGS
global tsan_saved_TEST_ALWAYS_FLAGS
+ global tsan_saved_ALWAYS_CXXFLAGS
global dg-do-what-default
global tsan_saved_dg-do-what-default
- if [info exists tsan_saved_TEST_ALWAYS_FLAGS] {
- set TEST_ALWAYS_FLAGS $tsan_saved_TEST_ALWAYS_FLAGS
+ if [info exists tsan_saved_ALWAYS_CXXFLAGS ] {
+ set ALWAYS_CXXFLAGS $tsan_saved_ALWAYS_CXXFLAGS
} else {
- unset TEST_ALWAYS_FLAGS
+ if [info exists tsan_saved_TEST_ALWAYS_FLAGS] {
+ set TEST_ALWAYS_FLAGS $tsan_saved_TEST_ALWAYS_FLAGS
+ } else {
+ unset TEST_ALWAYS_FLAGS
+ }
}
+
if [info exists tsan_saved_dg-do-what-default] {
set dg-do-what-default ${tsan_saved_dg-do-what-default}
} else {
unset dg-do-what-default
}
+ restore_ld_library_path_env_vars
}
# along with GCC; see the file COPYING3. If not see
# <http://www.gnu.org/licenses/>.
+# Return 1 if compilation with -fsanitize=undefined is error-free for trivial
+# code, 0 otherwise.
+
+proc check_effective_target_fsanitize_undefined {} {
+ return [check_no_compiler_messages fsanitize_undefined executable {
+ int main (void) { return 0; }
+ } "-fsanitize=undefined"]
+}
+
#
# ubsan_link_flags -- compute library path and flags to find libubsan.
# (originally from g++.exp)
global ALWAYS_CXXFLAGS
global TOOL_OPTIONS
global ubsan_saved_TEST_ALWAYS_FLAGS
+ global ubsan_saved_ALWAYS_CXXFLAGS
set link_flags ""
if ![is_remote host] {
set ubsan_saved_TEST_ALWAYS_FLAGS $TEST_ALWAYS_FLAGS
}
if [info exists ALWAYS_CXXFLAGS] {
+ set ubsan_saved_ALWAYS_CXXFLAGS $ALWAYS_CXXFLAGS
set ALWAYS_CXXFLAGS [concat "{ldflags=$link_flags}" $ALWAYS_CXXFLAGS]
} else {
if [info exists TEST_ALWAYS_FLAGS] {
set TEST_ALWAYS_FLAGS "$link_flags"
}
}
- if { $link_flags != "" } {
- return 1
- }
- return 0
}
#
proc ubsan_finish { args } {
global TEST_ALWAYS_FLAGS
global ubsan_saved_TEST_ALWAYS_FLAGS
+ global ubsan_saved_ALWAYS_CXXFLAGS
- if [info exists ubsan_saved_TEST_ALWAYS_FLAGS] {
- set TEST_ALWAYS_FLAGS $ubsan_saved_TEST_ALWAYS_FLAGS
+ if [info exists ubsan_saved_ALWAYS_CXXFLAGS ] {
+ set ALWAYS_CXXFLAGS $ubsan_saved_ALWAYS_CXXFLAGS
} else {
- unset TEST_ALWAYS_FLAGS
+ if [info exists ubsan_saved_TEST_ALWAYS_FLAGS] {
+ set TEST_ALWAYS_FLAGS $ubsan_saved_TEST_ALWAYS_FLAGS
+ } else {
+ unset TEST_ALWAYS_FLAGS
+ }
}
+ restore_ld_library_path_env_vars
}