Skip to content

Commit fcc0389

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 LLVM when building for the host architecture -- 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 fcc0389

File tree

2 files changed

+24
-7
lines changed

2 files changed

+24
-7
lines changed

utils/swift_build_support/swift_build_support/products/llvm.py

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -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":

utils/swift_build_support/swift_build_support/products/product.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ def get_linux_target(self, platform, arch):
389389
sysroot_arch, vendor, abi = self.get_linux_target_components(arch)
390390
return '{}-{}-linux-{}'.format(sysroot_arch, vendor, abi)
391391

392-
def generate_linux_toolchain_file(self, platform, arch):
392+
def generate_linux_toolchain_file(self, platform, arch, crosscompiling=True):
393393
"""
394394
Generates a new CMake tolchain file that specifies Linux as a target
395395
platform.
@@ -402,8 +402,9 @@ 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
405+
if crosscompiling:
406+
toolchain_args['CMAKE_SYSTEM_NAME'] = 'Linux'
407+
toolchain_args['CMAKE_SYSTEM_PROCESSOR'] = arch
407408

408409
# We only set the actual sysroot if we are actually cross
409410
# compiling. This is important since otherwise cmake seems to change the

0 commit comments

Comments
 (0)