@@ -242,7 +242,9 @@ def build(self, host_target):
242242 llvm_cmake_options .define ('INTERNAL_INSTALL_PREFIX' , 'local' )
243243
244244 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 ))
246248 llvm_cmake_options .define ('CMAKE_TOOLCHAIN_FILE:PATH' , toolchain_file )
247249 if not self .is_release ():
248250 # On Linux build LLVM and subprojects with -gsplit-dwarf which is more
@@ -309,12 +311,26 @@ def build(self, host_target):
309311 if host_target .startswith ('linux' ):
310312 # This preserves the behaviour we had when using
311313 # 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
313315 # by TSan are undefined (namely the ones for Blocks Runtime)
314316 # In the long term, we want to remove this and
315317 # 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' )
318334
319335 builtins_runtimes_target_for_darwin = f'{ arch } -apple-darwin'
320336 if system () == "Darwin" :
0 commit comments