File tree Expand file tree Collapse file tree 12 files changed +52
-26
lines changed
swift_build_support/swift_build_support/products Expand file tree Collapse file tree 12 files changed +52
-26
lines changed Original file line number Diff line number Diff line change @@ -481,10 +481,12 @@ if(SWIFT_PATH_TO_CMARK_BUILD)
481
481
endif ()
482
482
message (STATUS "" )
483
483
484
- if ("${SWIFT_NATIVE_LLVM_TOOLS_PATH} " STREQUAL "" )
485
- set (SWIFT_CROSS_COMPILING FALSE )
484
+ # Check if a prebuilt clang path was passed in, as this variable will be
485
+ # assigned if not, in SwiftSharedCMakeConfig.
486
+ if ("${SWIFT_NATIVE_CLANG_TOOLS_PATH} " STREQUAL "" )
487
+ set (SWIFT_PREBUILT_CLANG FALSE )
486
488
else ()
487
- set (SWIFT_CROSS_COMPILING TRUE )
489
+ set (SWIFT_PREBUILT_CLANG TRUE )
488
490
endif ()
489
491
490
492
include (SwiftSharedCMakeConfig )
Original file line number Diff line number Diff line change @@ -58,7 +58,7 @@ macro(swift_common_standalone_build_config_llvm product)
58
58
fix_imported_targets_for_xcode ("${LLVM_EXPORTED_TARGETS} " )
59
59
endif ()
60
60
61
- if (NOT CMAKE_CROSSCOMPILING AND NOT SWIFT_CROSS_COMPILING )
61
+ if (NOT CMAKE_CROSSCOMPILING )
62
62
set (${product} _NATIVE_LLVM_TOOLS_PATH "${LLVM_TOOLS_BINARY_DIR} " )
63
63
endif ()
64
64
@@ -159,7 +159,7 @@ endmacro()
159
159
macro (swift_common_standalone_build_config_clang product )
160
160
find_package (Clang CONFIG REQUIRED NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH )
161
161
162
- if (NOT CMAKE_CROSSCOMPILING )
162
+ if (NOT CMAKE_CROSSCOMPILING AND NOT SWIFT_PREBUILT_CLANG )
163
163
set (${product} _NATIVE_CLANG_TOOLS_PATH "${LLVM_TOOLS_BINARY_DIR} " )
164
164
endif ()
165
165
Original file line number Diff line number Diff line change @@ -112,11 +112,11 @@ else()
112
112
# If we use Clang-cl or MSVC, CMake provides default compiler and linker flags that are incompatible
113
113
# with the frontend of Clang or Clang++.
114
114
if (SWIFT_COMPILER_IS_MSVC_LIKE )
115
- set (CMAKE_CXX_COMPILER "${SWIFT_NATIVE_LLVM_TOOLS_PATH } /clang-cl" )
116
- set (CMAKE_C_COMPILER "${SWIFT_NATIVE_LLVM_TOOLS_PATH } /clang-cl" )
115
+ set (CMAKE_CXX_COMPILER "${SWIFT_NATIVE_CLANG_TOOLS_PATH } /clang-cl" )
116
+ set (CMAKE_C_COMPILER "${SWIFT_NATIVE_CLANG_TOOLS_PATH } /clang-cl" )
117
117
else ()
118
- set (CMAKE_CXX_COMPILER "${SWIFT_NATIVE_LLVM_TOOLS_PATH } /clang++" )
119
- set (CMAKE_C_COMPILER "${SWIFT_NATIVE_LLVM_TOOLS_PATH } /clang" )
118
+ set (CMAKE_CXX_COMPILER "${SWIFT_NATIVE_CLANG_TOOLS_PATH } /clang++" )
119
+ set (CMAKE_C_COMPILER "${SWIFT_NATIVE_CLANG_TOOLS_PATH } /clang" )
120
120
endif ()
121
121
122
122
if (CMAKE_C_COMPILER_LAUNCHER MATCHES ".*distcc" )
Original file line number Diff line number Diff line change @@ -1654,7 +1654,8 @@ function(add_swift_target_library name)
1654
1654
list (APPEND SWIFTLIB_SWIFT_COMPILE_FLAGS "-warn-implicit-overrides" )
1655
1655
endif ()
1656
1656
1657
- if (NOT SWIFT_BUILD_RUNTIME_WITH_HOST_COMPILER AND NOT BUILD_STANDALONE )
1657
+ if (NOT SWIFT_BUILD_RUNTIME_WITH_HOST_COMPILER AND NOT BUILD_STANDALONE AND
1658
+ NOT SWIFT_PREBUILT_CLANG )
1658
1659
list (APPEND SWIFTLIB_DEPENDS clang )
1659
1660
endif ()
1660
1661
Original file line number Diff line number Diff line change @@ -111,7 +111,8 @@ endif()
111
111
# First extract the "version" used for Clang's resource directory.
112
112
string (REGEX MATCH "[0-9]+\\ .[0-9]+(\\ .[0-9]+)?" CLANG_VERSION
113
113
"${LLVM_PACKAGE_VERSION} " )
114
- if (NOT SWIFT_INCLUDE_TOOLS AND SWIFT_BUILD_RUNTIME_WITH_HOST_COMPILER )
114
+ if (NOT SWIFT_INCLUDE_TOOLS AND
115
+ (SWIFT_BUILD_RUNTIME_WITH_HOST_COMPILER OR SWIFT_PREBUILT_CLANG ))
115
116
if (SWIFT_COMPILER_IS_MSVC_LIKE )
116
117
execute_process (COMMAND ${CMAKE_C_COMPILER} /clang:-print-resource-dir
117
118
OUTPUT_VARIABLE clang_headers_location
Original file line number Diff line number Diff line change @@ -13,11 +13,11 @@ if(("${SWIFT_HOST_VARIANT_SDK}" STREQUAL "${SWIFT_PRIMARY_VARIANT_SDK}") AND
13
13
# If we use Clang-cl or MSVC, CMake provides default compiler and linker flags that are incompatible
14
14
# with the frontend of Clang or Clang++.
15
15
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" )
18
18
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" )
21
21
endif ()
22
22
23
23
if (CMAKE_C_COMPILER_LAUNCHER MATCHES ".*distcc" )
Original file line number Diff line number Diff line change @@ -2283,10 +2283,9 @@ skip-build-cmark
2283
2283
skip-build-benchmarks
2284
2284
skip-test-cmark
2285
2285
2286
- # This triggers the stdlib standalone build: Don 't build tools ( the compiler),
2287
- # assume we are working with the host compiler.
2286
+ # This triggers the stdlib standalone build: don 't build the native tools from
2287
+ # scratch, ie the compiler.
2288
2288
build-swift-tools =0
2289
- build-runtime-with-host-compiler =1
2290
2289
2291
2290
# Then set the paths to our native tools. If compiling against a toolchain,
2292
2291
# these should all be the ./usr/bin directory.
Original file line number Diff line number Diff line change @@ -708,6 +708,18 @@ class BuildScriptInvocation(object):
708
708
impl_args += [
709
709
"--host-libtool" , toolchain .libtool ,
710
710
]
711
+ if args .native_clang_tools_path is not None :
712
+ impl_args += [
713
+ "--native-clang-tools-path=%s" % args .native_clang_tools_path
714
+ ]
715
+ if args .native_llvm_tools_path is not None :
716
+ impl_args += [
717
+ "--native-llvm-tools-path=%s" % args .native_llvm_tools_path
718
+ ]
719
+ if args .native_swift_tools_path is not None :
720
+ impl_args += [
721
+ "--native-swift-tools-path=%s" % args .native_swift_tools_path
722
+ ]
711
723
712
724
# If we have extra_swift_args, combine all of them together and then
713
725
# add them as one command.
Original file line number Diff line number Diff line change @@ -1485,13 +1485,6 @@ for host in "${ALL_HOSTS[@]}"; do
1485
1485
fi
1486
1486
fi
1487
1487
1488
- if [[ " ${NATIVE_CLANG_TOOLS_PATH} " ]] ; then
1489
- common_cmake_options_host+=(
1490
- -DCMAKE_C_COMPILER=" ${NATIVE_CLANG_TOOLS_PATH} /clang"
1491
- -DCMAKE_CXX_COMPILER=" ${NATIVE_CLANG_TOOLS_PATH} /clang++"
1492
- )
1493
- fi
1494
-
1495
1488
llvm_cmake_options=(
1496
1489
" ${llvm_cmake_options[@]} "
1497
1490
-DCMAKE_INSTALL_PREFIX:PATH=" $( get_host_install_prefix ${host} ) "
Original file line number Diff line number Diff line change @@ -374,6 +374,15 @@ def create_argument_parser():
374
374
option ('--host-cxx' , store_path (executable = True ),
375
375
help = 'the absolute path to CXX, the "clang++" compiler for the '
376
376
'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' )
377
386
option ('--cmake-c-launcher' , store_path (executable = True ),
378
387
default = os .environ .get ('C_COMPILER_LAUNCHER' , None ),
379
388
help = 'the absolute path to set CMAKE_C_COMPILER_LAUNCHER' )
You can’t perform that action at this time.
0 commit comments