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 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