Skip to content

Commit 9ed6766

Browse files
committed
[build-script] Move --native-{clang,llvm,swift}-tools-path flags into the Python build-script
Also, fix two places where the LLVM path was wrongly employed to set up clang, and use the Swift path in install_toolchain_path().
1 parent d1bfe02 commit 9ed6766

File tree

6 files changed

+38
-8
lines changed

6 files changed

+38
-8
lines changed

stdlib/CMakeLists.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,11 @@ else()
102102
# If we use Clang-cl or MSVC, CMake provides default compiler and linker flags that are incompatible
103103
# with the frontend of Clang or Clang++.
104104
if(SWIFT_COMPILER_IS_MSVC_LIKE)
105-
set(CMAKE_CXX_COMPILER "${SWIFT_NATIVE_LLVM_TOOLS_PATH}/clang-cl")
106-
set(CMAKE_C_COMPILER "${SWIFT_NATIVE_LLVM_TOOLS_PATH}/clang-cl")
105+
set(CMAKE_CXX_COMPILER "${SWIFT_NATIVE_CLANG_TOOLS_PATH}/clang-cl")
106+
set(CMAKE_C_COMPILER "${SWIFT_NATIVE_CLANG_TOOLS_PATH}/clang-cl")
107107
else()
108-
set(CMAKE_CXX_COMPILER "${SWIFT_NATIVE_LLVM_TOOLS_PATH}/clang++")
109-
set(CMAKE_C_COMPILER "${SWIFT_NATIVE_LLVM_TOOLS_PATH}/clang")
108+
set(CMAKE_CXX_COMPILER "${SWIFT_NATIVE_CLANG_TOOLS_PATH}/clang++")
109+
set(CMAKE_C_COMPILER "${SWIFT_NATIVE_CLANG_TOOLS_PATH}/clang")
110110
endif()
111111

112112
if(CMAKE_C_COMPILER_LAUNCHER MATCHES ".*distcc")

unittests/runtime/CMakeLists.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ if(("${SWIFT_HOST_VARIANT_SDK}" STREQUAL "${SWIFT_PRIMARY_VARIANT_SDK}") AND
1313
# If we use Clang-cl or MSVC, CMake provides default compiler and linker flags that are incompatible
1414
# with the frontend of Clang or Clang++.
1515
if(SWIFT_COMPILER_IS_MSVC_LIKE)
16-
set(CMAKE_CXX_COMPILER "${SWIFT_NATIVE_LLVM_TOOLS_PATH}/clang-cl")
17-
set(CMAKE_C_COMPILER "${SWIFT_NATIVE_LLVM_TOOLS_PATH}/clang-cl")
16+
set(CMAKE_CXX_COMPILER "${SWIFT_NATIVE_CLANG_TOOLS_PATH}/clang-cl")
17+
set(CMAKE_C_COMPILER "${SWIFT_NATIVE_CLANG_TOOLS_PATH}/clang-cl")
1818
else()
19-
set(CMAKE_CXX_COMPILER "${SWIFT_NATIVE_LLVM_TOOLS_PATH}/clang++")
20-
set(CMAKE_C_COMPILER "${SWIFT_NATIVE_LLVM_TOOLS_PATH}/clang")
19+
set(CMAKE_CXX_COMPILER "${SWIFT_NATIVE_CLANG_TOOLS_PATH}/clang++")
20+
set(CMAKE_C_COMPILER "${SWIFT_NATIVE_CLANG_TOOLS_PATH}/clang")
2121
endif()
2222

2323
if(CMAKE_C_COMPILER_LAUNCHER MATCHES ".*distcc")

utils/build-script

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -704,6 +704,18 @@ class BuildScriptInvocation(object):
704704
impl_args += [
705705
"--host-libtool", toolchain.libtool,
706706
]
707+
if args.native_clang_tools_path is not None:
708+
impl_args += [
709+
"--native-clang-tools-path=%s" % args.native_clang_tools_path
710+
]
711+
if args.native_llvm_tools_path is not None:
712+
impl_args += [
713+
"--native-llvm-tools-path=%s" % args.native_llvm_tools_path
714+
]
715+
if args.native_swift_tools_path is not None:
716+
impl_args += [
717+
"--native-swift-tools-path=%s" % args.native_swift_tools_path
718+
]
707719

708720
# If we have extra_swift_args, combine all of them together and then
709721
# add them as one command.

utils/build_swift/build_swift/driver_arguments.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,15 @@ def create_argument_parser():
374374
option('--host-cxx', store_path(executable=True),
375375
help='the absolute path to CXX, the "clang++" compiler for the '
376376
'host platform. Default is auto detected.')
377+
option('--native-swift-tools-path', store_path,
378+
help='the path to a directory that contains prebuilt Swift tools '
379+
'that are executable on the host platform')
380+
option('--native-clang-tools-path', store_path,
381+
help='the path to a directory that contains prebuilt Clang tools '
382+
'that are executable on the host platform')
383+
option('--native-llvm-tools-path', store_path,
384+
help='the path to a directory that contains prebuilt LLVM tools '
385+
'that are executable on the host platform')
377386
option('--cmake-c-launcher', store_path(executable=True),
378387
default=os.environ.get('C_COMPILER_LAUNCHER', None),
379388
help='the absolute path to set CMAKE_C_COMPILER_LAUNCHER')

utils/build_swift/tests/expected_options.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,9 @@
188188
'lto_type': None,
189189
'maccatalyst': False,
190190
'maccatalyst_ios_tests': False,
191+
'native_clang_tools_path': None,
192+
'native_llvm_tools_path': None,
193+
'native_swift_tools_path': None,
191194
'dump_config': False,
192195
'show_sdks': False,
193196
'skip_build': False,
@@ -652,6 +655,9 @@ class BuildScriptImplOption(_BaseOption):
652655
PathOption('--install-symroot'),
653656
PathOption('--install-destdir'),
654657
EnableOption('--install-all'),
658+
PathOption('--native-clang-tools-path'),
659+
PathOption('--native-llvm-tools-path'),
660+
PathOption('--native-swift-tools-path'),
655661
PathOption('--symbols-package'),
656662
PathOption('--cmake-c-launcher'),
657663
PathOption('--cmake-cxx-launcher'),

utils/swift_build_support/swift_build_support/products/product.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,9 @@ def install_toolchain_path(self, host_target):
169169
Returns the path to the toolchain that is being created as part of this
170170
build.
171171
"""
172+
if self.args.native_swift_tools_path is not None:
173+
return os.path.split(self.args.native_swift_tools_path)[0]
174+
172175
install_destdir = self.args.install_destdir
173176
if self.args.cross_compile_hosts:
174177
build_root = os.path.dirname(self.build_dir)

0 commit comments

Comments
 (0)