Skip to content

Commit b3ea191

Browse files
committed
Support bootstrapping with Xcode
Xcode does not compile libraries that contain only object files; it just skips them completely, not even mentioning them in the logs. Therefore, it fails to create the static library that would contain all SwiftCompilerSources object files. As a workaround, we add a dummy script phase to the target, to force that it gets compiled.
1 parent 78aec29 commit b3ea191

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

SwiftCompilerSources/CMakeLists.txt

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,7 @@ function(add_swift_compiler_modules_library name)
8989
set(sdk_option "")
9090

9191
if(SWIFT_HOST_VARIANT_SDK IN_LIST SWIFT_DARWIN_PLATFORMS)
92-
set(deployment_version "10.15") # TODO: once #38675 lands, replace this with
93-
# set(deployment_version "${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_DEPLOYMENT_VERSION}")
92+
set(deployment_version "${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_DEPLOYMENT_VERSION}")
9493
set(sdk_option "-sdk" "${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_ARCH_${SWIFT_HOST_VARIANT_ARCH}_PATH}")
9594
if(${BOOTSTRAPPING_MODE} STREQUAL "CROSSCOMPILE-WITH-HOSTLIBS")
9695
# Let the cross-compiled compile don't pick up the compiled stdlib by providing
@@ -158,6 +157,15 @@ function(add_swift_compiler_modules_library name)
158157
add_dependencies(${name} ${all_module_targets})
159158
set_target_properties(${name} PROPERTIES LINKER_LANGUAGE CXX)
160159
set_property(GLOBAL APPEND PROPERTY SWIFT_BUILDTREE_EXPORTS ${name})
160+
161+
# Xcode does not compile libraries that contain only object files.
162+
# Therefore, it fails to create the static library. As a workaround,
163+
# we add a dummy script phase to the target.
164+
if (XCODE)
165+
add_custom_command(TARGET ${name} POST_BUILD
166+
COMMAND ""
167+
COMMENT "Dummy script phase to force building this target")
168+
endif()
161169
endfunction()
162170

163171

0 commit comments

Comments
 (0)