Skip to content

Commit 871c6b9

Browse files
authored
[CMake] Begin moving Standard Library options in a separate file (#40610)
This allows the file to be easily included where needed (e.g. `StandaloneOverlay.cmake`) and reduce the likelihood of miscompilation due to missing sensible defaults. As a start, focus on a handful of parameters that got added/modified in recent PRs. Addresses rdar://85978195
1 parent 8612cd0 commit 871c6b9

File tree

3 files changed

+29
-16
lines changed

3 files changed

+29
-16
lines changed

cmake/modules/StandaloneOverlay.cmake

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
# In some configurations (e.g. back deploy concurrency) we
2+
# configure the build from the root of the Swift repo but we skip
3+
# stdlib/CMakeLists.txt, with the risk of missing important parameters.
4+
# To account for this scenario, we include the stdlib options
5+
# before the guard
6+
include(${CMAKE_CURRENT_LIST_DIR}/../../stdlib/cmake/modules/StdlibOptions.cmake)
7+
18
# CMAKE_SOURCE_DIR is the directory that cmake got initially invoked on.
29
# CMAKE_CURRENT_SOURCE_DIR is the current directory. If these are equal, it's
310
# a top-level build of the CMAKE_SOURCE_DIR. Otherwise, define a guard variable
@@ -85,10 +92,6 @@ set(SWIFT_DARWIN_MODULE_ARCHS "" CACHE STRING
8592
targets on Darwin platforms. These targets are in addition to the full \
8693
library targets.")
8794

88-
option(SWIFT_STDLIB_SHORT_MANGLING_LOOKUPS
89-
"Build stdlib with fast-path context descriptor lookups based on well-known short manglings."
90-
TRUE)
91-
9295
# -----------------------------------------------------------------------------
9396
# Constants
9497

stdlib/CMakeLists.txt

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,14 @@ endif()
7272
# User-configurable options for the standard library.
7373
#
7474

75+
# New options should be added to stdlib/cmake/modules/StdlibOptions.cmake,
76+
# so that they are considered in configurations using StandaloneOverlay.cmake
77+
7578
# NOTE: Some of these variables are also initialized in StandaloneOverlay.cmake
7679
# so that interfaces are emitted when overlays are separately built.
7780

81+
# TODO: migrate this section to StdlibOptions.cmake to reduce duplication
82+
7883
set(SWIFT_STDLIB_EXTRA_SWIFT_COMPILE_FLAGS "" CACHE STRING
7984
"Extra flags to pass when compiling swift stdlib files")
8085

@@ -89,10 +94,6 @@ option(SWIFT_ENABLE_MODULE_INTERFACES
8994
"Generate .swiftinterface files alongside .swiftmodule files"
9095
"${SWIFT_STDLIB_STABLE_ABI}")
9196

92-
option(SWIFT_STDLIB_SUPPORT_BACK_DEPLOYMENT
93-
"Support back-deployment of built binaries to older OS versions."
94-
TRUE)
95-
9697
option(SWIFT_STDLIB_HAS_DLADDR
9798
"Build stdlib assuming the runtime environment runtime environment provides dladdr API."
9899
TRUE)
@@ -133,10 +134,6 @@ option(SWIFT_STDLIB_PASSTHROUGH_METADATA_ALLOCATOR
133134
"Build stdlib without a custom implementation of MetadataAllocator, relying on malloc+free instead."
134135
FALSE)
135136

136-
option(SWIFT_STDLIB_SHORT_MANGLING_LOOKUPS
137-
"Build stdlib with fast-path context descriptor lookups based on well-known short manglings."
138-
TRUE)
139-
140137
option(SWIFT_STDLIB_HAS_COMMANDLINE
141138
"Build stdlib with the CommandLine enum and support for argv/argc."
142139
TRUE)
@@ -164,10 +161,6 @@ option(SWIFT_ENABLE_REFLECTION
164161
"Build stdlib with support for runtime reflection and mirrors."
165162
TRUE)
166163

167-
option(SWIFT_STDLIB_BUILD_PRIVATE
168-
"Build private part of the Standard Library."
169-
TRUE)
170-
171164
if(SWIFT_STDLIB_SINGLE_THREADED_RUNTIME)
172165
set(SWIFT_CONCURRENCY_GLOBAL_EXECUTOR_default "singlethreaded")
173166
else()
@@ -178,6 +171,10 @@ set(SWIFT_CONCURRENCY_GLOBAL_EXECUTOR
178171
"${SWIFT_CONCURRENCY_GLOBAL_EXECUTOR_default}" CACHE STRING
179172
"Build the concurrency library to use the given global executor (options: dispatch, singlethreaded, hooked)")
180173

174+
# New options should be added to stdlib/cmake/modules/StdlibOptions.cmake,
175+
# so that they are considered in configurations using StandaloneOverlay.cmake
176+
include(StdlibOptions)
177+
181178
#
182179
# End of user-configurable options.
183180
#
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
include_guard(GLOBAL)
2+
3+
option(SWIFT_STDLIB_SUPPORT_BACK_DEPLOYMENT
4+
"Support back-deployment of built binaries to older OS versions."
5+
TRUE)
6+
7+
option(SWIFT_STDLIB_SHORT_MANGLING_LOOKUPS
8+
"Build stdlib with fast-path context descriptor lookups based on well-known short manglings."
9+
TRUE)
10+
11+
option(SWIFT_STDLIB_BUILD_PRIVATE
12+
"Build private part of the Standard Library."
13+
TRUE)

0 commit comments

Comments
 (0)