Skip to content

Commit b247c6d

Browse files
committed
Enable build of Swift Swift parser even when bootstrapping is OFF.
The Swift Swift parser doesn't require any bootstrapping, so allow it to be built even when bootstrapping is off.
1 parent 965a966 commit b247c6d

File tree

3 files changed

+43
-26
lines changed

3 files changed

+43
-26
lines changed

CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -755,7 +755,7 @@ elseif(BOOTSTRAPPING_MODE MATCHES "BOOTSTRAPPING.*")
755755
else()
756756
set(BOOTSTRAPPING_MODE "HOSTTOOLS")
757757
endif()
758-
elseif(BOOTSTRAPPING_MODE STREQUAL "HOSTTOOLS")
758+
elseif(BOOTSTRAPPING_MODE STREQUAL "HOSTTOOLS" OR SWIFT_SWIFT_PARSER)
759759
# We are building using a pre-installed host toolchain but not bootstrapping
760760
# the Swift modules. This happens when building using 'build-tooling-libs'
761761
# where we haven't built a new Swift compiler. Use the Swift compiler from the
@@ -1091,6 +1091,7 @@ if(SWIFT_INCLUDE_TOOLS)
10911091
message(STATUS " Assertions: ${LLVM_ENABLE_ASSERTIONS}")
10921092
message(STATUS " LTO: ${SWIFT_TOOLS_ENABLE_LTO}")
10931093
message(STATUS " Bootstrapping: ${BOOTSTRAPPING_MODE}")
1094+
message(STATUS " Swift parser: ${SWIFT_SWIFT_PARSER_MODE}")
10941095
message(STATUS "")
10951096
else()
10961097
message(STATUS "Not building host Swift tools")

