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)
481481endif ()
482482message (STATUS "" )
483483
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 )
486488else ()
487- set (SWIFT_CROSS_COMPILING TRUE )
489+ set (SWIFT_PREBUILT_CLANG TRUE )
488490endif ()
489491
490492include (SwiftSharedCMakeConfig)
Original file line number Diff line number Diff line change @@ -58,7 +58,7 @@ macro(swift_common_standalone_build_config_llvm product)
5858 fix_imported_targets_for_xcode("${LLVM_EXPORTED_TARGETS} " )
5959 endif ()
6060
61- if (NOT CMAKE_CROSSCOMPILING AND NOT SWIFT_CROSS_COMPILING )
61+ if (NOT CMAKE_CROSSCOMPILING )
6262 set (${product} _NATIVE_LLVM_TOOLS_PATH "${LLVM_TOOLS_BINARY_DIR} " )
6363 endif ()
6464
@@ -159,7 +159,7 @@ endmacro()
159159macro (swift_common_standalone_build_config_clang product)
160160 find_package (Clang CONFIG REQUIRED NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH )
161161
162- if (NOT CMAKE_CROSSCOMPILING )
162+ if (NOT CMAKE_CROSSCOMPILING AND NOT SWIFT_PREBUILT_CLANG )
163163 set (${product} _NATIVE_CLANG_TOOLS_PATH "${LLVM_TOOLS_BINARY_DIR} " )
164164 endif ()
165165
Original file line number Diff line number Diff line change @@ -112,11 +112,11 @@ else()
112112 # If we use Clang-cl or MSVC, CMake provides default compiler and linker flags that are incompatible
113113 # with the frontend of Clang or Clang++.
114114 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" )
117117 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" )
120120 endif ()
121121
122122 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)
16541654 list (APPEND SWIFTLIB_SWIFT_COMPILE_FLAGS "-warn-implicit-overrides" )
16551655 endif ()
16561656
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)
16581659 list (APPEND SWIFTLIB_DEPENDS clang)
16591660 endif ()
16601661
Original file line number Diff line number Diff line change @@ -111,7 +111,8 @@ endif()
111111# First extract the "version" used for Clang's resource directory.
112112string (REGEX MATCH "[0-9]+\\ .[0-9]+(\\ .[0-9]+)?" CLANG_VERSION
113113 "${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))
115116 if (SWIFT_COMPILER_IS_MSVC_LIKE)
116117 execute_process (COMMAND ${CMAKE_C_COMPILER} /clang:-print-resource -dir
117118 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
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" )
Original file line number Diff line number Diff line change @@ -2283,10 +2283,9 @@ skip-build-cmark
22832283skip-build-benchmarks
22842284skip-test-cmark
22852285
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.
22882288build-swift-tools =0
2289- build-runtime-with-host-compiler =1
22902289
22912290# Then set the paths to our native tools. If compiling against a toolchain,
22922291# 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):
708708 impl_args += [
709709 "--host-libtool" , toolchain .libtool ,
710710 ]
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+ ]
711723
712724 # If we have extra_swift_args, combine all of them together and then
713725 # 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
14851485 fi
14861486 fi
14871487
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-
14951488 llvm_cmake_options=(
14961489 " ${llvm_cmake_options[@]} "
14971490 -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():
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' )
You can’t perform that action at this time.
0 commit comments