@@ -217,6 +217,22 @@ def should_build(self, host_target):
217
217
# LLVM will always be built in part
218
218
return True
219
219
220
+ @classmethod
221
+ def compute_cmake_args_for_runtimes (cls , host_target ):
222
+ # Swift expects the old layout for the runtime directory
223
+ args_for_runtime = '-DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR:BOOL=OFF'
224
+
225
+ if host_target .startswith ('linux' ):
226
+ # This preserves the behaviour we had when using
227
+ # LLVM_BUILD_EXTERNAL COMPILER_RT --
228
+ # that is, having the linker not complaing if symbols used
229
+ # by TSan are undefined (namely the ones for Blocks Runtime)
230
+ # In the long term, we want to remove this and
231
+ # build Blocks Runtime before LLVM
232
+ args_for_runtime += ';-DSANITIZER_COMMON_LINK_FLAGS:STRING=-Wl,-z,undefs'
233
+
234
+ return args_for_runtime
235
+
220
236
def build (self , host_target ):
221
237
"""build() -> void
222
238
@@ -291,7 +307,9 @@ def build(self, host_target):
291
307
llvm_cmake_options .define ('LLVM_INCLUDE_DOCS:BOOL' , 'TRUE' )
292
308
llvm_cmake_options .define ('LLVM_ENABLE_LTO:STRING' , self .args .lto_type )
293
309
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' )
310
+ llvm_cmake_options .define (
311
+ 'RUNTIMES_CMAKE_ARGS' ,
312
+ LLVM .compute_cmake_args_for_runtimes (host_target ))
295
313
296
314
if self .args .build_embedded_stdlib and system () == "Darwin" :
297
315
# Ask for Mach-O cross-compilation builtins (for Embedded Swift)
@@ -306,8 +324,6 @@ def build(self, host_target):
306
324
not self .is_cross_compile_target (host_target ):
307
325
llvm_enable_runtimes .append ('compiler-rt' )
308
326
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' )
311
327
312
328
if self .args .build_clang_tools_extra :
313
329
llvm_enable_projects .append ('clang-tools-extra' )
0 commit comments