Skip to content

Commit 61db072

Browse files
committed
cmake: fix libswift build dependencies
Unfortunately using the convenient "bootstrapping0-all", etc. custom targets does not work. For some reason it does not cause a dependent file (like libswift's SIL.o) being rebuilt when a depenency (like swift-frontend from the previous bootstrapping stage) changes. Instead we have to list al library- and executable-targets explicitly.
1 parent 3abd7b0 commit 61db072

File tree

8 files changed

+54
-52
lines changed

8 files changed

+54
-52
lines changed

CMakeLists.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1089,9 +1089,6 @@ if(SWIFT_ENABLE_DISPATCH)
10891089
include(Libdispatch)
10901090
endif()
10911091

1092-
add_bootstrapping_target(0)
1093-
add_bootstrapping_target(1)
1094-
10951092
# Add all of the subdirectories, where we actually do work.
10961093

10971094
###############

cmake/modules/SwiftUtils.cmake

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -111,35 +111,6 @@ function(get_bootstrapping_swift_lib_dir bs_lib_dir bootstrapping)
111111
set(bs_lib_dir ${bs_lib_dir} PARENT_SCOPE)
112112
endfunction()
113113

114-
function(add_bootstrapping_target bootstrapping)
115-
if(${LIBSWIFT_BUILD_MODE} MATCHES "BOOTSTRAPPING.*")
116-
117-
set(target "bootstrapping${bootstrapping}-all")
118-
add_custom_target(${target})
119-
120-
if(${LIBSWIFT_BUILD_MODE} STREQUAL "BOOTSTRAPPING")
121-
set(lib_target "bootstrapping${bootstrapping}-corelib")
122-
add_custom_target(${lib_target})
123-
add_dependencies(${target} ${lib_target})
124-
endif()
125-
126-
if(SWIFT_PATH_TO_LIBICU_BUILD)
127-
# Need to symlink the libicu libraries to be able to run
128-
# the bootstrapping compiler with a custom library path.
129-
get_bootstrapping_path(output_dir
130-
"${SWIFTLIB_DIR}/${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_LIB_SUBDIR}" "${bootstrapping}")
131-
if("${CMAKE_SYSTEM_NAME}" STREQUAL "Windows")
132-
message("TODO: support for copying ICU libraries on Windows")
133-
endif()
134-
add_custom_command(TARGET "${target}" POST_BUILD
135-
COMMAND
136-
"ln" "-s" "-f" "${SWIFT_PATH_TO_LIBICU_BUILD}/lib/libicu*" "."
137-
WORKING_DIRECTORY "${output_dir}"
138-
COMMENT "symlink ICU libraries for bootstrapping stage ${bootstrapping}")
139-
endif()
140-
endif()
141-
endfunction()
142-
143114
function(is_build_type_optimized build_type result_var_name)
144115
if("${build_type}" STREQUAL "Debug")
145116
set("${result_var_name}" FALSE PARENT_SCOPE)

libswift/CMakeLists.txt

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,18 +31,33 @@ else()
3131

3232
elseif(${LIBSWIFT_BUILD_MODE} MATCHES "BOOTSTRAPPING.*")
3333

34+
set(b0_deps swift-frontend-bootstrapping0 symlink-headers-bootstrapping0)
35+
set(b1_deps swift-frontend-bootstrapping1 symlink-headers-bootstrapping1)
36+
if(${LIBSWIFT_BUILD_MODE} STREQUAL "BOOTSTRAPPING")
37+
set(b0_deps ${b0_deps} swiftCore-bootstrapping0)
38+
set(b1_deps ${b1_deps} swiftCore-bootstrapping1)
39+
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
40+
set(b0_deps ${b0_deps} swiftOnoneSupport-bootstrapping0)
41+
set(b1_deps ${b1_deps} swiftOnoneSupport-bootstrapping1)
42+
endif()
43+
if(SWIFT_HOST_VARIANT_SDK IN_LIST SWIFT_DARWIN_PLATFORMS)
44+
set(b0_deps ${b0_deps} swiftDarwin-bootstrapping0)
45+
set(b1_deps ${b1_deps} swiftDarwin-bootstrapping1)
46+
endif()
47+
endif()
48+
3449
# Bootstrapping - stage 1, using the compiler from level 0
3550

3651
add_libswift("libswift-bootstrapping1"
3752
SWIFT_EXEC "${CMAKE_BINARY_DIR}/bootstrapping0/bin/swiftc"
38-
DEPENDS "bootstrapping0-all"
53+
DEPENDS ${b0_deps}
3954
BOOTSTRAPPING 1)
4055

4156
# The final build, using the compiler from stage 1
4257

4358
add_libswift("libswift"
4459
SWIFT_EXEC "${CMAKE_BINARY_DIR}/bootstrapping1/bin/swiftc"
45-
DEPENDS "bootstrapping1-all")
60+
DEPENDS ${b1_deps})
4661

