Skip to content

Commit f3a85b1

Browse files
committed
Add build-script option and lit config for nonescapable_types
With this build-script has a flag --enable-experimental-nonescpable-types=1 to enable this feature in stdlib. Also we can now add // REQUIRES: nonescapable_types to tests which run only when the compiler is built with this feature turned on.
1 parent 806921c commit f3a85b1

File tree

9 files changed

+48
-0
lines changed

9 files changed

+48
-0
lines changed

CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -657,6 +657,10 @@ option(SWIFT_ENABLE_EXPERIMENTAL_NONCOPYABLE_GENERICS
657657
"Enable experimental NoncopyableGenerics"
658658
FALSE)
659659

660+
option(SWIFT_ENABLE_EXPERIMENTAL_NONESCAPABLE_TYPES
661+
"Enable experimental NonescapableTypes"
662+
FALSE)
663+
660664
option(SWIFT_ENABLE_EXPERIMENTAL_STRING_PROCESSING
661665
"Enable experimental string processing"
662666
FALSE)
@@ -1253,6 +1257,7 @@ if(SWIFT_BUILD_STDLIB OR SWIFT_BUILD_SDK_OVERLAY)
12531257
message(STATUS "Concurrency Support: ${SWIFT_ENABLE_EXPERIMENTAL_CONCURRENCY}")
12541258
message(STATUS "Distributed Support: ${SWIFT_ENABLE_EXPERIMENTAL_DISTRIBUTED}")
12551259
message(STATUS "NoncopyableGenerics Support: ${SWIFT_ENABLE_EXPERIMENTAL_NONCOPYABLE_GENERICS}")
1260+
message(STATUS "NonEscapableTypes Support: ${SWIFT_ENABLE_EXPERIMENTAL_NONESCAPABLE_TYPES}")
12561261
message(STATUS "String Processing Support: ${SWIFT_ENABLE_EXPERIMENTAL_STRING_PROCESSING}")
12571262
message(STATUS "Backtracing Support: ${SWIFT_ENABLE_BACKTRACING}")
12581263
message(STATUS "Unicode Support: ${SWIFT_STDLIB_ENABLE_UNICODE_DATA}")

stdlib/cmake/modules/SwiftSource.cmake

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -617,6 +617,10 @@ function(_compile_swift_files
617617
list(APPEND swift_flags "-Xfrontend" "-enable-experimental-associated-type-inference")
618618
endif()
619619

620+
if(SWIFT_ENABLE_EXPERIMENTAL_NONESCAPABLE_TYPES)
621+
list(APPEND swift_flags "-enable-experimental-feature" "NonescapableTypes")
622+
endif()
623+
620624
if (SWIFT_STDLIB_ENABLE_STRICT_CONCURRENCY_COMPLETE)
621625
list(APPEND swift_flags "-strict-concurrency=complete")
622626
endif()

test/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@ normalize_boolean_spelling(SWIFT_ENABLE_EXPERIMENTAL_DIFFERENTIABLE_PROGRAMMING)
192192
normalize_boolean_spelling(SWIFT_ENABLE_EXPERIMENTAL_CONCURRENCY)
193193
normalize_boolean_spelling(SWIFT_ENABLE_EXPERIMENTAL_DISTRIBUTED)
194194
normalize_boolean_spelling(SWIFT_ENABLE_EXPERIMENTAL_NONCOPYABLE_GENERICS)
195+
normalize_boolean_spelling(SWIFT_ENABLE_EXPERIMENTAL_NONESCAPABLE_TYPES)
195196
normalize_boolean_spelling(SWIFT_ENABLE_EXPERIMENTAL_STRING_PROCESSING)
196197
normalize_boolean_spelling(SWIFT_ENABLE_EXPERIMENTAL_OBSERVATION)
197198
normalize_boolean_spelling(SWIFT_ENABLE_MACCATALYST)
@@ -404,6 +405,10 @@ foreach(SDK ${SWIFT_SDKS})
404405
list(APPEND LIT_ARGS "--param" "noncopyable_generics")
405406
endif()
406407

408+
if(SWIFT_ENABLE_EXPERIMENTAL_NONESCAPABLE_TYPES)
409+
list(APPEND LIT_ARGS "--param" "nonescapable_types")
410+
endif()
411+
407412
if(SWIFT_ENABLE_EXPERIMENTAL_STRING_PROCESSING)
408413
list(APPEND LIT_ARGS "--param" "string_processing")
409414
endif()

test/lit.site.cfg.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,8 @@ if "@SWIFT_ENABLE_EXPERIMENTAL_DISTRIBUTED@" == "TRUE":
145145
config.available_features.add('distributed')
146146
if "@SWIFT_ENABLE_EXPERIMENTAL_NONCOPYABLE_GENERICS@" == "TRUE":
147147
config.available_features.add('noncopyable_generics')
148+
if "@SWIFT_ENABLE_EXPERIMENTAL_NONESCAPABLE_TYPES@" == "TRUE":
149+
config.available_features.add('nonescapable_types')
148150
if "@SWIFT_STDLIB_STATIC_PRINT@" == "TRUE":
149151
config.available_features.add('stdlib_static_print')
150152
if "@SWIFT_STDLIB_ENABLE_UNICODE_DATA" == "TRUE":

utils/build_swift/build_swift/driver_arguments.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1351,6 +1351,10 @@ def create_argument_parser():
13511351
default=False,
13521352
help='Enable experimental NoncopyableGenerics.')
13531353

