Skip to content

Commit be841a5

Browse files
authored
Merge pull request #74493 from kubamracek/cmake-flag-for-volatile
Add a build-script + CMake flag to enable/disable building the _Volatile module
2 parents cdfe336 + c743b96 commit be841a5

File tree

12 files changed

+54
-1
lines changed

12 files changed

+54
-1
lines changed

CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -712,6 +712,10 @@ option(SWIFT_ENABLE_SYNCHRONIZATION
712712
"Enable build of the Swift Synchronization module"
713713
FALSE)
714714

715+
option(SWIFT_ENABLE_VOLATILE
716+
"Enable build of the Swift Volatile module"
717+
FALSE)
718+
715719
option(SWIFT_ENABLE_DISPATCH
716720
"Enable use of libdispatch"
717721
TRUE)
@@ -1359,6 +1363,7 @@ if(SWIFT_BUILD_STDLIB OR SWIFT_BUILD_SDK_OVERLAY)
13591363
message(STATUS "Unicode Support: ${SWIFT_STDLIB_ENABLE_UNICODE_DATA}")
13601364
message(STATUS "Observation Support: ${SWIFT_ENABLE_EXPERIMENTAL_OBSERVATION}")
13611365
message(STATUS "Synchronization Support: ${SWIFT_ENABLE_SYNCHRONIZATION}")
1366+
message(STATUS "Volatile Support: ${SWIFT_ENABLE_VOLATILE}")
13621367
message(STATUS "")
13631368
else()
13641369
message(STATUS "Not building Swift standard library, SDK overlays, and runtime")

