Skip to content

Commit 6349865

Browse files
MaskRaytstellar
authored andcommitted
[CMake] Don't use -fno-semantic-interposition with Clang<=13
Clang 13 has a -fsanitize-coverage -fno-semantic-interposition bug (D117190) which may lead to `relocation R_X86_64_PC32 cannot be used against symbol` linker error in -DLLVM_USE_SANITIZE_COVERAGE=ON build when a shared object is built (e.g. -DLLVM_BUILD_LLVM_DYLIB=on). For simplicity, just disallow Clang 13 entirely. Note: GCC -fPIC performance benefits from -fno-semantic-interposition dramatically. Clang benefits little. Using this option is more for a dogfood purpose to test correctness of this option, because in the wild some important packages like CPython uses this option. Differential Revision: https://reviews.llvm.org/D117183 (cherry picked from commit 1661c8c)
1 parent b3dcd15 commit 6349865

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

llvm/cmake/modules/HandleLLVMOptions.cmake

+3-4
Original file line numberDiff line numberDiff line change
@@ -316,12 +316,11 @@ if( LLVM_ENABLE_PIC )
316316
# Note: GCC<10.3 has a bug on SystemZ.
317317
#
318318
# Note: Clang allows IPO for -fPIC so this optimization is less effective.
319-
# Older Clang may support -fno-semantic-interposition but it used local
320-
# aliases to optimize global variables, which is incompatible with copy
321-
# relocations due to -fno-pic.
319+
# Clang 13 has a bug related to -fsanitize-coverage
320+
# -fno-semantic-interposition (https://reviews.llvm.org/D117183).
322321
if ((CMAKE_COMPILER_IS_GNUCXX AND
323322
NOT (LLVM_NATIVE_ARCH STREQUAL "SystemZ" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 10.3))
324-
OR (CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND CMAKE_CXX_COMPILER_VERSION GREATER_EQUAL 13))
323+
OR (CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND CMAKE_CXX_COMPILER_VERSION GREATER_EQUAL 14))
325324
add_flag_if_supported("-fno-semantic-interposition" FNO_SEMANTIC_INTERPOSITION)
326325
endif()
327326
endif()

0 commit comments

Comments
 (0)