4762
if(LIBSWIFT_BUILD_MODE STREQUAL "BOOTSTRAPPING-WITH-HOSTLIBS")
4863
file(GLOB module_dirs "${CMAKE_BINARY_DIR}/bootstrapping*/lib/swift/macosx/*.swiftmodule")

stdlib/public/Platform/CMakeLists.txt

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,18 +53,22 @@ if(${LIBSWIFT_BUILD_MODE} STREQUAL "BOOTSTRAPPING" AND
5353
ARCHITECTURE ${SWIFT_HOST_VARIANT_ARCH}
5454
INSTALL_IN_COMPONENT "never_install")
5555

56+
set(b0_deps swiftCore-bootstrapping0)
57+
set(b1_deps swiftCore-bootstrapping1)
58+
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
59+
set(b0_deps ${b0_deps} swiftOnoneSupport-bootstrapping0)
60+
set(b1_deps ${b1_deps} swiftOnoneSupport-bootstrapping1)
61+
endif()
62+
5663
add_swift_target_library_single(swiftDarwin-bootstrapping0 swiftDarwin
5764
${swiftDarwin_common_bootstrapping_options}
58-
FILE_DEPENDS bootstrapping0-corelib
65+
FILE_DEPENDS ${b0_deps}
5966
BOOTSTRAPPING 0)
6067

6168
add_swift_target_library_single(swiftDarwin-bootstrapping1 swiftDarwin
6269
${swiftDarwin_common_bootstrapping_options}
63-
FILE_DEPENDS bootstrapping1-corelib
70+
FILE_DEPENDS ${b1_deps}
6471
BOOTSTRAPPING 1)
65-
66-
add_dependencies(bootstrapping1-all swiftDarwin-bootstrapping1)
67-
add_dependencies(bootstrapping0-all swiftDarwin-bootstrapping0)
6872
endif()
6973