stdlib/cmake/modules/SwiftSource.cmake

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,10 @@ function(_add_target_variant_swift_compile_flags
330330
list(APPEND result "-D" "SWIFT_ENABLE_SYNCHRONIZATION")
331331
endif()
332332

333+
if(SWIFT_ENABLE_VOLATILE)
334+
list(APPEND result "-D" "SWIFT_ENABLE_VOLATILE")
335+
endif()
336+
333337
if(SWIFT_STDLIB_OS_VERSIONING)
334338
list(APPEND result "-D" "SWIFT_RUNTIME_OS_VERSIONING")
335339
endif()

stdlib/public/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,9 @@ if(SWIFT_BUILD_STDLIB AND NOT SWIFT_STDLIB_BUILD_ONLY_CORE_MODULES)
282282
add_subdirectory(Synchronization)
283283
endif()
284284

285-
add_subdirectory(Volatile)
285+
if(SWIFT_ENABLE_VOLATILE)
286+
add_subdirectory(Volatile)
287+
endif()
286288
endif()
287289

288290
if(SWIFT_BUILD_REMOTE_MIRROR)

test/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,7 @@ normalize_boolean_spelling(SWIFT_STDLIB_ENABLE_OBJC_INTEROP)
215215
normalize_boolean_spelling(SWIFT_ENABLE_BACKTRACING)
216216
normalize_boolean_spelling(SWIFT_BUILD_SWIFT_SYNTAX)
217217
normalize_boolean_spelling(SWIFT_ENABLE_SYNCHRONIZATION)
218+
normalize_boolean_spelling(SWIFT_ENABLE_VOLATILE)
218219
normalize_boolean_spelling(SWIFT_BUILD_REMOTE_MIRROR)
219220
is_build_type_optimized("${SWIFT_STDLIB_BUILD_TYPE}" SWIFT_OPTIMIZED)
220221

@@ -433,6 +434,10 @@ foreach(SDK ${SWIFT_SDKS})
433434
list(APPEND LIT_ARGS "--param" "synchronization")
434435
endif()
435436

437+
if(SWIFT_ENABLE_VOLATILE)
438+
list(APPEND LIT_ARGS "--param" "volatile")
439+
endif()
440+
436441
if(SWIFT_BUILD_REMOTE_MIRROR)
437442
list(APPEND LIT_ARGS "--param" "remote_mirror")
438443
endif()

test/lit.site.cfg.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,8 @@ if "@SWIFT_ENABLE_EXPERIMENTAL_OBSERVATION@" == "TRUE":
155155
config.available_features.add('observation')
156156
if "@SWIFT_STDLIB_ENABLE_DEBUG_PRECONDITIONS_IN_RELEASE@" == "TRUE":
157157
config.available_features.add('swift_stdlib_debug_preconditions_in_release')
158+
if "@SWIFT_ENABLE_VOLATILE@" == "TRUE":
159+
config.available_features.add('volatile')
158160
if "@SWIFT_ENABLE_SYNCHRONIZATION@" == "TRUE":
159161
config.available_features.add('synchronization')
160162
if "@SWIFT_SHOULD_BUILD_EMBEDDED_STDLIB@" == "TRUE":

utils/build.ps1

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1345,6 +1345,7 @@ function Build-Compilers() {
13451345
SWIFT_ENABLE_EXPERIMENTAL_OBSERVATION = "YES";
13461346
SWIFT_ENABLE_EXPERIMENTAL_STRING_PROCESSING = "YES";
13471347
SWIFT_ENABLE_SYNCHRONIZATION = "YES";
1348+
SWIFT_ENABLE_VOLATILE = "YES";
13481349
SWIFT_PATH_TO_LIBDISPATCH_SOURCE = "$SourceCache\swift-corelibs-libdispatch";
13491350
SWIFT_PATH_TO_SWIFT_SYNTAX_SOURCE = "$SourceCache\swift-syntax";
13501351
SWIFT_PATH_TO_STRING_PROCESSING_SOURCE = "$SourceCache\swift-experimental-string-processing";
@@ -1594,6 +1595,7 @@ function Build-Runtime([Platform]$Platform, $Arch) {
15941595
SWIFT_ENABLE_EXPERIMENTAL_STRING_PROCESSING = "YES";
15951596
# FIXME: re-enable after https://github.com/apple/swift/issues/74186 is fixed.
15961597
SWIFT_ENABLE_SYNCHRONIZATION = if (($Platform -eq "Android") -and ($Arch -eq $AndroidARMv7)) { "NO" } else { "YES" };
1598+
SWIFT_ENABLE_VOLATILE = "YES";
15971599
SWIFT_NATIVE_SWIFT_TOOLS_PATH = (Join-Path -Path $CompilersBinaryCache -ChildPath "bin");
15981600
SWIFT_PATH_TO_LIBDISPATCH_SOURCE = "$SourceCache\swift-corelibs-libdispatch";
15991601
SWIFT_PATH_TO_STRING_PROCESSING_SOURCE = "$SourceCache\swift-experimental-string-processing";

utils/build_swift/build_swift/driver_arguments.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1465,6 +1465,10 @@ def create_argument_parser():
14651465
default=True,
14661466
help='Enable Swift Synchronization.')
14671467

1468+
option('--enable-volatile', toggle_true,
1469+
default=True,
1470+
help='Enable Volatile module.')
1471+
14681472
option('--enable-experimental-parser-validation', toggle_true,
14691473
default=False,
14701474
help='Enable experimental Swift Parser validation by default.')

utils/build_swift/tests/expected_options.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@
181181
'enable_experimental_parser_validation': False,
182182
'swift_enable_backtracing': True,
183183
'enable_synchronization': True,
184+
'enable_volatile': True,
184185
'enable_lsan': False,
185186
'enable_sanitize_coverage': False,
186187
'disable_guaranteed_normal_arguments': False,
@@ -622,6 +623,7 @@ class BuildScriptImplOption(_BaseOption):
622623
EnableOption('--export-compile-commands'),
623624
EnableOption('--swift-enable-backtracing'),
624625
EnableOption('--enable-synchronization'),
626+
EnableOption('--enable-volatile'),
625627
EnableOption('--foundation', dest='build_foundation'),
626628
EnableOption('--host-test'),
627629
EnableOption('--only-executable-test'),

utils/swift-api-dump.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,8 @@ def create_parser():
108108
help='Enable experimental observation.')
109109
parser.add_argument('--enable-synchronization', action='store_true',
110110
help='Enable Synchronization.')
111+
parser.add_argument('--enable-volatile', action='store_true',
112+
help='Enable Volatile.')
111113
parser.add_argument('-swift-version', metavar='N',
112114
help='the Swift version to use')
113115
parser.add_argument('-show-overlay', action='store_true',

utils/swift_build_support/swift_build_support/products/swift.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@ def __init__(self, args, toolchain, source_dir, build_dir):
7272
# Add synchronization flag.
7373
self.cmake_options.extend(self._enable_synchronization)
7474

75+
# Add volatile flag.
76+
self.cmake_options.extend(self._enable_volatile)
77+
7578
# Add static vprintf flag
7679
self.cmake_options.extend(self._enable_stdlib_static_vprintf)
7780

@@ -219,6 +222,11 @@ def _enable_synchronization(self):
219222
return [('SWIFT_ENABLE_SYNCHRONIZATION:BOOL',
220223
self.args.enable_synchronization)]
221224

225+
@property
226+
def _enable_volatile(self):
227+
return [('SWIFT_ENABLE_VOLATILE:BOOL',
228+
self.args.enable_volatile)]
229+
222230
@property
223231
def _enable_stdlib_static_vprintf(self):
224232
return [('SWIFT_STDLIB_STATIC_PRINT',

utils/swift_build_support/swift_build_support/products/wasmstdlib.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ def _build(self, host_target, target_triple):
110110
'swift-experimental-string-processing'))
111111
self.cmake_options.define('SWIFT_ENABLE_EXPERIMENTAL_CXX_INTEROP:BOOL', 'TRUE')
112112
self.cmake_options.define('SWIFT_ENABLE_SYNCHRONIZATION:BOOL', 'TRUE')
113+
self.cmake_options.define('SWIFT_ENABLE_VOLATILE:BOOL', 'TRUE')
113114
self.cmake_options.define('SWIFT_ENABLE_EXPERIMENTAL_OBSERVATION:BOOL', 'TRUE')
114115

115116
self.add_extra_cmake_options()

utils/swift_build_support/tests/products/test_swift.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ def setUp(self):
6363
enable_experimental_parser_validation=False,
6464
swift_enable_backtracing=False,
6565
enable_synchronization=False,
66+
enable_volatile=False,
6667
build_early_swiftsyntax=False,
6768
build_swift_stdlib_static_print=False,
6869
build_swift_stdlib_unicode_data=True,
@@ -109,6 +110,7 @@ def test_by_default_no_cmake_options(self):
109110
'-DSWIFT_ENABLE_EXPERIMENTAL_PARSER_VALIDATION:BOOL=FALSE',
110111
'-DSWIFT_ENABLE_BACKTRACING:BOOL=FALSE',
111112
'-DSWIFT_ENABLE_SYNCHRONIZATION:BOOL=FALSE',
113+
'-DSWIFT_ENABLE_VOLATILE:BOOL=FALSE',
112114
'-DSWIFT_STDLIB_STATIC_PRINT=FALSE',
113115
'-DSWIFT_FREESTANDING_IS_DARWIN:BOOL=FALSE',
114116
'-DSWIFT_STDLIB_BUILD_PRIVATE:BOOL=TRUE',
@@ -140,6 +142,7 @@ def test_swift_runtime_tsan(self):
140142
'-DSWIFT_ENABLE_EXPERIMENTAL_PARSER_VALIDATION:BOOL=FALSE',
141143
'-DSWIFT_ENABLE_BACKTRACING:BOOL=FALSE',
142144
'-DSWIFT_ENABLE_SYNCHRONIZATION:BOOL=FALSE',
145+
'-DSWIFT_ENABLE_VOLATILE:BOOL=FALSE',
143146
'-DSWIFT_STDLIB_STATIC_PRINT=FALSE',
144147
'-DSWIFT_FREESTANDING_IS_DARWIN:BOOL=FALSE',
145148
'-DSWIFT_STDLIB_BUILD_PRIVATE:BOOL=TRUE',
@@ -461,6 +464,19 @@ def test_synchronization_flags(self):
461464
[x for x in swift.cmake_options
462465
if 'DSWIFT_ENABLE_SYNCHRONIZATION' in x])
463466

467+
def test_volatile_flags(self):
468+
self.args.enable_volatile = True
469+
swift = Swift(
470+
args=self.args,
471+
toolchain=self.toolchain,
472+
source_dir='/path/to/src',
473+
build_dir='/path/to/build')
474+
self.assertEqual(
475+
['-DSWIFT_ENABLE_VOLATILE:BOOL='
476+
'TRUE'],
477+
[x for x in swift.cmake_options
478+
if 'DSWIFT_ENABLE_VOLATILE' in x])
479+
464480
def test_freestanding_is_darwin_flags(self):
465481
self.args.swift_freestanding_is_darwin = True
466482
swift = Swift(

0 commit comments

Comments
 (0)