Skip to content

Commit 18a5500

Browse files
committed
Merge remote-tracking branch 'origin/main' into rebranch
2 parents 4e73e27 + 4bc24f5 commit 18a5500

File tree

3 files changed

+64
-0
lines changed

3 files changed

+64
-0
lines changed

stdlib/cmake/modules/StdlibOptions.cmake

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,16 @@ option(SWIFT_STDLIB_USE_RELATIVE_PROTOCOL_WITNESS_TABLES
250250
"Use relative protocol witness tables"
251251
FALSE)
252252

253+
if("${SWIFT_HOST_VARIANT_SDK}" IN_LIST SWIFT_DARWIN_PLATFORMS)
254+
set(SWIFT_STDLIB_INSTALL_PARENT_MODULE_FOR_SHIMS_default TRUE)
255+
else()
256+
set(SWIFT_STDLIB_INSTALL_PARENT_MODULE_FOR_SHIMS_default FALSE)
257+
endif()
258+
259+
option(SWIFT_STDLIB_INSTALL_PARENT_MODULE_FOR_SHIMS
260+
"Install a parent module map for Swift shims."
261+
${SWIFT_STDLIB_INSTALL_PARENT_MODULE_FOR_SHIMS_default})
262+
253263
set(SWIFT_RUNTIME_FIXED_BACKTRACER_PATH "" CACHE STRING
254264
"If set, provides a fixed path to the swift-backtrace binary. This
255265
will disable dynamic determination of the path and will also disable

stdlib/public/SwiftShims/swift/shims/CMakeLists.txt

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,31 @@ foreach(input ${sources})
6363
list(APPEND outputs "${output_dir_static}/${input}")
6464
endif()
6565
endforeach()
66+
if (SWIFT_STDLIB_INSTALL_PARENT_MODULE_FOR_SHIMS)
67+
# Copy the module map into the parent directory. Using "parent.modulemap"
68+
# instead of putting "module.modulemap" into the parent module to avoid
69+
# module redefinition conflicts with the toolchain.
70+
add_custom_command(
71+
OUTPUT "${output_dir}/../module.modulemap"
72+
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/parent.modulemap"
73+
COMMAND
74+
"${CMAKE_COMMAND}" "-E" "copy_if_different"
75+
"${CMAKE_CURRENT_SOURCE_DIR}/parent.modulemap"
76+
"${output_dir}/../module.modulemap"
77+
COMMENT "Copying parent.modulemap to ${output_dir}")
78+
list(APPEND outputs "${output_dir}/../module.modulemap")
79+
if(SWIFT_BUILD_STATIC_STDLIB)
80+
add_custom_command(
81+
OUTPUT "${output_dir_static}/../module.modulemap"
82+
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/parent.modulemap"
83+
COMMAND
84+
"${CMAKE_COMMAND}" "-E" "copy_if_different"
85+
"${CMAKE_CURRENT_SOURCE_DIR}/parent.modulemap"
86+
"${output_dir_static}/../module.modulemap"
87+
COMMENT "Copying parent.modulemap to ${output_dir_static}")
88+
list(APPEND outputs "${output_dir_static}/../module.modulemap")
89+
endif()
90+
endif()
6691
# Put the output dir itself last so that it isn't considered the primary output.
6792
list(APPEND outputs "${output_dir}")
6893

@@ -179,17 +204,43 @@ if(BOOTSTRAPPING_MODE MATCHES "BOOTSTRAPPING.*")
179204
COMMENT "Symlinking headers for bootstrapping0")
180205

181206
add_dependencies(${target_name} copy_shim_headers)
207+
208+
if (SWIFT_STDLIB_INSTALL_PARENT_MODULE_FOR_SHIMS)
209+
set(modulemap_target_name "symlink-modulemap-bootstrapping${bootstrapping}")
210+
add_custom_command_target(unused_var
211+
COMMAND
212+
"${CMAKE_COMMAND}" "-E" "make_directory" "${outdir}"
213+
COMMAND
214+
"${CMAKE_COMMAND}" "-E" ${cmake_symlink_option}
215+
"${output_dir}/../module.modulemap" "${outdir}/module.modulemap"
216+
217+
CUSTOM_TARGET_NAME ${modulemap_target_name}
218+
OUTPUT "${outdir}/module.modulemap"
219+
COMMENT "Symlinking shims modulemap for bootstrapping0")
220+
add_dependencies(${modulemap_target_name} copy_shim_headers)
221+
add_dependencies(${target_name} ${modulemap_target_name})
222+
endif()
182223
endforeach()
183224
endif()
184225

185226
swift_install_in_component(FILES ${sources}
186227
DESTINATION "lib/swift/shims"
187228
COMPONENT stdlib)
229+
if (SWIFT_STDLIB_INSTALL_PARENT_MODULE_FOR_SHIMS)
230+
swift_install_in_component(FILES "${output_dir}/../module.modulemap"
231+
DESTINATION "lib/swift"
232+
COMPONENT stdlib)
233+
endif()
188234

189235
if(SWIFT_BUILD_STATIC_STDLIB)
190236
swift_install_in_component(FILES ${sources}
191237
DESTINATION "lib/swift_static/shims"
192238
COMPONENT stdlib)
239+
if (SWIFT_STDLIB_INSTALL_PARENT_MODULE_FOR_SHIMS)
240+
swift_install_in_component(FILES "${output_dir_static}/../module.modulemap"
241+
DESTINATION "lib/swift_static"
242+
COMPONENT stdlib)
243+
endif()
193244
endif()
194245

195246
# Install Clang headers under the Swift library so that an installed Swift's
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
extern module SwiftShims "shims/module.modulemap"
2+
extern module _SwiftConcurrencyShims "shims/module.modulemap"
3+
extern module SwiftOverlayShims "shims/module.modulemap"

0 commit comments

Comments
 (0)