[clang] [compiler-rt] Move interceptors for libresolv functions to MSan (PR #119071)
Aaron Puchert via llvm-commits
llvm-commits at lists.llvm.org
Thu Dec 19 07:17:35 PST 2024
aaronpuchert wrote:
With my change reverted, the test lives in `compiler-rt/test/sanitizer_common`, where we get an additional `--sysroot=` argument. This comes from `compiler-rt/test/sanitizer_common/lit.site.cfg.py.in`:
```python
# Tool-specific config options.
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@"
```
In this case configured to `compiler-rt/test/sanitizer_common/msan-x86_64-Linux/lit.site.cfg.py`:
```python
# Tool-specific config options.
config.name_suffix = "msan-x86_64-Linux"
config.tool_name = "msan"
config.target_cflags = "-funwind-tables --sysroot=/home/aaron/chrome-sysroot"
config.target_arch = "x86_64"
```
This comes from `compiler-rt/test/sanitizer_common/CMakeLists.txt`:
```cmake
if(CMAKE_SYSROOT)
list(APPEND SANITIZER_COMMON_TEST_TARGET_CFLAGS "--sysroot=${CMAKE_SYSROOT}")
endif()
```
However, in `compiler-rt/test/msan/lit.site.cfg.py.in`:
```python
# Tool-specific config options.
config.name_suffix = "- at CONFIG_NAME@"
config.target_cflags = "@MSAN_TEST_TARGET_CFLAGS@"
config.target_arch = "@MSAN_TEST_TARGET_ARCH@"
config.use_lld = @MSAN_TEST_USE_LLD@
config.use_thinlto = @MSAN_TEST_USE_THINLTO@
```
Configured to e.g. `compiler-rt/test/msan/X86_64/lit.site.cfg.py`:
```python
# Tool-specific config options.
config.name_suffix = "-X86_64"
config.target_cflags = ""
config.target_arch = "x86_64"
config.use_lld = False
config.use_thinlto = False
```
This comes from `compiler-rt/test/msan/CMakeLists.txt`:
```cmake
get_test_cc_for_arch(${arch} MSAN_TEST_TARGET_CC MSAN_TEST_TARGET_CFLAGS)
```
which in turn goes to `compiler-rt/cmake/config-ix.cmake`:
```cmake
# Returns a compiler and CFLAGS that should be used to run tests for the
# specific architecture. When cross-compiling, this is controled via
# COMPILER_RT_TEST_COMPILER and COMPILER_RT_TEST_COMPILER_CFLAGS.
macro(get_test_cc_for_arch arch cc_out cflags_out)
if (NOT ${ARGC} EQUAL 3)
message(FATAL_ERROR "got too many args. expected 3, got ${ARGC} (namely: ${ARGV})")
endif()
if(ANDROID OR (NOT APPLE AND ${arch} MATCHES "arm|aarch64|riscv32|riscv64"))
# This is only true if we are cross-compiling.
# Build all tests with host compiler and use host tools.
set(${cc_out} ${COMPILER_RT_TEST_COMPILER})
set(${cflags_out} ${COMPILER_RT_TEST_COMPILER_CFLAGS})
else()
get_target_flags_for_arch(${arch} ${cflags_out})
if(APPLE)
list(APPEND ${cflags_out} ${DARWIN_osx_CFLAGS})
endif()
string(REPLACE ";" " " ${cflags_out} "${${cflags_out}}")
endif()
endmacro()
```
@vitalybuka, should we move the sysroot option into this macro? And always interpose both spellings?
https://github.com/llvm/llvm-project/pull/119071
More information about the llvm-commits
mailing list