mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
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
This commit is contained in:
@@ -242,7 +242,9 @@ class LLVM(cmake_product.CMakeProduct):
|
|||||||
llvm_cmake_options.define('INTERNAL_INSTALL_PREFIX', 'local')
|
llvm_cmake_options.define('INTERNAL_INSTALL_PREFIX', 'local')
|
||||||
|
|
||||||
if host_target.startswith('linux'):
|
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)
|
llvm_cmake_options.define('CMAKE_TOOLCHAIN_FILE:PATH', toolchain_file)
|
||||||
if not self.is_release():
|
if not self.is_release():
|
||||||
# On Linux build LLVM and subprojects with -gsplit-dwarf which is more
|
# On Linux build LLVM and subprojects with -gsplit-dwarf which is more
|
||||||
@@ -309,12 +311,26 @@ class LLVM(cmake_product.CMakeProduct):
|
|||||||
if host_target.startswith('linux'):
|
if host_target.startswith('linux'):
|
||||||
# This preserves the behaviour we had when using
|
# This preserves the behaviour we had when using
|
||||||
# LLVM_BUILD_EXTERNAL COMPILER_RT --
|
# 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)
|
# by TSan are undefined (namely the ones for Blocks Runtime)
|
||||||
# In the long term, we want to remove this and
|
# In the long term, we want to remove this and
|
||||||
# build Blocks Runtime before LLVM
|
# build Blocks Runtime before LLVM
|
||||||
llvm_cmake_options.define(
|
if ("-DCLANG_DEFAULT_LINKER=gold" in llvm_cmake_options
|
||||||
'SANITIZER_COMMON_LINK_FLAGS:STRING', '-Wl,-z,undefs')
|
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'
|
builtins_runtimes_target_for_darwin = f'{arch}-apple-darwin'
|
||||||
if system() == "Darwin":
|
if system() == "Darwin":
|
||||||
|
|||||||
@@ -389,7 +389,7 @@ class Product(object):
|
|||||||
sysroot_arch, vendor, abi = self.get_linux_target_components(arch)
|
sysroot_arch, vendor, abi = self.get_linux_target_components(arch)
|
||||||
return '{}-{}-linux-{}'.format(sysroot_arch, vendor, abi)
|
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
|
Generates a new CMake tolchain file that specifies Linux as a target
|
||||||
platform.
|
platform.
|
||||||
@@ -402,8 +402,9 @@ class Product(object):
|
|||||||
|
|
||||||
toolchain_args = {}
|
toolchain_args = {}
|
||||||
|
|
||||||
toolchain_args['CMAKE_SYSTEM_NAME'] = 'Linux'
|
if crosscompiling:
|
||||||
toolchain_args['CMAKE_SYSTEM_PROCESSOR'] = arch
|
toolchain_args['CMAKE_SYSTEM_NAME'] = 'Linux'
|
||||||
|
toolchain_args['CMAKE_SYSTEM_PROCESSOR'] = arch
|
||||||
|
|
||||||
# We only set the actual sysroot if we are actually cross
|
# We only set the actual sysroot if we are actually cross
|
||||||
# compiling. This is important since otherwise cmake seems to change the
|
# compiling. This is important since otherwise cmake seems to change the
|
||||||
|
|||||||
Reference in New Issue
Block a user