diff --git a/compiler-rt/lib/asan/asan_flags.h b/compiler-rt/lib/asan/asan_flags.h index 2d5249a1a138..43aa3a334d20 100644 --- a/compiler-rt/lib/asan/asan_flags.h +++ b/compiler-rt/lib/asan/asan_flags.h @@ -25,7 +25,7 @@ extern "C" { #if !defined(_WIN32) // We do not need to redefine the defaults right now on Windows. - char *__asan_default_options SANITIZER_WEAK_ATTRIBUTE; + const char *__asan_default_options() SANITIZER_WEAK_ATTRIBUTE; #endif } @@ -89,6 +89,7 @@ struct Flags { // to dump 16T+ core. bool disable_core; }; + Flags *flags(); void InitializeFlags(Flags *f, const char *env); diff --git a/compiler-rt/lib/asan/asan_rtl.cc b/compiler-rt/lib/asan/asan_rtl.cc index 70e4b5715ecc..2f15445cc0c9 100644 --- a/compiler-rt/lib/asan/asan_rtl.cc +++ b/compiler-rt/lib/asan/asan_rtl.cc @@ -128,10 +128,10 @@ void InitializeFlags(Flags *f, const char *env) { // Override from user-specified string. #if !defined(_WIN32) if (__asan_default_options) { - ParseFlagsFromString(f, __asan_default_options); + ParseFlagsFromString(f, __asan_default_options()); if (flags()->verbosity) { Report("Using the defaults from __asan_default_options: %s\n", - __asan_default_options); + __asan_default_options()); } } #endif diff --git a/compiler-rt/lib/asan/output_tests/default_options.cc b/compiler-rt/lib/asan/output_tests/default_options.cc new file mode 100644 index 000000000000..d6c70291e6ff --- /dev/null +++ b/compiler-rt/lib/asan/output_tests/default_options.cc @@ -0,0 +1,12 @@ +const char *kAsanDefaultOptions="verbosity=1 foo=bar"; + +extern "C" +__attribute__((no_address_safety_analysis)) +const char *__asan_default_options() { + return kAsanDefaultOptions; +} + +int main() { + // Check-Common: foo=bar + return 0; +} diff --git a/compiler-rt/lib/asan/output_tests/test_output.sh b/compiler-rt/lib/asan/output_tests/test_output.sh index 216760da1b17..6510043396e4 100755 --- a/compiler-rt/lib/asan/output_tests/test_output.sh +++ b/compiler-rt/lib/asan/output_tests/test_output.sh @@ -39,6 +39,8 @@ check_program a.out $C_TEST.c CHECKSLEEP export ASAN_OPTIONS="" rm ./a.out +# FIXME: some tests do not need to be ran for all the combinations of arch +# and optimization mode. for t in *.cc; do for b in 32 64; do for O in 0 1 2 3; do