@@ -352,17 +352,24 @@ 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
+ set (SWIFT_BUILD_SWIFT_SYNTAX OFF )
372
+ endif ()
366
373
367
374
option (BRIDGING_MODE [=[
368
375
How swift-C++ bridging code is compiled:
@@ -939,41 +946,44 @@ set(SWIFT_MAIN_INCLUDE_DIR "${SWIFT_SOURCE_DIR}/include")
939
946
set (SWIFT_SHIMS_INCLUDE_DIR "${SWIFT_SOURCE_DIR} /stdlib/public/SwiftShims" )
940
947
set (SWIFT_INCLUDE_DIR "${CMAKE_CURRENT_BINARY_DIR} /include" )
941
948
942
- if (NOT BOOTSTRAPPING_MODE)
949
+ if (NOT BOOTSTRAPPING_MODE AND SWIFT_ENABLE_SWIFT_IN_SWIFT )
943
950
message (FATAL_ERROR "turning off bootstrapping is not supported anymore" )
944
951
endif ()
945
952
946
953
set (SWIFT_RUNTIME_OUTPUT_INTDIR "${CMAKE_BINARY_DIR} /${CMAKE_CFG_INTDIR} /bin" )
947
954
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" )
955
+
956
+ if (SWIFT_ENABLE_SWIFT_IN_SWIFT)
957
+ if (NOT SWIFT_NATIVE_SWIFT_TOOLS_PATH)
958
+ # This is the normal case. We are not cross-compiling.
959
+ set (SWIFT_NATIVE_SWIFT_TOOLS_PATH "${SWIFT_RUNTIME_OUTPUT_INTDIR} " )
960
+ set (SWIFT_EXEC_FOR_SWIFT_MODULES "${CMAKE_Swift_COMPILER} " )
961
+ if (NOT SWIFT_EXEC_FOR_SWIFT_MODULES)
962
+ message (WARNING "BOOTSTRAPPING set to OFF because no Swift compiler is defined" )
963
+ set (BOOTSTRAPPING_MODE "OFF" )
964
+ endif ()
965
+ elseif (BOOTSTRAPPING_MODE MATCHES "BOOTSTRAPPING.*" )
966
+ # If cross-compiling, we don't have to bootstrap. We can just use the previously
967
+ # built native swiftc to build the swift compiler modules.
968
+ message (STATUS "Building swift modules with previously built tools instead of bootstrapping" )
969
+ set (SWIFT_EXEC_FOR_SWIFT_MODULES "${SWIFT_NATIVE_SWIFT_TOOLS_PATH} /swiftc" )
970
+ if (BOOTSTRAPPING_MODE STREQUAL "BOOTSTRAPPING-WITH-HOSTLIBS" )
971
+ set (BOOTSTRAPPING_MODE "CROSSCOMPILE-WITH-HOSTLIBS" )
972
+ elseif (BOOTSTRAPPING_MODE STREQUAL "BOOTSTRAPPING" )
973
+ set (BOOTSTRAPPING_MODE "CROSSCOMPILE" )
974
+ else ()
975
+ set (BOOTSTRAPPING_MODE "HOSTTOOLS" )
976
+ endif ()
977
+ elseif (BOOTSTRAPPING_MODE STREQUAL "HOSTTOOLS" OR SWIFT_BUILD_SWIFT_SYNTAX)
978
+ # We are building using a pre-installed host toolchain but not bootstrapping
979
+ # the Swift modules. This happens when building using 'build-tooling-libs'
980
+ # where we haven't built a new Swift compiler. Use the Swift compiler from the
981
+ # pre-installed host toolchain to build the Swift modules.
982
+ set (SWIFT_EXEC_FOR_SWIFT_MODULES "${CMAKE_Swift_COMPILER} " )
967
983
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
984
endif ()
975
985
976
- if (SWIFT_INCLUDE_TOOLS AND SWIFT_BUILD_SWIFT_SYNTAX)
986
+ if (SWIFT_INCLUDE_TOOLS AND SWIFT_BUILD_SWIFT_SYNTAX AND SWIFT_ENABLE_SWIFT_IN_SWIFT )
977
987
# Only "HOSTTOOLS" is supported in Linux when Swift parser integration is enabled.
978
988
if (SWIFT_HOST_VARIANT_SDK MATCHES "LINUX|OPENBSD|FREEBSD" AND NOT BOOTSTRAPPING_MODE STREQUAL "HOSTTOOLS" )
979
989
message (WARNING "Force setting BOOTSTRAPPING=HOSTTOOLS because Swift parser integration is enabled" )
@@ -1530,14 +1540,16 @@ if(SWIFT_INCLUDE_TOOLS)
1530
1540
# https://github.com/apple/swift/issues/48534
1531
1541
add_subdirectory (tools)
1532
1542
1533
- # Localization targets are configured in a way that assume the swift
1534
- # frontend is being built, so trying to include them for other builds
1535
- # (like stdlib) fail!
1536
- #
1537
- # Diagnostics information is only useful for the frontend compiler
1538
- # anyway, so let's only include it if the compiler is being built,
1539
- # which at the moment seems like if SWIFT_INCLUDE_TOOLS is defined.
1540
- add_subdirectory (localization)
1543
+ if (SWIFT_NATIVE_SWIFT_TOOLS_PATH)
1544
+ # Localization targets are configured in a way that assume the swift
1545
+ # frontend is being built, so trying to include them for other builds
1546
+ # (like stdlib) fail!
1547
+ #
1548
+ # Diagnostics information is only useful for the frontend compiler
1549
+ # anyway, so let's only include it if the compiler is being built,
1550
+ # which at the moment seems like if SWIFT_INCLUDE_TOOLS is defined.
1551
+ add_subdirectory (localization)
1552
+ endif ()
1541
1553
endif ()
1542
1554
1543
1555
add_subdirectory (utils)
0 commit comments