Skip to content

Commit ff1c471

Browse files
committed
Reenable build of compiler-rt with LLVM_ENABLE_RUNTIMES in Linux bots...
...we disabled in #81354 This requires a couple of supporting changes * under Linux, do not cross compile by default -- that will ensure that the compiler-rt build will use the just built compiler and not the system one (which may not be new enough for this purpose); * provide sanitizer flags depending on the linker the just built compiler will use -- this detection is brittle, so print a message advising the user how to override this. Addresses rdar://150849329
1 parent c018f67 commit ff1c471

File tree

2 files changed

+20
-6
lines changed

2 files changed

+20
-6
lines changed

utils/swift_build_support/swift_build_support/products/llvm.py

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -309,12 +309,26 @@ def build(self, host_target):
309309
if host_target.startswith('linux'):
310310
# This preserves the behaviour we had when using
311311
# LLVM_BUILD_EXTERNAL COMPILER_RT --
312-
# that is, having the linker not complaing if symbols used
312+
# that is, having the linker not complaining if symbols used
313313
# by TSan are undefined (namely the ones for Blocks Runtime)
314314
# In the long term, we want to remove this and
315315
# build Blocks Runtime before LLVM
316-
llvm_cmake_options.define(
317-
'SANITIZER_COMMON_LINK_FLAGS:STRING', '-Wl,-z,undefs')
316+
if ("-DCLANG_DEFAULT_LINKER=gold" in llvm_cmake_options
317+
or "-DCLANG_DEFAULT_LINKER:STRING=gold" in llvm_cmake_options):
318+
print("Assuming just built clang will use a gold linker -- "
319+
"if that's not the case, please adjust the value of "
320+
"`SANITIZER_COMMON_LINK_FLAGS` in `extra-llvm-cmake-options`",
321+
flush=True)
322+
llvm_cmake_options.define(
323+
'SANITIZER_COMMON_LINK_FLAGS:STRING',
324+
'-Wl,--unresolved-symbols,ignore-in-object-files')
325+
else:
326+
print("Assuming just built clang will use a non gold linker -- "
327+
"if that's not the case, please adjust the value of "
328+
"`SANITIZER_COMMON_LINK_FLAGS` in `extra-llvm-cmake-options`",
329+
flush=True)
330+
llvm_cmake_options.define(
331+
'SANITIZER_COMMON_LINK_FLAGS:STRING', '-Wl,-z,undefs')
318332

319333
builtins_runtimes_target_for_darwin = f'{arch}-apple-darwin'
320334
if system() == "Darwin":

utils/swift_build_support/swift_build_support/products/product.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -402,15 +402,15 @@ def generate_linux_toolchain_file(self, platform, arch):
402402

403403
toolchain_args = {}
404404

405-
toolchain_args['CMAKE_SYSTEM_NAME'] = 'Linux'
406-
toolchain_args['CMAKE_SYSTEM_PROCESSOR'] = arch
407-
408405
# We only set the actual sysroot if we are actually cross
409406
# compiling. This is important since otherwise cmake seems to change the
410407
# RUNPATH to be a relative rather than an absolute path, breaking
411408
# certain cmark tests (and maybe others).
412409
maybe_sysroot = self.get_linux_sysroot(platform, arch)
410+
print(f'DEBUG: detected sysroot for Linux (None = host sysroot) = {maybe_sysroot}')
413411
if maybe_sysroot is not None:
412+
toolchain_args['CMAKE_SYSTEM_NAME'] = 'Linux'
413+
toolchain_args['CMAKE_SYSTEM_PROCESSOR'] = arch
414414
toolchain_args['CMAKE_SYSROOT'] = maybe_sysroot
415415

416416
target = self.get_linux_target(platform, arch)

0 commit comments

Comments
 (0)