@@ -352,17 +352,23 @@ option(SWIFT_TOOLS_LD64_LTO_CODEGEN_ONLY_FOR_SUPPORTING_TARGETS
352
352
debugging Swift)"
353
353
FALSE )
354
354
355
- set (BOOTSTRAPPING_MODE HOSTTOOLS CACHE STRING [=[
356
- How to build the swift compiler modules. Possible values are
357
- HOSTTOOLS: build with a pre-installed toolchain
358
- BOOTSTRAPPING: build with a 2-stage bootstrapping process
359
- BOOTSTRAPPING-WITH-HOSTLIBS: build with a 2-stage bootstrapping process,
360
- but the compiler links against the host system swift libs (macOS only)
361
- CROSSCOMPILE: cross-compiledwith a native host compiler, provided in
362
- `SWIFT_NATIVE_SWIFT_TOOLS_PATH` (non-Darwin only)
363
- CROSSCOMPILE-WITH-HOSTLIBS: build with a bootstrapping-with-hostlibs compiled
364
- compiler, provided in `SWIFT_NATIVE_SWIFT_TOOLS_PATH`
365
- ]=])
355
+ option (SWIFT_ENABLE_SWIFT_IN_SWIFT "Enable Swift sources in Swift compiler" ON )
356
+
357
+ if (SWIFT_ENABLE_SWIFT_IN_SWIFT)
358
+ set (BOOTSTRAPPING_MODE HOSTTOOLS CACHE STRING [=[
359
+ How to build the swift compiler modules. Possible values are
360
+ HOSTTOOLS: build with a pre-installed toolchain
361
+ BOOTSTRAPPING: build with a 2-stage bootstrapping process
362
+ BOOTSTRAPPING-WITH-HOSTLIBS: build with a 2-stage bootstrapping process,
363
+ but the compiler links against the host system swift libs (macOS only)
364
+ CROSSCOMPILE: cross-compiledwith a native host compiler, provided in
365
+ `SWIFT_NATIVE_SWIFT_TOOLS_PATH` (non-Darwin only)
366
+ CROSSCOMPILE-WITH-HOSTLIBS: build with a bootstrapping-with-hostlibs compiled
367
+ compiler, provided in `SWIFT_NATIVE_SWIFT_TOOLS_PATH`
368
+ ]=])
369
+ else ()
370
+ set (BOOTSTRAPPING_MODE OFF )
371
+ endif ()
366
372
367
373
option (BRIDGING_MODE [=[
368
374
How swift-C++ bridging code is compiled:
@@ -939,41 +945,44 @@ set(SWIFT_MAIN_INCLUDE_DIR "${SWIFT_SOURCE_DIR}/include")
939
945
set (SWIFT_SHIMS_INCLUDE_DIR "${SWIFT_SOURCE_DIR} /stdlib/public/SwiftShims" )
940
946
set (SWIFT_INCLUDE_DIR "${CMAKE_CURRENT_BINARY_DIR} /include" )
941
947
942
- if (NOT BOOTSTRAPPING_MODE)
948
+ if (NOT BOOTSTRAPPING_MODE AND SWIFT_ENABLE_SWIFT_IN_SWIFT )
943
949
message (FATAL_ERROR "turning off bootstrapping is not supported anymore" )
944
950
endif ()
945
951
946
952
set (SWIFT_RUNTIME_OUTPUT_INTDIR "${CMAKE_BINARY_DIR} /${CMAKE_CFG_INTDIR} /bin" )
947
953
set (SWIFT_LIBRARY_OUTPUT_INTDIR "${CMAKE_BINARY_DIR} /${CMAKE_CFG_INTDIR} /lib" )
948
- if ("${SWIFT_NATIVE_SWIFT_TOOLS_PATH} " STREQUAL "" )
949
- # This is the normal case. We are not cross-compiling.
950
- set (SWIFT_NATIVE_SWIFT_TOOLS_PATH "${SWIFT_RUNTIME_OUTPUT_INTDIR} " )
951
- set (SWIFT_EXEC_FOR_SWIFT_MODULES "${CMAKE_Swift_COMPILER} " )
952
- if (NOT SWIFT_EXEC_FOR_SWIFT_MODULES)
953
- message (WARNING "BOOTSTRAPPING set to OFF because no Swift compiler is defined" )
954
- set (BOOTSTRAPPING_MODE "OFF" )
955
- endif ()
956
- elseif (BOOTSTRAPPING_MODE MATCHES "BOOTSTRAPPING.*" )
957
- # If cross-compiling, we don't have to bootstrap. We can just use the previously
958
- # built native swiftc to build the swift compiler modules.
959
- message (STATUS "Building swift modules with previously built tools instead of bootstrapping" )
960
- set (SWIFT_EXEC_FOR_SWIFT_MODULES "${SWIFT_NATIVE_SWIFT_TOOLS_PATH} /swiftc" )
961
- if (BOOTSTRAPPING_MODE STREQUAL "BOOTSTRAPPING-WITH-HOSTLIBS" )
962
- set (BOOTSTRAPPING_MODE "CROSSCOMPILE-WITH-HOSTLIBS" )
963
- elseif (BOOTSTRAPPING_MODE STREQUAL "BOOTSTRAPPING" )
964
- set (BOOTSTRAPPING_MODE "CROSSCOMPILE" )
965
- else ()
966
- set (BOOTSTRAPPING_MODE "HOSTTOOLS" )
954
+
955
+ if (SWIFT_ENABLE_SWIFT_IN_SWIFT)
956
+ if ("${SWIFT_NATIVE_SWIFT_TOOLS_PATH} " STREQUAL "" )
957
+ # This is the normal case. We are not cross-compiling.
958
+ set (SWIFT_NATIVE_SWIFT_TOOLS_PATH "${SWIFT_RUNTIME_OUTPUT_INTDIR} " )
959
+ set (SWIFT_EXEC_FOR_SWIFT_MODULES "${CMAKE_Swift_COMPILER} " )
960
+ if (NOT SWIFT_EXEC_FOR_SWIFT_MODULES)
961
+ message (WARNING "BOOTSTRAPPING set to OFF because no Swift compiler is defined" )
962
+ set (BOOTSTRAPPING_MODE "OFF" )
963
+ endif ()
964
+ elseif (BOOTSTRAPPING_MODE MATCHES "BOOTSTRAPPING.*" )
965
+ # If cross-compiling, we don't have to bootstrap. We can just use the previously
966
+ # built native swiftc to build the swift compiler modules.
967
+ message (STATUS "Building swift modules with previously built tools instead of bootstrapping" )
968
+ set (SWIFT_EXEC_FOR_SWIFT_MODULES "${SWIFT_NATIVE_SWIFT_TOOLS_PATH} /swiftc" )
969
+ if (BOOTSTRAPPING_MODE STREQUAL "BOOTSTRAPPING-WITH-HOSTLIBS" )
970
+ set (BOOTSTRAPPING_MODE "CROSSCOMPILE-WITH-HOSTLIBS" )
971
+ elseif (BOOTSTRAPPING_MODE STREQUAL "BOOTSTRAPPING" )
972
+ set (BOOTSTRAPPING_MODE "CROSSCOMPILE" )
973
+ else ()
974
+ set (BOOTSTRAPPING_MODE "HOSTTOOLS" )
975
+ endif ()
976
+ elseif (BOOTSTRAPPING_MODE STREQUAL "HOSTTOOLS" OR SWIFT_BUILD_SWIFT_SYNTAX)
977
+ # We are building using a pre-installed host toolchain but not bootstrapping
978
+ # the Swift modules. This happens when building using 'build-tooling-libs'
979
+ # where we haven't built a new Swift compiler. Use the Swift compiler from the
980
+ # pre-installed host toolchain to build the Swift modules.
981
+ set (SWIFT_EXEC_FOR_SWIFT_MODULES "${CMAKE_Swift_COMPILER} " )
967
982
endif ()
968
- elseif (BOOTSTRAPPING_MODE STREQUAL "HOSTTOOLS" OR SWIFT_BUILD_SWIFT_SYNTAX)
969
- # We are building using a pre-installed host toolchain but not bootstrapping
970
- # the Swift modules. This happens when building using 'build-tooling-libs'
971
- # where we haven't built a new Swift compiler. Use the Swift compiler from the
972
- # pre-installed host toolchain to build the Swift modules.
973
- set (SWIFT_EXEC_FOR_SWIFT_MODULES "${CMAKE_Swift_COMPILER} " )
974
983
endif ()
975
984
976
- if (SWIFT_INCLUDE_TOOLS AND SWIFT_BUILD_SWIFT_SYNTAX)
985
+ if (SWIFT_INCLUDE_TOOLS AND SWIFT_BUILD_SWIFT_SYNTAX AND SWIFT_ENABLE_SWIFT_IN_SWIFT )
977
986
# Only "HOSTTOOLS" is supported in Linux when Swift parser integration is enabled.
978
987
if (SWIFT_HOST_VARIANT_SDK MATCHES "LINUX|OPENBSD|FREEBSD" AND NOT BOOTSTRAPPING_MODE STREQUAL "HOSTTOOLS" )
979
988
message (WARNING "Force setting BOOTSTRAPPING=HOSTTOOLS because Swift parser integration is enabled" )
0 commit comments