cmake/modules/AddSwift.cmake

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,13 @@ endfunction()
435435
436436
function(_add_swift_runtime_link_flags target relpath_to_lib_dir bootstrapping)
437437
if(NOT BOOTSTRAPPING_MODE)
438-
return()
438+
if (SWIFT_SWIFT_PARSER)
439+
set(ASRLF_BOOTSTRAPPING_MODE "HOSTTOOLS")
440+
else()
441+
return()
442+
endif()
443+
else()
444+
set(ASRLF_BOOTSTRAPPING_MODE ${BOOTSTRAPPING_MODE})
439445
endif()
440446
441447
# RPATH where Swift runtime can be found.
@@ -448,7 +454,7 @@ function(_add_swift_runtime_link_flags target relpath_to_lib_dir bootstrapping)
448454
# If we found a swift compiler and are going to use swift code in swift
449455
# host side tools but link with clang, add the appropriate -L paths so we
450456
# find all of the necessary swift libraries on Darwin.
451-
if(BOOTSTRAPPING_MODE STREQUAL "HOSTTOOLS")
457+
if(ASRLF_BOOTSTRAPPING_MODE STREQUAL "HOSTTOOLS")
452458
# Add in the toolchain directory so we can grab compatibility libraries
453459
get_filename_component(TOOLCHAIN_BIN_DIR ${SWIFT_EXEC_FOR_SWIFT_MODULES} DIRECTORY)
454460
get_filename_component(TOOLCHAIN_LIB_DIR "${TOOLCHAIN_BIN_DIR}/../lib/swift/${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_LIB_SUBDIR}" ABSOLUTE)
@@ -460,7 +466,7 @@ function(_add_swift_runtime_link_flags target relpath_to_lib_dir bootstrapping)
460466
# Include the abi stable system stdlib in our rpath.
461467
set(swift_runtime_rpath "/usr/lib/swift")
462468
463-
elseif(BOOTSTRAPPING_MODE STREQUAL "CROSSCOMPILE-WITH-HOSTLIBS")
469+
elseif(ASRLF_BOOTSTRAPPING_MODE STREQUAL "CROSSCOMPILE-WITH-HOSTLIBS")
464470
465471
# Intentionally don't add the lib dir of the cross-compiled compiler, so that
466472
# the stdlib is not picked up from there, but from the SDK.
@@ -478,7 +484,7 @@ function(_add_swift_runtime_link_flags target relpath_to_lib_dir bootstrapping)
478484
# Include the abi stable system stdlib in our rpath.
479485
set(swift_runtime_rpath "/usr/lib/swift")
480486
481-
elseif(BOOTSTRAPPING_MODE STREQUAL "BOOTSTRAPPING-WITH-HOSTLIBS")
487+
elseif(ASRLF_BOOTSTRAPPING_MODE STREQUAL "BOOTSTRAPPING-WITH-HOSTLIBS")
482488
# Add the SDK directory for the host platform.
483489
target_link_directories(${target} PRIVATE "${sdk_dir}")
484490
@@ -489,7 +495,7 @@ function(_add_swift_runtime_link_flags target relpath_to_lib_dir bootstrapping)
489495
# Include the abi stable system stdlib in our rpath.
490496
set(swift_runtime_rpath "/usr/lib/swift")
491497
492-
elseif(BOOTSTRAPPING_MODE STREQUAL "BOOTSTRAPPING")
498+
elseif(ASRLF_BOOTSTRAPPING_MODE STREQUAL "BOOTSTRAPPING")
493499
# At build time link against the built swift libraries from the
494500
# previous bootstrapping stage.
495501
get_bootstrapping_swift_lib_dir(bs_lib_dir "${bootstrapping}")
@@ -503,7 +509,7 @@ function(_add_swift_runtime_link_flags target relpath_to_lib_dir bootstrapping)
503509
# bootstrapping stage.
504510
set(swift_runtime_rpath "@loader_path/${relpath_to_lib_dir}/swift/${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_LIB_SUBDIR}")
505511
else()
506-
message(FATAL_ERROR "Unknown BOOTSTRAPPING_MODE '${BOOTSTRAPPING_MODE}'")
512+
message(FATAL_ERROR "Unknown BOOTSTRAPPING_MODE '${ASRLF_BOOTSTRAPPING_MODE}'")
507513
endif()
508514
509515
# Workaround to make lldb happy: we have to explicitly add all swift compiler modules
@@ -524,7 +530,7 @@ function(_add_swift_runtime_link_flags target relpath_to_lib_dir bootstrapping)
524530
525531
elseif(SWIFT_HOST_VARIANT_SDK MATCHES "LINUX|ANDROID|OPENBSD")
526532
set(swiftrt "swiftImageRegistrationObject${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_OBJECT_FORMAT}-${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_LIB_SUBDIR}-${SWIFT_HOST_VARIANT_ARCH}")
527-
if(${BOOTSTRAPPING_MODE} MATCHES "HOSTTOOLS|CROSSCOMPILE")
533+
if(${ASRLF_BOOTSTRAPPING_MODE} MATCHES "HOSTTOOLS|CROSSCOMPILE")
528534
# At build time and run time, link against the swift libraries in the
529535
# installed host toolchain.
530536
get_filename_component(swift_bin_dir ${SWIFT_EXEC_FOR_SWIFT_MODULES} DIRECTORY)
@@ -535,13 +541,13 @@ function(_add_swift_runtime_link_flags target relpath_to_lib_dir bootstrapping)
535541
target_link_libraries(${target} PRIVATE "swiftCore")
536542
537543
target_link_directories(${target} PRIVATE ${host_lib_dir})
538-
if(BOOTSTRAPPING_MODE STREQUAL "HOSTTOOLS")
544+
if(ASRLF_BOOTSTRAPPING_MODE STREQUAL "HOSTTOOLS")
539545
set(swift_runtime_rpath "${host_lib_dir}")
540546
else()
541547
set(swift_runtime_rpath "$ORIGIN/${relpath_to_lib_dir}/swift/${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_LIB_SUBDIR}")
542548
endif()
543549
544-
elseif(BOOTSTRAPPING_MODE STREQUAL "BOOTSTRAPPING")
550+
elseif(ASRLF_BOOTSTRAPPING_MODE STREQUAL "BOOTSTRAPPING")
545551
# At build time link against the built swift libraries from the
546552
# previous bootstrapping stage.
547553
if (NOT "${bootstrapping}" STREQUAL "0")
@@ -555,10 +561,10 @@ function(_add_swift_runtime_link_flags target relpath_to_lib_dir bootstrapping)
555561
# bootstrapping stage.
556562
set(swift_runtime_rpath "$ORIGIN/${relpath_to_lib_dir}/swift/${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_LIB_SUBDIR}")
557563
558-
elseif(BOOTSTRAPPING_MODE STREQUAL "BOOTSTRAPPING-WITH-HOSTLIBS")
564+
elseif(ASRLF_BOOTSTRAPPING_MODE STREQUAL "BOOTSTRAPPING-WITH-HOSTLIBS")
559565
message(FATAL_ERROR "BOOTSTRAPPING_MODE 'BOOTSTRAPPING-WITH-HOSTLIBS' not supported on Linux")
560566
else()
561-
message(FATAL_ERROR "Unknown BOOTSTRAPPING_MODE '${BOOTSTRAPPING_MODE}'")
567+
message(FATAL_ERROR "Unknown BOOTSTRAPPING_MODE '${ASRLF_BOOTSTRAPPING_MODE}'")
562568
endif()
563569
endif()
564570

