Skip to content

[cmake][build-script] Add support for building the runtime with +0 no… #13651

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,10 @@ option(SWIFT_STDLIB_ENABLE_SIL_OWNERSHIP
"Build the standard libraries and overlays with sil ownership enabled."
FALSE)

option(SWIFT_ENABLE_GUARANTEED_NORMAL_ARGUMENTS
"Build the standard libraries, overlays, and runtime with normal arguments at +0"
FALSE)

#
# End of user-configurable options.
#
Expand Down
5 changes: 5 additions & 0 deletions stdlib/public/runtime/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ if(SWIFT_RUNTIME_ENABLE_LEAK_CHECKER)
set(swift_runtime_leaks_sources Leaks.mm)
endif()

if(SWIFT_ENABLE_GUARANTEED_NORMAL_ARGUMENTS)
list(APPEND swift_runtime_compile_flags
"-DSWIFT_RUNTIME_ENABLE_GUARANTEED_NORMAL_ARGUMENTS")
endif()

list(APPEND swift_runtime_compile_flags
"-D__SWIFT_CURRENT_DYLIB=swiftCore")

Expand Down
3 changes: 3 additions & 0 deletions utils/build_swift/driver_arguments.py
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,9 @@ def create_argument_parser():
option('--enable-sil-ownership', store_true,
help='Enable the SIL ownership model')

option('--enable-guaranteed-normal-arguments', store_true,
help='Enable guaranteed normal arguments')

option('--force-optimized-typechecker', store_true,
help='Force the type checker to be built with '
'optimization')
Expand Down
2 changes: 2 additions & 0 deletions utils/build_swift/tests/expected_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@
'enable_asan': False,
'enable_lsan': False,
'enable_sil_ownership': False,
'enable_guaranteed_normal_arguments': False,
'enable_tsan': False,
'enable_tsan_runtime': False,
'enable_ubsan': False,
Expand Down Expand Up @@ -374,6 +375,7 @@ class IgnoreOption(_BaseOption):
SetTrueOption('--clean'),
SetTrueOption('--dry-run'),
SetTrueOption('--enable-sil-ownership'),
SetTrueOption('--enable-guaranteed-normal-arguments'),
SetTrueOption('--force-optimized-typechecker'),
SetTrueOption('--ios'),
SetTrueOption('--llbuild', dest='build_llbuild'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ def __init__(self, args, toolchain, source_dir, build_dir):
# Add any sil ownership flags.
self.cmake_options.extend(self._sil_ownership_flags)

# Add any guaranteed normal arguments flags
self.cmake_options.extend(self._guaranteed_normal_arguments_flags)

# Generate the compile db.
self.cmake_options.extend(self._compile_db_flags)

Expand Down Expand Up @@ -109,6 +112,12 @@ def _sil_ownership_flags(self):
return ["-DSWIFT_STDLIB_ENABLE_SIL_OWNERSHIP=FALSE"]
return ["-DSWIFT_STDLIB_ENABLE_SIL_OWNERSHIP=TRUE"]

@property
def _guaranteed_normal_arguments_flags(self):
if not self.args.enable_guaranteed_normal_arguments:
return ["-DSWIFT_ENABLE_GUARANTEED_NORMAL_ARGUMENTS=FALSE"]
return ["-DSWIFT_ENABLE_GUARANTEED_NORMAL_ARGUMENTS=TRUE"]

@property
def _compile_db_flags(self):
return ['-DCMAKE_EXPORT_COMPILE_COMMANDS=TRUE']
Expand Down
25 changes: 20 additions & 5 deletions utils/swift_build_support/tests/products/test_swift.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ def setUp(self):
benchmark_num_onone_iterations=3,
benchmark_num_o_iterations=3,
enable_sil_ownership=False,
enable_guaranteed_normal_arguments=False,
force_optimized_typechecker=False)

# Setup shell
Expand Down Expand Up @@ -86,6 +87,7 @@ def test_by_default_no_cmake_options(self):
self.assertEqual(set(swift.cmake_options), set([
'-DCMAKE_EXPORT_COMPILE_COMMANDS=TRUE',
'-DSWIFT_STDLIB_ENABLE_SIL_OWNERSHIP=FALSE',
'-DSWIFT_ENABLE_GUARANTEED_NORMAL_ARGUMENTS=FALSE',
'-DSWIFT_FORCE_OPTIMIZED_TYPECHECKER=FALSE']))

def test_swift_runtime_tsan(self):
Expand All @@ -95,11 +97,12 @@ def test_swift_runtime_tsan(self):
toolchain=self.toolchain,
source_dir='/path/to/src',
build_dir='/path/to/build')
self.assertEqual(set(swift.cmake_options),
set(['-DSWIFT_RUNTIME_USE_SANITIZERS=Thread',
'-DCMAKE_EXPORT_COMPILE_COMMANDS=TRUE',
'-DSWIFT_STDLIB_ENABLE_SIL_OWNERSHIP=FALSE',
'-DSWIFT_FORCE_OPTIMIZED_TYPECHECKER=FALSE']))
flags_set = set(['-DSWIFT_RUNTIME_USE_SANITIZERS=Thread',
'-DCMAKE_EXPORT_COMPILE_COMMANDS=TRUE',
'-DSWIFT_STDLIB_ENABLE_SIL_OWNERSHIP=FALSE',
'-DSWIFT_ENABLE_GUARANTEED_NORMAL_ARGUMENTS=FALSE',
'-DSWIFT_FORCE_OPTIMIZED_TYPECHECKER=FALSE'])
self.assertEqual(set(swift.cmake_options), flags_set)

def test_swift_compiler_vendor_flags(self):
self.args.compiler_vendor = "none"
Expand Down Expand Up @@ -285,6 +288,18 @@ def test_sil_ownership_flags(self):
[x for x in swift.cmake_options
if 'SWIFT_STDLIB_ENABLE_SIL_OWNERSHIP' in x])

def test_swift_guaranteed_normal_arguments_flags(self):
self.args.enable_guaranteed_normal_arguments = True
swift = Swift(
args=self.args,
toolchain=self.toolchain,
source_dir='/path/to/src',
build_dir='/path/to/build')
self.assertEqual(
['-DSWIFT_ENABLE_GUARANTEED_NORMAL_ARGUMENTS=TRUE'],
[x for x in swift.cmake_options
if 'SWIFT_ENABLE_GUARANTEED_NORMAL_ARGUMENTS' in x])

def test_force_optimized_typechecker_flags(self):
self.args.force_optimized_typechecker = True
swift = Swift(
Expand Down