[sanitizer-common] Force pickup of llvm-symbolizer from new binaries.
authorMitch Phillips <31459023+hctim@users.noreply.github.com>
Wed, 16 Dec 2020 14:36:22 +0000 (06:36 -0800)
committerMitch Phillips <31459023+hctim@users.noreply.github.com>
Wed, 16 Dec 2020 14:36:26 +0000 (06:36 -0800)
It's possible currently that the sanitizer runtimes when testing grab
the path to the symbolizer through *SAN_SYMBOLIZER_PATH=...

This can be polluted by things like Android's setup script. This patch
forces external_symbolizer_path=$new_build_out_dir/llvm-symbolizer when
%env_tool_options is used.

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D93352

compiler-rt/test/sanitizer_common/lit.common.cfg.py
compiler-rt/test/sanitizer_common/lit.site.cfg.py.in

index b4f0670f99594da30004fcfff66d7c4bcd55be6c..f7c526b6b37bb73340ca72a8622b612e349337cf 100644 (file)
@@ -43,6 +43,14 @@ elif config.android:
   # which does not work for abort()-terminated programs.
   default_tool_options += ['abort_on_error=0']
 
+# If the user has a poisoned *SAN_SYMBOLIZER_PATH (like what's setup by
+# build/envsetup.sh on Android), then they can end up with an out-of-date
+# symbolizer for the tests. Ensure they get the one from the recent build tree.
+symbolizer_path="''"
+if len(config.binary_path):
+  symbolizer_path = os.path.join(config.binary_path, "llvm-symbolizer")
+default_tool_options += ['external_symbolizer_path=' + symbolizer_path]
+
 default_tool_options_str = ':'.join(default_tool_options)
 if default_tool_options_str:
   config.environment[tool_options] = default_tool_options_str
index 38f5ca158463115031215a0261262b787ef524b4..3ff7c44aeab4542665a81c108a2e5d09e9615855 100644 (file)
@@ -5,6 +5,7 @@ config.name_suffix = "@CONFIG_NAME@"
 config.tool_name = "@SANITIZER_COMMON_LIT_TEST_MODE@"
 config.target_cflags = "@SANITIZER_COMMON_TEST_TARGET_CFLAGS@"
 config.target_arch = "@SANITIZER_COMMON_TEST_TARGET_ARCH@"
+config.binary_path = "@CMAKE_RUNTIME_OUTPUT_DIRECTORY@"
 
 # Load common config for all compiler-rt lit tests.
 lit_config.load_config(config, "@COMPILER_RT_BINARY_DIR@/test/lit.common.configured")