tools/SourceKit/cmake/modules/AddSwiftSourceKit.cmake

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,16 @@ endfunction()
2020

2121
function(add_sourcekitd_swifrt_linking target path HAS_SWIFT_MODULES)
2222
set(RPATH_LIST)
23+
24+
# If we are linking in the Swift Swift parser, we at least need host tools
25+
# to do it.
26+
set(ASKD_BOOTSTRAPPING_MODE ${BOOTSTRAPPING_MODE})
27+
if (NOT ASKD_BOOTSTRAPPING_MODE)
28+
if (SWIFT_SWIFT_PARSER)
29+
set(ASKD_BOOTSTRAPPING_MODE HOSTTOOLS)
30+
endif()
31+
endif()
32+
2333
if(${SWIFT_HOST_VARIANT_SDK} IN_LIST SWIFT_DARWIN_PLATFORMS)
2434

2535
# Lists of rpaths that we are going to add to our executables.
@@ -31,9 +41,9 @@ function(add_sourcekitd_swifrt_linking target path HAS_SWIFT_MODULES)
3141
# If we found a swift compiler and are going to use swift code in swift
3242
# host side tools but link with clang, add the appropriate -L paths so we
3343
# find all of the necessary swift libraries on Darwin.
34-
if (HAS_SWIFT_MODULES AND BOOTSTRAPPING_MODE)
44+
if (HAS_SWIFT_MODULES AND ASKD_BOOTSTRAPPING_MODE)
3545

36-
if(BOOTSTRAPPING_MODE STREQUAL "HOSTTOOLS")
46+
if(ASKD_BOOTSTRAPPING_MODE STREQUAL "HOSTTOOLS")
3747
# Add in the toolchain directory so we can grab compatibility libraries
3848
get_filename_component(TOOLCHAIN_BIN_DIR ${SWIFT_EXEC_FOR_SWIFT_MODULES} DIRECTORY)
3949
get_filename_component(TOOLCHAIN_LIB_DIR "${TOOLCHAIN_BIN_DIR}/../lib/swift/macosx" ABSOLUTE)
@@ -45,7 +55,7 @@ function(add_sourcekitd_swifrt_linking target path HAS_SWIFT_MODULES)
4555
# Include the abi stable system stdlib in our rpath.
4656
list(APPEND RPATH_LIST "/usr/lib/swift")
4757

48-
elseif(BOOTSTRAPPING_MODE STREQUAL "CROSSCOMPILE-WITH-HOSTLIBS")
58+
elseif(ASKD_BOOTSTRAPPING_MODE STREQUAL "CROSSCOMPILE-WITH-HOSTLIBS")
4959

5060
# Intentinally don't add the lib dir of the cross-compiled compiler, so that
5161
# the stdlib is not picked up from there, but from the SDK.
@@ -59,7 +69,7 @@ function(add_sourcekitd_swifrt_linking target path HAS_SWIFT_MODULES)
5969
# Include the abi stable system stdlib in our rpath.
6070
list(APPEND RPATH_LIST "/usr/lib/swift")
6171

62-
elseif(BOOTSTRAPPING_MODE STREQUAL "BOOTSTRAPPING-WITH-HOSTLIBS")
72+
elseif(ASKD_BOOTSTRAPPING_MODE STREQUAL "BOOTSTRAPPING-WITH-HOSTLIBS")
6373
# Add the SDK directory for the host platform.
6474
target_link_directories(${target} PRIVATE "${sdk_dir}")
6575

@@ -70,7 +80,7 @@ function(add_sourcekitd_swifrt_linking target path HAS_SWIFT_MODULES)
7080
# Include the abi stable system stdlib in our rpath.
7181
list(APPEND RPATH_LIST "/usr/lib/swift")
7282

73-
elseif(BOOTSTRAPPING_MODE STREQUAL "BOOTSTRAPPING")
83+
elseif(ASKD_BOOTSTRAPPING_MODE STREQUAL "BOOTSTRAPPING")
7484
# At build time link against the built swift libraries from the
7585
# previous bootstrapping stage.
7686
get_bootstrapping_swift_lib_dir(bs_lib_dir "")
@@ -85,7 +95,7 @@ function(add_sourcekitd_swifrt_linking target path HAS_SWIFT_MODULES)
8595
file(RELATIVE_PATH relative_rtlib_path "${path}" "${SWIFTLIB_DIR}/${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_LIB_SUBDIR}")
8696
list(APPEND RPATH_LIST "@loader_path/${relative_rtlib_path}")
8797
else()
88-
message(FATAL_ERROR "Unknown BOOTSTRAPPING_MODE '${BOOTSTRAPPING_MODE}'")
98+
message(FATAL_ERROR "Unknown ASKD_BOOTSTRAPPING_MODE '${ASKD_BOOTSTRAPPING_MODE}'")
8999
endif()
90100