1354+
option('--enable-experimental-nonescapable-types', toggle_true,
1355+
default=False,
1356+
help='Enable experimental NonescapableTypes.')
1357+
13541358
option('--enable-experimental-string-processing', toggle_true,
13551359
default=True,
13561360
help='Enable experimental Swift string processing.')

utils/build_swift/tests/expected_options.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@
169169
'enable_cxx_interop_swift_bridging_header': True,
170170
'enable_experimental_distributed': True,
171171
'enable_experimental_noncopyable_generics': False,
172+
'enable_experimental_nonescapable_types': False,
172173
'enable_experimental_string_processing': True,
173174
'enable_experimental_observation': True,
174175
'swift_enable_backtracing': True,
@@ -593,6 +594,7 @@ class BuildScriptImplOption(_BaseOption):
593594
EnableOption('--enable-cxx-interop-swift-bridging-header'),
594595
EnableOption('--enable-experimental-distributed'),
595596
EnableOption('--enable-experimental-noncopyable-generics'),
597+
EnableOption('--enable-experimental-nonescapable-types'),
596598
EnableOption('--enable-experimental-string-processing'),
597599
EnableOption('--enable-experimental-observation'),
598600
EnableOption('--enable-lsan'),

utils/swift_build_support/swift_build_support/products/swift.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@ def __init__(self, args, toolchain, source_dir, build_dir):
6262
# Add experimental NoncopyableGenerics flag.
6363
self.cmake_options.extend(self._enable_experimental_noncopyable_generics)
6464

65+
# Add experimental NonescapableTypes flag.
66+
self.cmake_options.extend(self._enable_experimental_nonescapable_types)
67+
6568
# Add backtracing flag.
6669
self.cmake_options.extend(self._enable_backtracing)
6770

@@ -198,6 +201,11 @@ def _enable_experimental_noncopyable_generics(self):
198201
return [('SWIFT_ENABLE_EXPERIMENTAL_NONCOPYABLE_GENERICS:BOOL',
199202
self.args.enable_experimental_noncopyable_generics)]
200203

