Skip to content

Commit 099d0ec

Browse files
committed
Link sanitizers with libgcc on Linux, allow undefined symbols
1 parent 738384d commit 099d0ec

File tree

1 file changed

+7
-3
lines changed
  • utils/swift_build_support/swift_build_support/products

1 file changed

+7
-3
lines changed

utils/swift_build_support/swift_build_support/products/llvm.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,13 @@ def build(self, host_target):
291291
llvm_cmake_options.define('LLVM_INCLUDE_DOCS:BOOL', 'TRUE')
292292
llvm_cmake_options.define('LLVM_ENABLE_LTO:STRING', self.args.lto_type)
293293
llvm_cmake_options.define('COMPILER_RT_INTERCEPT_LIBDISPATCH', 'ON')
294-
llvm_cmake_options.define('RUNTIMES_CMAKE_ARGS', '-DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR:BOOL=OFF')
294+
llvm_cmake_options.define(
295+
'RUNTIMES_CMAKE_ARGS',
296+
'-DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR:BOOL=OFF;'
297+
# This preserves the behaviour we had when using LLVM_BUILD_EXTERNAL COMPILER_RT --
298+
# that is, not requiring the linker to complaining if symbols used by TSan are
299+
# undefined (namely the ones for Blocks Runtime)
300+
'-DSANITIZER_COMMON_LINK_FLAGS:STRING=-Wl,-z,undefs')
295301

296302
if self.args.build_embedded_stdlib and system() == "Darwin":
297303
# Ask for Mach-O cross-compilation builtins (for Embedded Swift)
@@ -306,8 +312,6 @@ def build(self, host_target):
306312
not self.is_cross_compile_target(host_target):
307313
llvm_enable_runtimes.append('compiler-rt')
308314
build_targets.append("runtimes")
309-
# This is needed to build correctly TSan under Linux
310-
llvm_cmake_options.define('COMPILER_RT_USE_BUILTINS_LIBRARY', 'ON')
311315

312316
if self.args.build_clang_tools_extra:
313317
llvm_enable_projects.append('clang-tools-extra')

0 commit comments

Comments
 (0)