91101
# Workaround to make lldb happy: we have to explicitly add all swift compiler modules
@@ -104,11 +114,11 @@ function(add_sourcekitd_swifrt_linking target path HAS_SWIFT_MODULES)
104114
set_property(TARGET ${target} APPEND_STRING PROPERTY
105115
LINK_FLAGS " -lobjc ")
106116

107-
endif() # HAS_SWIFT_MODULES AND BOOTSTRAPPING_MODE
117+
endif() # HAS_SWIFT_MODULES AND ASKD_BOOTSTRAPPING_MODE
108118

109-
elseif(SWIFT_HOST_VARIANT_SDK MATCHES "LINUX|ANDROID|OPENBSD" AND HAS_SWIFT_MODULES AND BOOTSTRAPPING_MODE)
119+
elseif(SWIFT_HOST_VARIANT_SDK MATCHES "LINUX|ANDROID|OPENBSD" AND HAS_SWIFT_MODULES AND ASKD_BOOTSTRAPPING_MODE)
110120
set(swiftrt "swiftImageRegistrationObject${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_OBJECT_FORMAT}-${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_LIB_SUBDIR}-${SWIFT_HOST_VARIANT_ARCH}")
111-
if(${BOOTSTRAPPING_MODE} MATCHES "HOSTTOOLS|CROSSCOMPILE")
121+
if(${ASKD_BOOTSTRAPPING_MODE} MATCHES "HOSTTOOLS|CROSSCOMPILE")
112122
# At build time and and run time, link against the swift libraries in the
113123
# installed host toolchain.
114124
get_filename_component(swift_bin_dir ${SWIFT_EXEC_FOR_SWIFT_MODULES} DIRECTORY)
@@ -119,14 +129,14 @@ function(add_sourcekitd_swifrt_linking target path HAS_SWIFT_MODULES)
119129
target_link_libraries(${target} PRIVATE "swiftCore")
120130

121131
target_link_directories(${target} PRIVATE ${host_lib_dir})
122-
if(BOOTSTRAPPING_MODE STREQUAL "HOSTTOOLS")
132+
if(ASKD_BOOTSTRAPPING_MODE STREQUAL "HOSTTOOLS")
123133
list(APPEND RPATH_LIST "${host_lib_dir}")
124134
else()
125135
file(RELATIVE_PATH relative_rtlib_path "${path}" "${SWIFTLIB_DIR}/${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_LIB_SUBDIR}")
126136
list(APPEND RPATH_LIST "$ORIGIN/${relative_rtlib_path}")
127137
endif()
128138

129-
elseif(BOOTSTRAPPING_MODE STREQUAL "BOOTSTRAPPING")
139+
elseif(ASKD_BOOTSTRAPPING_MODE STREQUAL "BOOTSTRAPPING")
130140
get_bootstrapping_swift_lib_dir(bs_lib_dir "")
131141
target_link_directories(${target} PRIVATE ${bs_lib_dir})
132142
target_link_libraries(${target} PRIVATE ${swiftrt})
@@ -137,10 +147,10 @@ function(add_sourcekitd_swifrt_linking target path HAS_SWIFT_MODULES)
137147
file(RELATIVE_PATH relative_rtlib_path "${path}" "${SWIFTLIB_DIR}/${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_LIB_SUBDIR}")
138148
list(APPEND RPATH_LIST "$ORIGIN/${relative_rtlib_path}")
139149

140-
elseif(BOOTSTRAPPING_MODE STREQUAL "BOOTSTRAPPING-WITH-HOSTLIBS")
141-
message(FATAL_ERROR "BOOTSTRAPPING_MODE 'BOOTSTRAPPING-WITH-HOSTLIBS' not supported on Linux")
150+
elseif(ASKD_BOOTSTRAPPING_MODE STREQUAL "BOOTSTRAPPING-WITH-HOSTLIBS")
151+
message(FATAL_ERROR "ASKD_BOOTSTRAPPING_MODE 'BOOTSTRAPPING-WITH-HOSTLIBS' not supported on Linux")
142152
else()
143-
message(FATAL_ERROR "Unknown BOOTSTRAPPING_MODE '${BOOTSTRAPPING_MODE}'")
153+
message(FATAL_ERROR "Unknown ASKD_BOOTSTRAPPING_MODE '${ASKD_BOOTSTRAPPING_MODE}'")
144154
endif()
145155
endif()
146156
set(RPATH_LIST ${RPATH_LIST} PARENT_SCOPE)

0 commit comments

Comments
 (0)