Skip to content

[Build-Script]: Extend Swift cmake options #81364

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
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
16 changes: 8 additions & 8 deletions utils/build-presets.ini
Original file line number Diff line number Diff line change
Expand Up @@ -3138,20 +3138,20 @@ build-swift-examples=0
build-runtime-with-host-compiler=0
build-swift-libexec=0
build-swift-remote-mirror=0
build-swift-static-sdk-overlay=0
build-swift-static-stdlib=0
enable-experimental-concurrency=1
enable-experimental-distributed=0
enable-experimental-observation=0
enable-experimental-differentiable-programming=0

extra-cmake-options=
extra-llvm-cmake-options=
-DLLVM_TARGETS_TO_BUILD=AArch64;X86

swift-cmake-options=
-DSWIFT_ENABLE_EXPERIMENTAL_CONCURRENCY:BOOL=YES
-DSWIFT_ENABLE_EXPERIMENTAL_OBSERVATION:BOOL=NO
-DSWIFT_ENABLE_EXPERIMENTAL_DISTRIBUTED:BOOL=NO
-DSWIFT_ENABLE_EXPERIMENTAL_DIFFERENTIABLE_PROGRAMMING:BOOL=NO
extra-swift-cmake-options=
-DSWIFT_ENABLE_SWIFT_IN_SWIFT:BOOL=NO
-DSWIFT_INCLUDE_DOCS:BOOL=NO
-DSWIFT_BUILD_EXAMPLES:BOOL=OFF
-DSWIFT_BUILD_STATIC_SDK_OVERLAY:BOOL=NO
-DSWIFT_BUILD_STATIC_STDLIB:BOOL=NO

build-subdir=%(build_subdir)s
install-destdir=%(install_destdir)s
Expand Down
13 changes: 13 additions & 0 deletions utils/build_swift/build_swift/driver_arguments.py
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,12 @@ def create_argument_parser():
'will get little benefit from it (e.g. tools for '
'bootstrapping or debugging Swift)')

option('--extra-swift-cmake-options', append,
type=argparse.ShellSplitType(),
help='Pass additional CMake options to the Swift build. '
'Can be passed multiple times to add multiple options.',
default=[])

option('--dsymutil-jobs', store_int,
default=defaults.DSYMUTIL_JOBS,
metavar='COUNT',
Expand Down Expand Up @@ -1403,6 +1409,13 @@ def create_argument_parser():
help='CMake options used for llvm in the form of comma '
'separated options "-DCMAKE_VAR1=YES,-DCMAKE_VAR2=/tmp". Can '
'be called multiple times to add multiple such options.')
option('--extra-llvm-cmake-options', append,
type=argparse.ShellSplitType(),
help='Pass additional CMake options to the LLVM build. '
'Can be passed multiple times to add multiple options. '
'These are the last arguments passed to CMake and can override '
'existing options.',
default=[])

option('--llvm-build-compiler-rt-with-use-runtimes', toggle_true, default=True,
help='Switch to LLVM_ENABLE_RUNTIMES as the mechanism to build compiler-rt'
Expand Down
4 changes: 4 additions & 0 deletions utils/build_swift/tests/expected_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,9 @@
'enable_ubsan': False,
'export_compile_commands': False,
'extra_cmake_options': [],
'extra_llvm_cmake_options': [],
'extra_swift_args': [],
'extra_swift_cmake_options': [],
'swift_debuginfo_non_lto_args': None,
'force_optimized_typechecker': False,
'foundation_build_variant': 'Debug',
Expand Down Expand Up @@ -803,6 +805,7 @@ class BuildScriptImplOption(_BaseOption):
StrOption('--swift-darwin-module-archs'),
StrOption('--swift-darwin-supported-archs'),
SetTrueOption('--swift-freestanding-is-darwin'),
AppendOption('--extra-swift-cmake-options'),

StrOption('--linux-archs'),
StrOption('--linux-static-archs'),
Expand Down Expand Up @@ -853,6 +856,7 @@ class BuildScriptImplOption(_BaseOption):
AppendOption('--llvm-ninja-targets'),
AppendOption('--llvm-ninja-targets-for-cross-compile-hosts'),
AppendOption('--llvm-cmake-options'),
AppendOption('--extra-llvm-cmake-options'),
EnableOption('--llvm-build-compiler-rt-with-use-runtimes'),
AppendOption('--darwin-symroot-path-filters'),

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,7 @@ def build(self, host_target):

self.cmake_options.extend(host_config.cmake_options)
self.cmake_options.extend(llvm_cmake_options)
self.cmake_options.extend_raw(self.args.extra_llvm_cmake_options)

self._handle_cxx_headers(host_target, platform)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ def __init__(self, args, toolchain, source_dir, build_dir):
self.cmake_options.extend(
self._enable_new_runtime_build)

self.cmake_options.extend_raw(self.args.extra_swift_cmake_options)

@classmethod
def product_source_name(cls):
"""product_source_name() -> str
Expand Down
3 changes: 3 additions & 0 deletions utils/swift_build_support/tests/products/test_swift.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ def setUp(self):
benchmark_num_o_iterations=3,
disable_guaranteed_normal_arguments=True,
force_optimized_typechecker=False,
extra_swift_cmake_options=["-DHELLO=YES"],
enable_stdlibcore_exclusivity_checking=False,
enable_experimental_differentiable_programming=False,
enable_experimental_concurrency=False,
Expand Down Expand Up @@ -125,6 +126,7 @@ def test_by_default_no_cmake_options(self):
'-USWIFT_DEBUGINFO_NON_LTO_ARGS',
'-DSWIFT_STDLIB_BUILD_SYMBOL_GRAPHS:BOOL=FALSE',
'-DSWIFT_ENABLE_NEW_RUNTIME_BUILD:BOOL=FALSE',
'-DHELLO=YES',
]
self.assertEqual(set(swift.cmake_options), set(expected))

Expand Down Expand Up @@ -161,6 +163,7 @@ def test_swift_runtime_tsan(self):
'-USWIFT_DEBUGINFO_NON_LTO_ARGS',
'-DSWIFT_STDLIB_BUILD_SYMBOL_GRAPHS:BOOL=FALSE',
'-DSWIFT_ENABLE_NEW_RUNTIME_BUILD:BOOL=FALSE',
'-DHELLO=YES',
]
self.assertEqual(set(swift.cmake_options), set(flags_set))

Expand Down