[compiler-rt] 9111635 - [test] Fix asan/scudo -shared-libsan tests with -DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=on
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 15 09:07:51 PDT 2021
Author: Fangrui Song
Date: 2021-09-15T09:07:47-07:00
New Revision: 9111635cb78e4a134364319e2728ff8dd69d36a8
URL: https://github.com/llvm/llvm-project/commit/9111635cb78e4a134364319e2728ff8dd69d36a8
DIFF: https://github.com/llvm/llvm-project/commit/9111635cb78e4a134364319e2728ff8dd69d36a8.diff
LOG: [test] Fix asan/scudo -shared-libsan tests with -DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=on
On x86_64-unknown-linux-gnu, `-m32` tests set LD_LIBRARY_PATH to
`config.compiler_rt_libdir` (`$build/lib/clang/14.0.0/lib/x86_64-unknown-linux-gnu`)
instead of i386-unknown-linux-gnu, so `-shared-libsan` executables
cannot find their runtime (e.g. `TestCases/replaceable_new_delete.cpp`).
Detect -m32 and -m64 in config.target_cflags, and adjust `config.compiler_rt_libdir`.
Reviewed By: vitalybuka
Differential Revision: https://reviews.llvm.org/D108859
Added:
Modified:
compiler-rt/test/lit.common.cfg.py
Removed:
################################################################################
diff --git a/compiler-rt/test/lit.common.cfg.py b/compiler-rt/test/lit.common.cfg.py
index 0b88a930f5b98..0515475c3b3f1 100644
--- a/compiler-rt/test/lit.common.cfg.py
+++ b/compiler-rt/test/lit.common.cfg.py
@@ -55,7 +55,9 @@ def get_path_from_clang(args, allow_failure):
# Try using `-print-runtime-dir`. This is only supported by very new versions of Clang.
# so allow failure here.
- runtime_dir, clang_cmd = get_path_from_clang(['-print-runtime-dir'], allow_failure=True)
+ runtime_dir, clang_cmd = get_path_from_clang(shlex.split(config.target_cflags)
+ + ['-print-runtime-dir'],
+ allow_failure=True)
if runtime_dir:
if os.path.exists(runtime_dir):
return os.path.realpath(runtime_dir)
@@ -123,6 +125,16 @@ def get_path_from_clang(args, allow_failure):
# Add compiler ID to the list of available features.
config.available_features.add(compiler_id)
+# When LLVM_ENABLE_PER_TARGET_RUNTIME_DIR=on, the initial value of
+# config.compiler_rt_libdir (COMPILER_RT_RESOLVED_LIBRARY_OUTPUT_DIR) has the
+# triple as the trailing path component. The value is incorrect for -m32/-m64.
+# Adjust config.compiler_rt accordingly.
+if config.enable_per_target_runtime_dir:
+ if '-m32' in shlex.split(config.target_cflags):
+ config.compiler_rt_libdir = re.sub(r'/x86_64(?=-[^/]+$)', '/i386', config.compiler_rt_libdir)
+ elif '-m64' in shlex.split(config.target_cflags):
+ config.compiler_rt_libdir = re.sub(r'/i386(?=-[^/]+$)', '/x86_64', config.compiler_rt_libdir)
+
# Ask the compiler for the path to libraries it is going to use. If this
# doesn't match config.compiler_rt_libdir then it means we might be testing the
# compiler's own runtime libraries rather than the ones we just built.
More information about the llvm-commits
mailing list