@@ -242,7 +242,9 @@ def build(self, host_target):
242
242
llvm_cmake_options .define ('INTERNAL_INSTALL_PREFIX' , 'local' )
243
243
244
244
if host_target .startswith ('linux' ):
245
- toolchain_file = self .generate_linux_toolchain_file (platform , arch )
245
+ toolchain_file = self .generate_linux_toolchain_file (
246
+ platform , arch ,
247
+ crosscompiling = self .is_cross_compile_target (host_target ))
246
248
llvm_cmake_options .define ('CMAKE_TOOLCHAIN_FILE:PATH' , toolchain_file )
247
249
if not self .is_release ():
248
250
# On Linux build LLVM and subprojects with -gsplit-dwarf which is more
@@ -309,12 +311,26 @@ def build(self, host_target):
309
311
if host_target .startswith ('linux' ):
310
312
# This preserves the behaviour we had when using
311
313
# LLVM_BUILD_EXTERNAL COMPILER_RT --
312
- # that is, having the linker not complaing if symbols used
314
+ # that is, having the linker not complaining if symbols used
313
315
# by TSan are undefined (namely the ones for Blocks Runtime)
314
316
# In the long term, we want to remove this and
315
317
# build Blocks Runtime before LLVM
316
- llvm_cmake_options .define (
317
- 'SANITIZER_COMMON_LINK_FLAGS:STRING' , '-Wl,-z,undefs' )
318
+ if ("-DCLANG_DEFAULT_LINKER=gold" in llvm_cmake_options
319
+ or "-DCLANG_DEFAULT_LINKER:STRING=gold" in llvm_cmake_options ):
320
+ print ("Assuming just built clang will use a gold linker -- "
321
+ "if that's not the case, please adjust the value of "
322
+ "`SANITIZER_COMMON_LINK_FLAGS` in `extra-llvm-cmake-options`" ,
323
+ flush = True )
324
+ llvm_cmake_options .define (
325
+ 'SANITIZER_COMMON_LINK_FLAGS:STRING' ,
326
+ '-Wl,--unresolved-symbols,ignore-in-object-files' )
327
+ else :
328
+ print ("Assuming just built clang will use a non gold linker -- "
329
+ "if that's not the case, please adjust the value of "
330
+ "`SANITIZER_COMMON_LINK_FLAGS` in `extra-llvm-cmake-options`" ,
331
+ flush = True )
332
+ llvm_cmake_options .define (
333
+ 'SANITIZER_COMMON_LINK_FLAGS:STRING' , '-Wl,-z,undefs' )
318
334
319
335
builtins_runtimes_target_for_darwin = f'{ arch } -apple-darwin'
320
336
if system () == "Darwin" :
0 commit comments