Skip to content

Commit

Permalink
[cmake][build-script] Add support for building the runtime with +0 no…
Browse files Browse the repository at this point in the history
…rmal args.

I am upstreaming some changes to the runtime to support +0 normal arguments.

rdar://34222540
  • Loading branch information
gottesmm committed Dec 31, 2017
1 parent 0a41588 commit 8c0908a
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 5 deletions.
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

0 comments on commit 8c0908a

Please sign in to comment.