@@ -120,6 +120,27 @@ function(_set_pure_swift_profile_flags target_name)
120
120
endif ()
121
121
endfunction ()
122
122
123
+ function (_set_pure_swift_package_options target_name package_name)
124
+ if (NOT package_name OR NOT Swift_COMPILER_PACKAGE_CMO_SUPPORT)
125
+ return ()
126
+ endif ()
127
+
128
+ # Enable package CMO if possible
129
+ if (Swift_COMPILER_PACKAGE_CMO_SUPPORT STREQUAL "IMPLEMENTED" )
130
+ target_compile_options ("${target_name} " PRIVATE
131
+ "SHELL:-package-name ${package_name} "
132
+ "SHELL:-Xfrontend -package-cmo"
133
+ "SHELL:-Xfrontend -allow-non-resilient-access"
134
+ )
135
+ elseif (Swift_COMPILER_PACKAGE_CMO_SUPPORT STREQUAL "EXPERIMENTAL" )
136
+ target_compile_options ("${target_name} " PRIVATE
137
+ "SHELL:-package-name ${package_name} "
138
+ "SHELL:-Xfrontend -experimental-package-cmo"
139
+ "SHELL:-Xfrontend -experimental-allow-non-resilient-access"
140
+ "SHELL:-Xfrontend -experimental-package-bypass-resilience"
141
+ )
142
+ endif ()
143
+ endfunction ()
123
144
124
145
# Add a new "pure" Swift host library.
125
146
#
@@ -149,6 +170,9 @@ endfunction()
149
170
# EMIT_MODULE
150
171
# Emit '.swiftmodule' to
151
172
#
173
+ # PACKAGE_NAME
174
+ # Name of the Swift package this library belongs to.
175
+ #
152
176
# DEPENDENCIES
153
177
# Target names to pass target_link_library
154
178
#
@@ -169,7 +193,8 @@ function(add_pure_swift_host_library name)
169
193
SHARED
170
194
STATIC
171
195
EMIT_MODULE)
172
- set (single_parameter_options)
196
+ set (single_parameter_options
197
+ PACKAGE_NAME)
173
198
set (multiple_parameter_options
174
199
DEPENDENCIES
175
200
SWIFT_DEPENDENCIES)
@@ -193,6 +218,7 @@ function(add_pure_swift_host_library name)
193
218
# Create the library.
194
219
add_library (${name} ${libkind} ${APSHL_SOURCES} )
195
220
_add_host_swift_compile_options(${name} )
221
+ _set_pure_swift_package_options(${name} "${APSHL_PACKAGE_NAME} " )
196
222
197
223
set_property (TARGET ${name}
198
224
PROPERTY BUILD_WITH_INSTALL_RPATH YES )
@@ -315,6 +341,9 @@ endfunction()
315
341
# name
316
342
# Name of the tool (e.g., swift-frontend).
317
343
#
344
+ # PACKAGE_NAME
345
+ # Name of the Swift package this executable belongs to.
346
+ #
318
347
# DEPENDENCIES
319
348
# Target names to pass target_link_library
320
349
#
@@ -333,7 +362,8 @@ function(add_pure_swift_host_tool name)
333
362
# Option handling
334
363
set (options )
335
364
set (single_parameter_options
336
- SWIFT_COMPONENT)
365
+ SWIFT_COMPONENT
366
+ PACKAGE_NAME)
337
367
set (multiple_parameter_options
338
368
DEPENDENCIES
339
369
SWIFT_DEPENDENCIES)
@@ -349,6 +379,7 @@ function(add_pure_swift_host_tool name)
349
379
add_executable (${name} ${APSHT_SOURCES} )
350
380
_add_host_swift_compile_options(${name} )
351
381
_set_pure_swift_link_flags(${name} "../lib/" )
382
+ _set_pure_swift_package_options(${name} "${APSHT_PACKAGE_NAME} " )
352
383
353
384
if (SWIFT_HOST_VARIANT_SDK IN_LIST SWIFT_DARWIN_PLATFORMS)
354
385
set_property (TARGET ${name}
0 commit comments