204+
@property
205+
def _enable_experimental_nonescapable_types(self):
206+
return [('SWIFT_ENABLE_EXPERIMENTAL_NONESCAPABLE_TYPES:BOOL',
207+
self.args.enable_experimental_nonescapable_types)]
208+
201209
@property
202210
def _enable_backtracing(self):
203211
return [('SWIFT_ENABLE_BACKTRACING:BOOL',

utils/swift_build_support/tests/products/test_swift.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ def setUp(self):
5959
enable_cxx_interop_swift_bridging_header=False,
6060
enable_experimental_distributed=False,
6161
enable_experimental_noncopyable_generics=False,
62+
enable_experimental_nonescapable_types=False,
6263
enable_experimental_observation=False,
6364
swift_enable_backtracing=False,
6465
enable_synchronization=False,
@@ -104,6 +105,7 @@ def test_by_default_no_cmake_options(self):
104105
'-DSWIFT_ENABLE_CXX_INTEROP_SWIFT_BRIDGING_HEADER:BOOL=FALSE',
105106
'-DSWIFT_ENABLE_EXPERIMENTAL_DISTRIBUTED:BOOL=FALSE',
106107
'-DSWIFT_ENABLE_EXPERIMENTAL_NONCOPYABLE_GENERICS:BOOL=FALSE',
108+
'-DSWIFT_ENABLE_EXPERIMENTAL_NONESCAPABLE_TYPES:BOOL=FALSE',
107109
'-DSWIFT_ENABLE_EXPERIMENTAL_OBSERVATION:BOOL=FALSE',
108110
'-DSWIFT_ENABLE_BACKTRACING:BOOL=FALSE',
109111
'-DSWIFT_ENABLE_SYNCHRONIZATION:BOOL=FALSE',
@@ -133,6 +135,7 @@ def test_swift_runtime_tsan(self):
133135
'-DSWIFT_ENABLE_CXX_INTEROP_SWIFT_BRIDGING_HEADER:BOOL=FALSE',
134136
'-DSWIFT_ENABLE_EXPERIMENTAL_DISTRIBUTED:BOOL=FALSE',
135137
'-DSWIFT_ENABLE_EXPERIMENTAL_NONCOPYABLE_GENERICS:BOOL=FALSE',
138+
'-DSWIFT_ENABLE_EXPERIMENTAL_NONESCAPABLE_TYPES:BOOL=FALSE',
136139
'-DSWIFT_ENABLE_EXPERIMENTAL_OBSERVATION:BOOL=FALSE',
137140
'-DSWIFT_ENABLE_BACKTRACING:BOOL=FALSE',
138141
'-DSWIFT_ENABLE_SYNCHRONIZATION:BOOL=FALSE',
@@ -417,6 +420,19 @@ def test_experimental_noncopyable_generics_flags(self):
417420
[x for x in swift.cmake_options
418421
if 'DSWIFT_ENABLE_EXPERIMENTAL_NONCOPYABLE_GENERICS' in x])
419422

423+
def test_experimental_nonescapable_types_flags(self):
424+
self.args.enable_experimental_nonescapable_types = True
425+
swift = Swift(
426+
args=self.args,
427+
toolchain=self.toolchain,
428+
source_dir='/path/to/src',
429+
build_dir='/path/to/build')
430+
self.assertEqual(
431+
['-DSWIFT_ENABLE_EXPERIMENTAL_NONESCAPABLE_TYPES:BOOL='
432+
'TRUE'],
433+
[x for x in swift.cmake_options
434+
if 'DSWIFT_ENABLE_EXPERIMENTAL_NONESCAPABLE_TYPES' in x])
435+
420436
def test_experimental_observation_flags(self):
421437
self.args.enable_experimental_observation = True
422438
swift = Swift(

validation-test/lit.site.cfg.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,8 @@ if "@SWIFT_ENABLE_EXPERIMENTAL_DISTRIBUTED@" == "TRUE":
132132
config.available_features.add('distributed')
133133
if "@SWIFT_ENABLE_EXPERIMENTAL_NONCOPYABLE_GENERICS@" == "TRUE":
134134
config.available_features.add('noncopyable_generics')
135+
if "@SWIFT_ENABLE_EXPERIMENTAL_NONESCAPABLE_TYPES@" == "TRUE":
136+
config.available_features.add('nonescapable_types')
135137
if "@SWIFT_ENABLE_EXPERIMENTAL_STRING_PROCESSING@" == "TRUE":
136138
config.available_features.add('string_processing')
137139
if "@SWIFT_STDLIB_ENABLE_DEBUG_PRECONDITIONS_IN_RELEASE@" == "TRUE":

0 commit comments

Comments
 (0)