Skip to content

Commit 18407d8

Browse files
authored
Merge pull request #40838 from cbjeukendrup/try_fix_xcode_bootstrapping_build
Support bootstrapping with Xcode
2 parents 0e9edff + 5ad98aa commit 18407d8

File tree

3 files changed

+14
-9
lines changed

3 files changed

+14
-9
lines changed

CMakeLists.txt

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,7 @@ set(SWIFT_TOOLS_ENABLE_LTO OFF CACHE STRING "Build Swift tools with LTO. One
192192
option only affects the tools that run on the host (the compiler), and has
193193
no effect on the target libraries (the standard library and the runtime).")
194194

195-
# NOTE: We do not currently support building the swift compiler modules with the Xcode generator.
196-
cmake_dependent_option(BOOTSTRAPPING_MODE [=[
195+
option(BOOTSTRAPPING_MODE [=[
197196
How to build the swift compiler modules. Possible values are
198197
OFF: build without swift modules
199198
HOSTTOOLS: build with a pre-installed toolchain
@@ -204,7 +203,7 @@ How to build the swift compiler modules. Possible values are
204203
`SWIFT_NATIVE_SWIFT_TOOLS_PATH` (non-Darwin only)
205204
CROSSCOMPILE-WITH-HOSTLIBS: build with a bootstrapping-with-hostlibs compiled
206205
compiler, provided in `SWIFT_NATIVE_SWIFT_TOOLS_PATH`
207-
]=] OFF "NOT XCODE" OFF)
206+
]=] OFF)
208207

209208
# The following only works with the Ninja generator in CMake >= 3.0.
210209
set(SWIFT_PARALLEL_LINK_JOBS "" CACHE STRING
@@ -1110,8 +1109,6 @@ if(SWIFT_INCLUDE_TOOLS)
11101109
# SwiftCompilerSources must come before "tools".
11111110
# It adds swift module names to the global property "swift_compiler_modules"
11121111
# which is used in add_swift_host_tool for the lldb workaround.
1113-
#
1114-
# NOTE: We do not currently support SwiftCompilerSources with the Xcode generator.
11151112
add_subdirectory(SwiftCompilerSources)
11161113

11171114
# Always include this after including stdlib/!

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

tools/driver/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ if(${BOOTSTRAPPING_MODE} MATCHES "BOOTSTRAPPING.*")
1919
swift_create_post_build_symlink(swift-frontend-bootstrapping0
2020
SOURCE "swift-frontend${CMAKE_EXECUTABLE_SUFFIX}"
2121
DESTINATION "swiftc${CMAKE_EXECUTABLE_SUFFIX}"
22-
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/bootstrapping0/bin")
22+
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/bootstrapping0/${CMAKE_CFG_INTDIR}/bin")
2323

2424
# Bootstrapping - level 1
2525

@@ -37,7 +37,7 @@ if(${BOOTSTRAPPING_MODE} MATCHES "BOOTSTRAPPING.*")
3737
swift_create_post_build_symlink(swift-frontend-bootstrapping1
3838
SOURCE "swift-frontend${CMAKE_EXECUTABLE_SUFFIX}"
3939
DESTINATION "swiftc${CMAKE_EXECUTABLE_SUFFIX}"
40-
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/bootstrapping1/bin")
40+
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/bootstrapping1/${CMAKE_CFG_INTDIR}/bin")
4141
endif()
4242

4343
add_swift_host_tool(swift-frontend

0 commit comments

Comments
 (0)