7074
add_swift_target_library(swiftDarwin ${SWIFT_STDLIB_LIBRARY_BUILD_TYPES}

stdlib/public/SwiftOnoneSupport/CMakeLists.txt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,13 @@ if(CMAKE_BUILD_TYPE STREQUAL "Debug" AND ${LIBSWIFT_BUILD_MODE} STREQUAL "BOOTST
2727
FILE_DEPENDS swiftCore-bootstrapping0
2828
BOOTSTRAPPING 0)
2929

30-
add_dependencies(bootstrapping0-corelib swiftSwiftOnoneSupport-bootstrapping0)
31-
3230
# Bootstrapping - stage 1
3331

3432
add_swift_target_library_single(swiftSwiftOnoneSupport-bootstrapping1 swiftSwiftOnoneSupport
3533
${swiftOnoneSupport_common_bootstrapping_options}
3634
FILE_DEPENDS swiftCore-bootstrapping1
3735
BOOTSTRAPPING 1)
3836

39-
add_dependencies(bootstrapping1-corelib swiftSwiftOnoneSupport-bootstrapping1)
40-
4137
endif()
4238

4339
add_swift_target_library(swiftSwiftOnoneSupport

stdlib/public/SwiftShims/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,6 @@ if(${LIBSWIFT_BUILD_MODE} MATCHES "BOOTSTRAPPING.*")
177177
COMMENT "Symlinking headers for bootstrapping0")
178178

179179
add_dependencies(${target_name} copy_shim_headers)
180-
add_dependencies(bootstrapping${bootstrapping}-all ${target_name})
181180
endforeach()
182181
endif()
183182

stdlib/public/core/CMakeLists.txt

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,32 @@ set(swiftCore_common_dependencies
340340

341341
if(${LIBSWIFT_BUILD_MODE} STREQUAL "BOOTSTRAPPING")
342342

343+
set(b0_deps symlink-headers-bootstrapping0)
344+
set(b1_deps symlink-headers-bootstrapping1)
345+
346+
if(SWIFT_PATH_TO_LIBICU_BUILD)
347+
foreach(bootstrapping "0" "1")
348+
# Need to symlink the libicu libraries to be able to run
349+
# the bootstrapping compiler with a custom library path.
350+
get_bootstrapping_path(output_dir
351+
"${SWIFTLIB_DIR}/${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_LIB_SUBDIR}" "${bootstrapping}")
352+
if("${CMAKE_SYSTEM_NAME}" STREQUAL "Windows")
353+
message("TODO: support for copying ICU libraries on Windows")
354+
endif()
355+
set(target "symlink-icu-bootstrapping${bootstrapping}")
356+
add_custom_target(${target})
357+
add_custom_command(TARGET ${target} POST_BUILD
358+
COMMAND
359+
"${CMAKE_COMMAND}" "-E" "make_directory" "${output_dir}"
360+
COMMAND
361+
"ln" "-s" "-f" "${SWIFT_PATH_TO_LIBICU_BUILD}/lib/libicu*" "."
362+
WORKING_DIRECTORY "${output_dir}"
363+
COMMENT "symlink ICU libraries for bootstrapping stage ${bootstrapping}")
364+
endforeach()
365+
set(b0_deps ${b0_deps} symlink-icu-bootstrapping0)
366+
set(b1_deps ${b1_deps} symlink-icu-bootstrapping1)
367+
endif()
368+
343369
list(FIND SWIFT_STDLIB_LIBRARY_BUILD_TYPES "SHARED" index_of_shared)
344370
if(index_of_shared EQUAL -1)
345371
message(FATAL_ERROR "bootstrapping requires SHARED stdlib build type")
@@ -358,19 +384,16 @@ if(${LIBSWIFT_BUILD_MODE} STREQUAL "BOOTSTRAPPING")
358384
add_swift_target_library_single(swiftCore-bootstrapping0 swiftCore
359385
${swiftCore_common_bootstrapping_options}
360386
FILE_DEPENDS
361-
symlink-headers-bootstrapping0 ${swiftCore_common_dependencies}
387+
${b0_deps} ${swiftCore_common_dependencies}
362388
BOOTSTRAPPING 0)
363389

364390
# Bootstrapping - stage 1
365391

366392
add_swift_target_library_single(swiftCore-bootstrapping1 swiftCore
367393
${swiftCore_common_bootstrapping_options}
368394
FILE_DEPENDS
369-
symlink-headers-bootstrapping1 ${swiftCore_common_dependencies}
395+
${b1_deps} ${swiftCore_common_dependencies}
370396
BOOTSTRAPPING 1)
371-
372-
add_dependencies(bootstrapping1-corelib swiftCore-bootstrapping1)
373-
add_dependencies(bootstrapping0-corelib swiftCore-bootstrapping0)
374397
endif()
375398

376399
add_swift_target_library(swiftCore

tools/driver/CMakeLists.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,6 @@ if(${LIBSWIFT_BUILD_MODE} MATCHES "BOOTSTRAPPING.*")
3838
SOURCE "swift-frontend${CMAKE_EXECUTABLE_SUFFIX}"
3939
DESTINATION "swiftc${CMAKE_EXECUTABLE_SUFFIX}"
4040
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/bootstrapping1/bin")
41-
42-
add_dependencies(bootstrapping0-all swift-frontend-bootstrapping0)
43-
add_dependencies(bootstrapping1-all swift-frontend-bootstrapping1)
4441
endif()
4542

4643
add_swift_host_tool(swift-frontend

0 commit comments

Comments
 (0)