mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Merge pull request #71977 from kateinoigakukun/pr-5ff3fb0d5bd5d000aa636f748af814d1607455e3
This commit is contained in:
@@ -97,13 +97,16 @@ class CMakeOptions(object):
|
||||
|
||||
class CMake(object):
|
||||
|
||||
def __init__(self, args, toolchain, prefer_just_built_toolchain=False):
|
||||
"""If prefer_just_built_toolchain is set to True, we set the clang, clang++,
|
||||
and Swift compilers from the installed toolchain.
|
||||
def __init__(self, args, toolchain, prefer_native_toolchain=False):
|
||||
"""If prefer_native_toolchain is set to True, we set the clang, clang++,
|
||||
and Swift compilers from the toolchain explicitly specified by the
|
||||
native-*-tools-path options or just installed toolchain if the options
|
||||
are not specified. If prefer_native_toolchain is set to False, we use
|
||||
system defaults.
|
||||
"""
|
||||
self.args = args
|
||||
self.toolchain = toolchain
|
||||
self.prefer_just_built_toolchain = prefer_just_built_toolchain
|
||||
self.prefer_native_toolchain = prefer_native_toolchain
|
||||
|
||||
def common_options(self, product=None):
|
||||
"""Return options used for all products, including LLVM/Clang
|
||||
@@ -146,8 +149,8 @@ class CMake(object):
|
||||
if args.cmake_cxx_launcher:
|
||||
define("CMAKE_CXX_COMPILER_LAUNCHER:PATH", args.cmake_cxx_launcher)
|
||||
|
||||
if self.prefer_just_built_toolchain and product:
|
||||
toolchain_path = product.install_toolchain_path(args.host_target)
|
||||
if self.prefer_native_toolchain and product:
|
||||
toolchain_path = product.native_toolchain_path(args.host_target)
|
||||
cmake_swiftc_path = os.getenv('CMAKE_Swift_COMPILER',
|
||||
os.path.join(toolchain_path, 'bin', 'swiftc'))
|
||||
define("CMAKE_C_COMPILER:PATH", os.path.join(toolchain_path,
|
||||
|
||||
@@ -24,11 +24,11 @@ class CMakeProduct(product.Product):
|
||||
return self.args.verbose_build
|
||||
|
||||
def build_with_cmake(self, build_targets, build_type, build_args,
|
||||
prefer_just_built_toolchain=False):
|
||||
prefer_native_toolchain=False):
|
||||
assert self.toolchain.cmake is not None
|
||||
cmake_build = []
|
||||
_cmake = cmake.CMake(self.args, self.toolchain,
|
||||
prefer_just_built_toolchain)
|
||||
prefer_native_toolchain)
|
||||
|
||||
if self.toolchain.distcc_pump:
|
||||
cmake_build.append(self.toolchain.distcc_pump)
|
||||
|
||||
@@ -174,7 +174,7 @@ class MinimalStdlib(cmake_product.CMakeProduct):
|
||||
|
||||
# Build!
|
||||
self.build_with_cmake(["swift-stdlib-freestanding"], build_variant, [],
|
||||
prefer_just_built_toolchain=True)
|
||||
prefer_native_toolchain=True)
|
||||
|
||||
def should_test(self, host_target):
|
||||
return False
|
||||
|
||||
@@ -45,7 +45,10 @@ class WASILibc(product.Product):
|
||||
|
||||
def build(self, host_target):
|
||||
build_root = os.path.dirname(self.build_dir)
|
||||
llvm_build_dir = os.path.join('..', build_root, '%s-%s' % ('llvm', host_target))
|
||||
llvm_build_bin_dir = os.path.join(
|
||||
'..', build_root, '%s-%s' % ('llvm', host_target), 'bin')
|
||||
llvm_tools_path = self.args.native_llvm_tools_path or llvm_build_bin_dir
|
||||
clang_tools_path = self.args.native_clang_tools_path or llvm_build_bin_dir
|
||||
build_jobs = self.args.build_jobs or multiprocessing.cpu_count()
|
||||
|
||||
sysroot_build_dir = WASILibc.sysroot_build_path(build_root, host_target)
|
||||
@@ -66,9 +69,9 @@ class WASILibc(product.Product):
|
||||
'OBJDIR=' + os.path.join(self.build_dir, 'obj'),
|
||||
'SYSROOT=' + sysroot_build_dir,
|
||||
'INSTALL_DIR=' + WASILibc.sysroot_install_path(build_root),
|
||||
'CC=' + os.path.join(llvm_build_dir, 'bin', 'clang'),
|
||||
'AR=' + os.path.join(llvm_build_dir, 'bin', 'llvm-ar'),
|
||||
'NM=' + os.path.join(llvm_build_dir, 'bin', 'llvm-nm'),
|
||||
'CC=' + os.path.join(clang_tools_path, 'clang'),
|
||||
'AR=' + os.path.join(llvm_tools_path, 'llvm-ar'),
|
||||
'NM=' + os.path.join(llvm_tools_path, 'llvm-nm'),
|
||||
])
|
||||
|
||||
@classmethod
|
||||
@@ -119,7 +122,10 @@ class WasmLLVMRuntimeLibs(cmake_product.CMakeProduct):
|
||||
|
||||
def build(self, host_target):
|
||||
build_root = os.path.dirname(self.build_dir)
|
||||
llvm_build_dir = os.path.join('..', build_root, '%s-%s' % ('llvm', host_target))
|
||||
llvm_build_bin_dir = os.path.join(
|
||||
'..', build_root, '%s-%s' % ('llvm', host_target), 'bin')
|
||||
llvm_tools_path = self.args.native_llvm_tools_path or llvm_build_bin_dir
|
||||
clang_tools_path = self.args.native_clang_tools_path or llvm_build_bin_dir
|
||||
|
||||
self.cmake_options.define('CMAKE_SYSROOT:PATH',
|
||||
WASILibc.sysroot_build_path(build_root, host_target))
|
||||
@@ -144,13 +150,13 @@ class WasmLLVMRuntimeLibs(cmake_product.CMakeProduct):
|
||||
self.cmake_options.define('CMAKE_SYSTEM_NAME:STRING', 'WASI')
|
||||
self.cmake_options.define('CMAKE_SYSTEM_PROCESSOR:STRING', 'wasm32')
|
||||
self.cmake_options.define('CMAKE_AR:FILEPATH',
|
||||
os.path.join(llvm_build_dir, 'bin', 'llvm-ar'))
|
||||
os.path.join(llvm_tools_path, 'llvm-ar'))
|
||||
self.cmake_options.define('CMAKE_RANLIB:FILEPATH',
|
||||
os.path.join(llvm_build_dir, 'bin', 'llvm-ranlib'))
|
||||
os.path.join(llvm_tools_path, 'llvm-ranlib'))
|
||||
self.cmake_options.define('CMAKE_C_COMPILER:FILEPATH',
|
||||
os.path.join(llvm_build_dir, 'bin', 'clang'))
|
||||
os.path.join(clang_tools_path, 'clang'))
|
||||
self.cmake_options.define('CMAKE_CXX_COMPILER:STRING',
|
||||
os.path.join(llvm_build_dir, 'bin', 'clang++'))
|
||||
os.path.join(clang_tools_path, 'clang++'))
|
||||
# Explicitly disable exceptions even though it's usually implicitly disabled by
|
||||
# LIBCXX_ENABLE_EXCEPTIONS because the CMake feature check fails to detect
|
||||
# -fno-exceptions support in clang due to missing compiler-rt while configuring
|
||||
@@ -188,7 +194,7 @@ class WasmLLVMRuntimeLibs(cmake_product.CMakeProduct):
|
||||
self.cmake_options.define('UNIX:BOOL', 'TRUE')
|
||||
|
||||
self.build_with_cmake([], self.args.build_variant, [],
|
||||
prefer_just_built_toolchain=True)
|
||||
prefer_native_toolchain=True)
|
||||
self.install_with_cmake(
|
||||
["install"], WASILibc.sysroot_install_path(build_root))
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ class WasmStdlib(cmake_product.CMakeProduct):
|
||||
'SWIFT_STDLIB_BUILD_TYPE:STRING', self._build_variant)
|
||||
|
||||
# Toolchain configuration
|
||||
toolchain_path = self.install_toolchain_path(host_target)
|
||||
toolchain_path = self.native_toolchain_path(host_target)
|
||||
# Explicitly set the CMake AR and RANLIB to force it to use llvm-ar/llvm-ranlib
|
||||
# instead of the system ar/ranlib, which usually don't support WebAssembly
|
||||
# object files.
|
||||
@@ -117,7 +117,7 @@ class WasmStdlib(cmake_product.CMakeProduct):
|
||||
|
||||
# Configure with WebAssembly target variant, and build with just-built toolchain
|
||||
self.build_with_cmake([], self._build_variant, [],
|
||||
prefer_just_built_toolchain=True)
|
||||
prefer_native_toolchain=True)
|
||||
|
||||
def test(self, host_target):
|
||||
build_root = os.path.dirname(self.build_dir)
|
||||
|
||||
Reference in New Issue
Block a user