Skip to content

Commit 8c0908a

Browse files
committed
[cmake][build-script] Add support for building the runtime with +0 normal args.
I am upstreaming some changes to the runtime to support +0 normal arguments. rdar://34222540
1 parent 0a41588 commit 8c0908a

File tree

6 files changed

+43
-5
lines changed

6 files changed

+43
-5
lines changed

CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,10 @@ option(SWIFT_STDLIB_ENABLE_SIL_OWNERSHIP
296296
"Build the standard libraries and overlays with sil ownership enabled."
297297
FALSE)
298298

299+
option(SWIFT_ENABLE_GUARANTEED_NORMAL_ARGUMENTS
300+
"Build the standard libraries, overlays, and runtime with normal arguments at +0"
301+
FALSE)
302+
299303
#
300304
# End of user-configurable options.
301305
#

stdlib/public/runtime/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ if(SWIFT_RUNTIME_ENABLE_LEAK_CHECKER)
2323
set(swift_runtime_leaks_sources Leaks.mm)
2424
endif()
2525

26+
if(SWIFT_ENABLE_GUARANTEED_NORMAL_ARGUMENTS)
27+
list(APPEND swift_runtime_compile_flags
28+
"-DSWIFT_RUNTIME_ENABLE_GUARANTEED_NORMAL_ARGUMENTS")
29+
endif()
30+
2631
list(APPEND swift_runtime_compile_flags
2732
"-D__SWIFT_CURRENT_DYLIB=swiftCore")
2833

utils/build_swift/driver_arguments.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,9 @@ def create_argument_parser():
437437
option('--enable-sil-ownership', store_true,
438438
help='Enable the SIL ownership model')
439439

440+
option('--enable-guaranteed-normal-arguments', store_true,
441+
help='Enable guaranteed normal arguments')
442+
440443
option('--force-optimized-typechecker', store_true,
441444
help='Force the type checker to be built with '
442445
'optimization')

utils/build_swift/tests/expected_options.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@
114114
'enable_asan': False,
115115
'enable_lsan': False,
116116
'enable_sil_ownership': False,
117+
'enable_guaranteed_normal_arguments': False,
117118
'enable_tsan': False,
118119
'enable_tsan_runtime': False,
119120
'enable_ubsan': False,
@@ -374,6 +375,7 @@ class IgnoreOption(_BaseOption):
374375
SetTrueOption('--clean'),
375376
SetTrueOption('--dry-run'),
376377
SetTrueOption('--enable-sil-ownership'),
378+
SetTrueOption('--enable-guaranteed-normal-arguments'),
377379
SetTrueOption('--force-optimized-typechecker'),
378380
SetTrueOption('--ios'),
379381
SetTrueOption('--llbuild', dest='build_llbuild'),

utils/swift_build_support/swift_build_support/products/swift.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ def __init__(self, args, toolchain, source_dir, build_dir):
3333
# Add any sil ownership flags.
3434
self.cmake_options.extend(self._sil_ownership_flags)
3535

36+
# Add any guaranteed normal arguments flags
37+
self.cmake_options.extend(self._guaranteed_normal_arguments_flags)
38+
3639
# Generate the compile db.
3740
self.cmake_options.extend(self._compile_db_flags)
3841

@@ -109,6 +112,12 @@ def _sil_ownership_flags(self):
109112
return ["-DSWIFT_STDLIB_ENABLE_SIL_OWNERSHIP=FALSE"]
110113
return ["-DSWIFT_STDLIB_ENABLE_SIL_OWNERSHIP=TRUE"]
111114

115+
@property
116+
def _guaranteed_normal_arguments_flags(self):
117+
if not self.args.enable_guaranteed_normal_arguments:
118+
return ["-DSWIFT_ENABLE_GUARANTEED_NORMAL_ARGUMENTS=FALSE"]
119+
return ["-DSWIFT_ENABLE_GUARANTEED_NORMAL_ARGUMENTS=TRUE"]
120+
112121
@property
113122
def _compile_db_flags(self):
114123
return ['-DCMAKE_EXPORT_COMPILE_COMMANDS=TRUE']

utils/swift_build_support/tests/products/test_swift.py

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ def setUp(self):
5656
benchmark_num_onone_iterations=3,
5757
benchmark_num_o_iterations=3,
5858
enable_sil_ownership=False,
59+
enable_guaranteed_normal_arguments=False,
5960
force_optimized_typechecker=False)
6061

6162
# Setup shell
@@ -86,6 +87,7 @@ def test_by_default_no_cmake_options(self):
8687
self.assertEqual(set(swift.cmake_options), set([
8788
'-DCMAKE_EXPORT_COMPILE_COMMANDS=TRUE',
8889
'-DSWIFT_STDLIB_ENABLE_SIL_OWNERSHIP=FALSE',
90+
'-DSWIFT_ENABLE_GUARANTEED_NORMAL_ARGUMENTS=FALSE',
8991
'-DSWIFT_FORCE_OPTIMIZED_TYPECHECKER=FALSE']))
9092

9193
def test_swift_runtime_tsan(self):
@@ -95,11 +97,12 @@ def test_swift_runtime_tsan(self):
9597
toolchain=self.toolchain,
9698
source_dir='/path/to/src',
9799
build_dir='/path/to/build')
98-
self.assertEqual(set(swift.cmake_options),
99-
set(['-DSWIFT_RUNTIME_USE_SANITIZERS=Thread',
100-
'-DCMAKE_EXPORT_COMPILE_COMMANDS=TRUE',
101-
'-DSWIFT_STDLIB_ENABLE_SIL_OWNERSHIP=FALSE',
102-
'-DSWIFT_FORCE_OPTIMIZED_TYPECHECKER=FALSE']))
100+
flags_set = set(['-DSWIFT_RUNTIME_USE_SANITIZERS=Thread',
101+
'-DCMAKE_EXPORT_COMPILE_COMMANDS=TRUE',
102+
'-DSWIFT_STDLIB_ENABLE_SIL_OWNERSHIP=FALSE',
103+
'-DSWIFT_ENABLE_GUARANTEED_NORMAL_ARGUMENTS=FALSE',
104+
'-DSWIFT_FORCE_OPTIMIZED_TYPECHECKER=FALSE'])
105+
self.assertEqual(set(swift.cmake_options), flags_set)
103106

104107
def test_swift_compiler_vendor_flags(self):
105108
self.args.compiler_vendor = "none"
@@ -285,6 +288,18 @@ def test_sil_ownership_flags(self):
285288
[x for x in swift.cmake_options
286289
if 'SWIFT_STDLIB_ENABLE_SIL_OWNERSHIP' in x])
287290

291+
def test_swift_guaranteed_normal_arguments_flags(self):
292+
self.args.enable_guaranteed_normal_arguments = True
293+
swift = Swift(
294+
args=self.args,
295+
toolchain=self.toolchain,
296+
source_dir='/path/to/src',
297+
build_dir='/path/to/build')
298+
self.assertEqual(
299+
['-DSWIFT_ENABLE_GUARANTEED_NORMAL_ARGUMENTS=TRUE'],
300+
[x for x in swift.cmake_options
301+
if 'SWIFT_ENABLE_GUARANTEED_NORMAL_ARGUMENTS' in x])
302+
288303
def test_force_optimized_typechecker_flags(self):
289304
self.args.force_optimized_typechecker = True
290305
swift = Swift(

0 commit comments

Comments
 (0)