From c018f679e871ab19298e912ee229f54f3e069564 Mon Sep 17 00:00:00 2001 From: Eric Miotto Date: Wed, 7 May 2025 07:04:17 -0700 Subject: [PATCH 1/2] Revert "Fallback to legacy way to build compiler-rt in some Linux bots" This reverts commit 0441a81211fd48451ad43896b51f8656a1f7aa0d. --- utils/build-presets.ini | 3 --- 1 file changed, 3 deletions(-) diff --git a/utils/build-presets.ini b/utils/build-presets.ini index fd72c77e9eee1..b701e8cb312a0 100644 --- a/utils/build-presets.ini +++ b/utils/build-presets.ini @@ -936,9 +936,6 @@ mixin-preset= skip-test-swiftdocc -# to allow to build under aarch64 -llvm-build-compiler-rt-with-use-runtime=0 - [preset: buildbot_linux,release_foundation_tests] mixin-preset=buildbot_linux From fcc03898c735b45738f53d592407be0be395ac8d Mon Sep 17 00:00:00 2001 From: Eric Miotto Date: Thu, 8 May 2025 09:43:46 -0700 Subject: [PATCH 2/2] 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 --- .../swift_build_support/products/llvm.py | 24 +++++++++++++++---- .../swift_build_support/products/product.py | 7 +++--- 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/utils/swift_build_support/swift_build_support/products/llvm.py b/utils/swift_build_support/swift_build_support/products/llvm.py index fad5efa812503..c5371269f534e 100644 --- a/utils/swift_build_support/swift_build_support/products/llvm.py +++ b/utils/swift_build_support/swift_build_support/products/llvm.py @@ -242,7 +242,9 @@ def build(self, host_target): llvm_cmake_options.define('INTERNAL_INSTALL_PREFIX', 'local') if host_target.startswith('linux'): - toolchain_file = self.generate_linux_toolchain_file(platform, arch) + toolchain_file = self.generate_linux_toolchain_file( + platform, arch, + crosscompiling=self.is_cross_compile_target(host_target)) llvm_cmake_options.define('CMAKE_TOOLCHAIN_FILE:PATH', toolchain_file) if not self.is_release(): # On Linux build LLVM and subprojects with -gsplit-dwarf which is more @@ -309,12 +311,26 @@ def build(self, host_target): if host_target.startswith('linux'): # This preserves the behaviour we had when using # LLVM_BUILD_EXTERNAL COMPILER_RT -- - # that is, having the linker not complaing if symbols used + # that is, having the linker not complaining if symbols used # by TSan are undefined (namely the ones for Blocks Runtime) # In the long term, we want to remove this and # build Blocks Runtime before LLVM - llvm_cmake_options.define( - 'SANITIZER_COMMON_LINK_FLAGS:STRING', '-Wl,-z,undefs') + if ("-DCLANG_DEFAULT_LINKER=gold" in llvm_cmake_options + or "-DCLANG_DEFAULT_LINKER:STRING=gold" in llvm_cmake_options): + print("Assuming just built clang will use a gold linker -- " + "if that's not the case, please adjust the value of " + "`SANITIZER_COMMON_LINK_FLAGS` in `extra-llvm-cmake-options`", + flush=True) + llvm_cmake_options.define( + 'SANITIZER_COMMON_LINK_FLAGS:STRING', + '-Wl,--unresolved-symbols,ignore-in-object-files') + else: + print("Assuming just built clang will use a non gold linker -- " + "if that's not the case, please adjust the value of " + "`SANITIZER_COMMON_LINK_FLAGS` in `extra-llvm-cmake-options`", + flush=True) + llvm_cmake_options.define( + 'SANITIZER_COMMON_LINK_FLAGS:STRING', '-Wl,-z,undefs') builtins_runtimes_target_for_darwin = f'{arch}-apple-darwin' if system() == "Darwin": diff --git a/utils/swift_build_support/swift_build_support/products/product.py b/utils/swift_build_support/swift_build_support/products/product.py index 8e675f228a29f..274b60373058b 100644 --- a/utils/swift_build_support/swift_build_support/products/product.py +++ b/utils/swift_build_support/swift_build_support/products/product.py @@ -389,7 +389,7 @@ def get_linux_target(self, platform, arch): sysroot_arch, vendor, abi = self.get_linux_target_components(arch) return '{}-{}-linux-{}'.format(sysroot_arch, vendor, abi) - def generate_linux_toolchain_file(self, platform, arch): + def generate_linux_toolchain_file(self, platform, arch, crosscompiling=True): """ Generates a new CMake tolchain file that specifies Linux as a target platform. @@ -402,8 +402,9 @@ def generate_linux_toolchain_file(self, platform, arch): toolchain_args = {} - toolchain_args['CMAKE_SYSTEM_NAME'] = 'Linux' - toolchain_args['CMAKE_SYSTEM_PROCESSOR'] = arch + if crosscompiling: + toolchain_args['CMAKE_SYSTEM_NAME'] = 'Linux' + toolchain_args['CMAKE_SYSTEM_PROCESSOR'] = arch # We only set the actual sysroot if we are actually cross # compiling. This is important since otherwise cmake seems to change the