2021-01-14 16:12:45 +01:00
|
|
|
diff --git a/swift/CMakeLists.txt b/swift/CMakeLists.txt
|
|
|
|
index 8be6f4a7abd7..77e81153a232 100644
|
|
|
|
--- a/swift/CMakeLists.txt
|
|
|
|
+++ b/swift/CMakeLists.txt
|
|
|
|
@@ -481,10 +481,12 @@ if(SWIFT_PATH_TO_CMARK_BUILD)
|
|
|
|
endif()
|
|
|
|
message(STATUS "")
|
|
|
|
|
|
|
|
-if("${SWIFT_NATIVE_LLVM_TOOLS_PATH}" STREQUAL "")
|
|
|
|
- set(SWIFT_CROSS_COMPILING FALSE)
|
|
|
|
+# Check if a prebuilt clang path was passed in, as this variable will be
|
|
|
|
+# assigned if not, in SwiftSharedCMakeConfig.
|
|
|
|
+if("${SWIFT_NATIVE_CLANG_TOOLS_PATH}" STREQUAL "")
|
|
|
|
+ set(SWIFT_PREBUILT_CLANG FALSE)
|
|
|
|
else()
|
|
|
|
- set(SWIFT_CROSS_COMPILING TRUE)
|
|
|
|
+ set(SWIFT_PREBUILT_CLANG TRUE)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
include(SwiftSharedCMakeConfig)
|
|
|
|
diff --git a/swift/cmake/modules/SwiftSharedCMakeConfig.cmake b/swift/cmake/modules/SwiftSharedCMakeConfig.cmake
|
|
|
|
index c4c15084fe90..9ee086565891 100644
|
|
|
|
--- a/swift/cmake/modules/SwiftSharedCMakeConfig.cmake
|
|
|
|
+++ b/swift/cmake/modules/SwiftSharedCMakeConfig.cmake
|
|
|
|
@@ -58,7 +58,7 @@ macro(swift_common_standalone_build_config_llvm product)
|
|
|
|
fix_imported_targets_for_xcode("${LLVM_EXPORTED_TARGETS}")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
- if(NOT CMAKE_CROSSCOMPILING AND NOT SWIFT_CROSS_COMPILING)
|
|
|
|
+ if(NOT CMAKE_CROSSCOMPILING)
|
|
|
|
set(${product}_NATIVE_LLVM_TOOLS_PATH "${LLVM_TOOLS_BINARY_DIR}")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
@@ -159,7 +159,7 @@ endmacro()
|
|
|
|
macro(swift_common_standalone_build_config_clang product)
|
|
|
|
find_package(Clang CONFIG REQUIRED NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH)
|
|
|
|
|
|
|
|
- if (NOT CMAKE_CROSSCOMPILING)
|
|
|
|
+ if (NOT CMAKE_CROSSCOMPILING AND NOT SWIFT_PREBUILT_CLANG)
|
|
|
|
set(${product}_NATIVE_CLANG_TOOLS_PATH "${LLVM_TOOLS_BINARY_DIR}")
|
|
|
|
endif()
|
|
|
|
|
2020-11-06 17:02:29 +01:00
|
|
|
diff --git a/swift/stdlib/CMakeLists.txt b/swift/stdlib/CMakeLists.txt
|
2021-01-14 16:12:45 +01:00
|
|
|
index edf7c19f4b7a..91d9f4c28a51 100644
|
2020-11-06 17:02:29 +01:00
|
|
|
--- a/swift/stdlib/CMakeLists.txt
|
|
|
|
+++ b/swift/stdlib/CMakeLists.txt
|
2021-01-14 16:12:45 +01:00
|
|
|
@@ -112,11 +112,11 @@ else()
|
2020-11-06 17:02:29 +01:00
|
|
|
# If we use Clang-cl or MSVC, CMake provides default compiler and linker flags that are incompatible
|
|
|
|
# with the frontend of Clang or Clang++.
|
|
|
|
if(SWIFT_COMPILER_IS_MSVC_LIKE)
|
|
|
|
- set(CMAKE_CXX_COMPILER "${SWIFT_NATIVE_LLVM_TOOLS_PATH}/clang-cl")
|
|
|
|
- set(CMAKE_C_COMPILER "${SWIFT_NATIVE_LLVM_TOOLS_PATH}/clang-cl")
|
|
|
|
+ set(CMAKE_CXX_COMPILER "${SWIFT_NATIVE_CLANG_TOOLS_PATH}/clang-cl")
|
|
|
|
+ set(CMAKE_C_COMPILER "${SWIFT_NATIVE_CLANG_TOOLS_PATH}/clang-cl")
|
|
|
|
else()
|
|
|
|
- set(CMAKE_CXX_COMPILER "${SWIFT_NATIVE_LLVM_TOOLS_PATH}/clang++")
|
|
|
|
- set(CMAKE_C_COMPILER "${SWIFT_NATIVE_LLVM_TOOLS_PATH}/clang")
|
|
|
|
+ set(CMAKE_CXX_COMPILER "${SWIFT_NATIVE_CLANG_TOOLS_PATH}/clang++")
|
|
|
|
+ set(CMAKE_C_COMPILER "${SWIFT_NATIVE_CLANG_TOOLS_PATH}/clang")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(CMAKE_C_COMPILER_LAUNCHER MATCHES ".*distcc")
|
2021-01-14 16:12:45 +01:00
|
|
|
diff --git a/swift/stdlib/cmake/modules/AddSwiftStdlib.cmake b/swift/stdlib/cmake/modules/AddSwiftStdlib.cmake
|
|
|
|
index 2a6e1d1df071..d5df9c57dd33 100644
|
|
|
|
--- a/swift/stdlib/cmake/modules/AddSwiftStdlib.cmake
|
|
|
|
+++ b/swift/stdlib/cmake/modules/AddSwiftStdlib.cmake
|
|
|
|
@@ -1669,7 +1669,8 @@ function(add_swift_target_library name)
|
|
|
|
list(APPEND SWIFTLIB_SWIFT_COMPILE_FLAGS "-warn-implicit-overrides")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
- if(NOT SWIFT_BUILD_RUNTIME_WITH_HOST_COMPILER AND NOT BUILD_STANDALONE)
|
|
|
|
+ if(NOT SWIFT_BUILD_RUNTIME_WITH_HOST_COMPILER AND NOT BUILD_STANDALONE AND
|
|
|
|
+ NOT SWIFT_PREBUILT_CLANG)
|
|
|
|
list(APPEND SWIFTLIB_DEPENDS clang)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
diff --git a/swift/stdlib/public/SwiftShims/CMakeLists.txt b/swift/stdlib/public/SwiftShims/CMakeLists.txt
|
|
|
|
index 926020372fb2..5ee8a9c92069 100644
|
|
|
|
--- a/swift/stdlib/public/SwiftShims/CMakeLists.txt
|
|
|
|
+++ b/swift/stdlib/public/SwiftShims/CMakeLists.txt
|
|
|
|
@@ -111,7 +111,8 @@ endif()
|
|
|
|
# First extract the "version" used for Clang's resource directory.
|
|
|
|
string(REGEX MATCH "[0-9]+\\.[0-9]+(\\.[0-9]+)?" CLANG_VERSION
|
|
|
|
"${LLVM_PACKAGE_VERSION}")
|
|
|
|
-if(NOT SWIFT_INCLUDE_TOOLS AND SWIFT_BUILD_RUNTIME_WITH_HOST_COMPILER)
|
|
|
|
+if(NOT SWIFT_INCLUDE_TOOLS AND
|
|
|
|
+ (SWIFT_BUILD_RUNTIME_WITH_HOST_COMPILER OR SWIFT_PREBUILT_CLANG))
|
|
|
|
if(SWIFT_COMPILER_IS_MSVC_LIKE)
|
|
|
|
execute_process(COMMAND ${CMAKE_C_COMPILER} /clang:-print-resource-dir
|
|
|
|
OUTPUT_VARIABLE clang_headers_location
|
|
|
|
diff --git a/swift/unittests/runtime/CMakeLists.txt b/swift/unittests/runtime/CMakeLists.txt
|
|
|
|
index 60f9944e1e64..2ca86bf2b407 100644
|
|
|
|
--- a/swift/unittests/runtime/CMakeLists.txt
|
|
|
|
+++ b/swift/unittests/runtime/CMakeLists.txt
|
|
|
|
@@ -13,11 +13,11 @@ if(("${SWIFT_HOST_VARIANT_SDK}" STREQUAL "${SWIFT_PRIMARY_VARIANT_SDK}") AND
|
|
|
|
# If we use Clang-cl or MSVC, CMake provides default compiler and linker flags that are incompatible
|
|
|
|
# with the frontend of Clang or Clang++.
|
|
|
|
if(SWIFT_COMPILER_IS_MSVC_LIKE)
|
|
|
|
- set(CMAKE_CXX_COMPILER "${SWIFT_NATIVE_LLVM_TOOLS_PATH}/clang-cl")
|
|
|
|
- set(CMAKE_C_COMPILER "${SWIFT_NATIVE_LLVM_TOOLS_PATH}/clang-cl")
|
|
|
|
+ set(CMAKE_CXX_COMPILER "${SWIFT_NATIVE_CLANG_TOOLS_PATH}/clang-cl")
|
|
|
|
+ set(CMAKE_C_COMPILER "${SWIFT_NATIVE_CLANG_TOOLS_PATH}/clang-cl")
|
|
|
|
else()
|
|
|
|
- set(CMAKE_CXX_COMPILER "${SWIFT_NATIVE_LLVM_TOOLS_PATH}/clang++")
|
|
|
|
- set(CMAKE_C_COMPILER "${SWIFT_NATIVE_LLVM_TOOLS_PATH}/clang")
|
|
|
|
+ set(CMAKE_CXX_COMPILER "${SWIFT_NATIVE_CLANG_TOOLS_PATH}/clang++")
|
|
|
|
+ set(CMAKE_C_COMPILER "${SWIFT_NATIVE_CLANG_TOOLS_PATH}/clang")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(CMAKE_C_COMPILER_LAUNCHER MATCHES ".*distcc")
|
|
|
|
diff --git a/swift/utils/build-presets.ini b/swift/utils/build-presets.ini
|
|
|
|
index 5330b5acba18..dcba1e6d7b74 100644
|
|
|
|
--- a/swift/utils/build-presets.ini
|
|
|
|
+++ b/swift/utils/build-presets.ini
|
|
|
|
@@ -2283,10 +2283,9 @@ skip-build-cmark
|
|
|
|
skip-build-benchmarks
|
|
|
|
skip-test-cmark
|
|
|
|
|
|
|
|
-# This triggers the stdlib standalone build: Don't build tools (the compiler),
|
|
|
|
-# assume we are working with the host compiler.
|
|
|
|
+# This triggers the stdlib standalone build: don't build the native tools from
|
|
|
|
+# scratch, ie the compiler.
|
|
|
|
build-swift-tools=0
|
|
|
|
-build-runtime-with-host-compiler=1
|
|
|
|
|
|
|
|
# Then set the paths to our native tools. If compiling against a toolchain,
|
|
|
|
# these should all be the ./usr/bin directory.
|
2020-11-06 17:02:29 +01:00
|
|
|
diff --git a/swift/utils/build-script b/swift/utils/build-script
|
2021-01-14 16:12:45 +01:00
|
|
|
index ab9809b1351c..f544478b2a57 100755
|
2020-11-06 17:02:29 +01:00
|
|
|
--- a/swift/utils/build-script
|
|
|
|
+++ b/swift/utils/build-script
|
2021-01-14 16:12:45 +01:00
|
|
|
@@ -707,6 +707,18 @@ class BuildScriptInvocation(object):
|
2020-11-06 17:02:29 +01:00
|
|
|
impl_args += [
|
|
|
|
"--host-libtool", toolchain.libtool,
|
|
|
|
]
|
|
|
|
+ if args.native_clang_tools_path is not None:
|
|
|
|
+ impl_args += [
|
|
|
|
+ "--native-clang-tools-path=%s" % args.native_clang_tools_path
|
|
|
|
+ ]
|
|
|
|
+ if args.native_llvm_tools_path is not None:
|
|
|
|
+ impl_args += [
|
|
|
|
+ "--native-llvm-tools-path=%s" % args.native_llvm_tools_path
|
|
|
|
+ ]
|
|
|
|
+ if args.native_swift_tools_path is not None:
|
|
|
|
+ impl_args += [
|
|
|
|
+ "--native-swift-tools-path=%s" % args.native_swift_tools_path
|
|
|
|
+ ]
|
|
|
|
|
|
|
|
# If we have extra_swift_args, combine all of them together and then
|
|
|
|
# add them as one command.
|
2021-01-14 16:12:45 +01:00
|
|
|
diff --git a/swift/utils/build-script-impl b/swift/utils/build-script-impl
|
|
|
|
index 268d23de155a..7ac53c1e5a91 100755
|
|
|
|
--- a/swift/utils/build-script-impl
|
|
|
|
+++ b/swift/utils/build-script-impl
|
|
|
|
@@ -1485,13 +1485,6 @@ for host in "${ALL_HOSTS[@]}"; do
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
- if [[ "${NATIVE_CLANG_TOOLS_PATH}" ]] ; then
|
|
|
|
- common_cmake_options_host+=(
|
|
|
|
- -DCMAKE_C_COMPILER="${NATIVE_CLANG_TOOLS_PATH}/clang"
|
|
|
|
- -DCMAKE_CXX_COMPILER="${NATIVE_CLANG_TOOLS_PATH}/clang++"
|
|
|
|
- )
|
|
|
|
- fi
|
|
|
|
-
|
|
|
|
llvm_cmake_options=(
|
|
|
|
"${llvm_cmake_options[@]}"
|
|
|
|
-DCMAKE_INSTALL_PREFIX:PATH="$(get_host_install_prefix ${host})"
|
2020-11-06 17:02:29 +01:00
|
|
|
diff --git a/swift/utils/build_swift/build_swift/driver_arguments.py b/swift/utils/build_swift/build_swift/driver_arguments.py
|
2021-01-14 16:12:45 +01:00
|
|
|
index 28a3ec0e6ab2..aab24712b801 100644
|
2020-11-06 17:02:29 +01:00
|
|
|
--- a/swift/utils/build_swift/build_swift/driver_arguments.py
|
|
|
|
+++ b/swift/utils/build_swift/build_swift/driver_arguments.py
|
|
|
|
@@ -374,6 +374,15 @@ def create_argument_parser():
|
|
|
|
option('--host-cxx', store_path(executable=True),
|
|
|
|
help='the absolute path to CXX, the "clang++" compiler for the '
|
|
|
|
'host platform. Default is auto detected.')
|
|
|
|
+ option('--native-swift-tools-path', store_path,
|
|
|
|
+ help='the path to a directory that contains prebuilt Swift tools '
|
|
|
|
+ 'that are executable on the host platform')
|
|
|
|
+ option('--native-clang-tools-path', store_path,
|
|
|
|
+ help='the path to a directory that contains prebuilt Clang tools '
|
|
|
|
+ 'that are executable on the host platform')
|
|
|
|
+ option('--native-llvm-tools-path', store_path,
|
|
|
|
+ help='the path to a directory that contains prebuilt LLVM tools '
|
|
|
|
+ 'that are executable on the host platform')
|
|
|
|
option('--cmake-c-launcher', store_path(executable=True),
|
|
|
|
default=os.environ.get('C_COMPILER_LAUNCHER', None),
|
|
|
|
help='the absolute path to set CMAKE_C_COMPILER_LAUNCHER')
|
2021-01-14 16:12:45 +01:00
|
|
|
diff --git a/swift/utils/build_swift/tests/expected_options.py b/swift/utils/build_swift/tests/expected_options.py
|
|
|
|
index 8f13cca65b9c..9ecfc4714312 100644
|
|
|
|
--- a/swift/utils/build_swift/tests/expected_options.py
|
|
|
|
+++ b/swift/utils/build_swift/tests/expected_options.py
|
|
|
|
@@ -189,6 +189,9 @@
|
|
|
|
'lto_type': None,
|
|
|
|
'maccatalyst': False,
|
|
|
|
'maccatalyst_ios_tests': False,
|
|
|
|
+ 'native_clang_tools_path': None,
|
|
|
|
+ 'native_llvm_tools_path': None,
|
|
|
|
+ 'native_swift_tools_path': None,
|
|
|
|
'dump_config': False,
|
|
|
|
'show_sdks': False,
|
|
|
|
'skip_build': False,
|
|
|
|
@@ -653,6 +656,9 @@ class BuildScriptImplOption(_BaseOption):
|
|
|
|
PathOption('--install-symroot'),
|
|
|
|
PathOption('--install-destdir'),
|
|
|
|
EnableOption('--install-all'),
|
|
|
|
+ PathOption('--native-clang-tools-path'),
|
|
|
|
+ PathOption('--native-llvm-tools-path'),
|
|
|
|
+ PathOption('--native-swift-tools-path'),
|
|
|
|
PathOption('--symbols-package'),
|
|
|
|
PathOption('--cmake-c-launcher'),
|
|
|
|
PathOption('--cmake-cxx-launcher'),
|
2020-11-06 17:02:29 +01:00
|
|
|
diff --git a/swift/utils/swift_build_support/swift_build_support/products/product.py b/swift/utils/swift_build_support/swift_build_support/products/product.py
|
2021-01-14 16:12:45 +01:00
|
|
|
index ba6f673bb6c9..075b934d10ac 100644
|
2020-11-06 17:02:29 +01:00
|
|
|
--- a/swift/utils/swift_build_support/swift_build_support/products/product.py
|
|
|
|
+++ b/swift/utils/swift_build_support/swift_build_support/products/product.py
|
2021-01-14 16:12:45 +01:00
|
|
|
@@ -167,8 +167,11 @@ def install_toolchain_path(self, host_target):
|
|
|
|
"""toolchain_path() -> string
|
|
|
|
|
2020-11-06 17:02:29 +01:00
|
|
|
Returns the path to the toolchain that is being created as part of this
|
2021-01-14 16:12:45 +01:00
|
|
|
- build.
|
|
|
|
+ build, or to a native prebuilt toolchain that was passed in.
|
2020-11-06 17:02:29 +01:00
|
|
|
"""
|
|
|
|
+ if self.args.native_swift_tools_path is not None:
|
|
|
|
+ return os.path.split(self.args.native_swift_tools_path)[0]
|
|
|
|
+
|
|
|
|
install_destdir = self.args.install_destdir
|
|
|
|
if self.args.cross_compile_hosts:
|
|
|
|
build_root = os.path.dirname(self.build_dir)
|