Skip to content

build: enable control over the C++ interop modules #65398

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 1 commit into from
Apr 28, 2023
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 @@ -605,6 +605,10 @@ option(SWIFT_ENABLE_EXPERIMENTAL_CONCURRENCY
"Enable build of the Swift concurrency module"
FALSE)

option(SWIFT_ENABLE_EXPERIMENTAL_CXX_INTEROP
"Enable experimental C++ interop modules"
FALSE)

option(SWIFT_ENABLE_EXPERIMENTAL_DISTRIBUTED
"Enable experimental distributed actors and functions"
FALSE)
Expand Down
4 changes: 3 additions & 1 deletion stdlib/public/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ endif()

add_subdirectory(SwiftShims/swift/shims)
add_subdirectory(CommandLineSupport)
add_subdirectory(Cxx)
if(SWIFT_ENABLE_EXPERIMENTAL_CXX_INTEROP)
add_subdirectory(Cxx)
endif()
add_subdirectory(Threading)

# This static library is shared across swiftCore and swiftRemoteInspection
Expand Down
2 changes: 2 additions & 0 deletions utils/build-windows-toolchain.bat
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ cmake ^
-D LLVM_VERSION_SUFFIX="" ^

-D SWIFT_ENABLE_EXPERIMENTAL_CONCURRENCY=YES ^
-D SWIFT_ENABLE_EXPERIMENTAL_CXX_INTEROP=YES ^
-D SWIFT_ENABLE_EXPERIMENTAL_DISTRIBUTED=YES ^
-D SWIFT_ENABLE_EXPERIMENTAL_DIFFERENTIABLE_PROGRAMMING=YES ^
-D SWIFT_ENABLE_EXPERIMENTAL_STRING_PROCESSING=YES ^
Expand Down Expand Up @@ -254,6 +255,7 @@ cmake ^
-D SWIFT_PATH_TO_STRING_PROCESSING_SOURCE=%SourceRoot%\swift-experimental-string-processing ^

-D SWIFT_ENABLE_EXPERIMENTAL_CONCURRENCY=YES ^
-D SWIFT_ENABLE_EXPERIMENTAL_CXX_INTEROP=YES ^
-D SWIFT_ENABLE_EXPERIMENTAL_DISTRIBUTED=YES ^
-D SWIFT_ENABLE_EXPERIMENTAL_DIFFERENTIABLE_PROGRAMMING=YES ^
-D SWIFT_ENABLE_EXPERIMENTAL_STRING_PROCESSING=YES ^
Expand Down
1 change: 1 addition & 0 deletions utils/build-windows.bat
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ cmake^
-DSWIFT_BUILD_SOURCEKIT:BOOL=YES^
-DSWIFT_ENABLE_SOURCEKIT_TESTS:BOOL=YES^
-DSWIFT_ENABLE_EXPERIMENTAL_CONCURRENCY=YES^
-DSWIFT_ENABLE_EXPERIMENTAL_CXX_INTEROP=YES^
-DSWIFT_ENABLE_EXPERIMENTAL_DISTRIBUTED=YES^
-DSWIFT_ENABLE_EXPERIMENTAL_DIFFERENTIABLE_PROGRAMMING=YES^
-DSWIFT_ENABLE_EXPERIMENTAL_STRING_PROCESSING=YES^
Expand Down
7 changes: 5 additions & 2 deletions utils/build_swift/build_swift/driver_arguments.py
Original file line number Diff line number Diff line change
Expand Up @@ -1321,10 +1321,13 @@ def create_argument_parser():
default=True,
help='Enable experimental Swift differentiable programming.')

option('--enable-experimental-concurrency', toggle_true,
default=True,
option('--enable-experimental-concurrency', toggle_true, default=True,
help='Enable experimental Swift concurrency model.')

option('--enable-experimental-cxx-interop', toggle_true,
default=True,
help='Enable experimental C++ interop.')

option('--enable-experimental-distributed', toggle_true,
default=True,
help='Enable experimental Swift distributed actors.')
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 @@ -162,6 +162,7 @@
'enable_asan': False,
'enable_experimental_differentiable_programming': True,
'enable_experimental_concurrency': True,
'enable_experimental_cxx_interop': True,
'enable_experimental_distributed': True,
'enable_experimental_string_processing': True,
'enable_experimental_observation': True,
Expand Down Expand Up @@ -579,6 +580,7 @@ class BuildScriptImplOption(_BaseOption):
EnableOption('--enable-asan'),
EnableOption('--enable-experimental-differentiable-programming'),
EnableOption('--enable-experimental-concurrency'),
EnableOption('--enable-experimental-cxx-interop'),
EnableOption('--enable-experimental-distributed'),
EnableOption('--enable-experimental-string-processing'),
EnableOption('--enable-experimental-observation'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ def __init__(self, args, toolchain, source_dir, build_dir):
# Add experimental concurrency flag.
self.cmake_options.extend(self._enable_experimental_concurrency)

# Add experimental cxx interop flag.
self.cmake_options.extend(self._enable_experimental_cxx_interop)

# Add experimental distributed flag.
self.cmake_options.extend(self._enable_experimental_distributed)

Expand Down Expand Up @@ -168,6 +171,11 @@ def _enable_experimental_concurrency(self):
return [('SWIFT_ENABLE_EXPERIMENTAL_CONCURRENCY:BOOL',
self.args.enable_experimental_concurrency)]

@property
def _enable_experimental_cxx_interop(self):
return [('SWIFT_ENABLE_EXPERIMENTAL_CXX_INTEROP:BOOL',
self.args.enable_experimental_cxx_interop)]

@property
def _enable_experimental_distributed(self):
return [('SWIFT_ENABLE_EXPERIMENTAL_DISTRIBUTED:BOOL',
Expand Down
15 changes: 15 additions & 0 deletions utils/swift_build_support/tests/products/test_swift.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ def setUp(self):
enable_stdlibcore_exclusivity_checking=False,
enable_experimental_differentiable_programming=False,
enable_experimental_concurrency=False,
enable_experimental_cxx_interop=False,
enable_experimental_distributed=False,
enable_experimental_observation=False,
swift_enable_backtracing=False,
Expand Down Expand Up @@ -96,6 +97,7 @@ def test_by_default_no_cmake_options(self):
'-DSWIFT_STDLIB_ENABLE_STDLIBCORE_EXCLUSIVITY_CHECKING:BOOL=FALSE',
'-DSWIFT_ENABLE_EXPERIMENTAL_DIFFERENTIABLE_PROGRAMMING:BOOL=FALSE',
'-DSWIFT_ENABLE_EXPERIMENTAL_CONCURRENCY:BOOL=FALSE',
'-DSWIFT_ENABLE_EXPERIMENTAL_CXX_INTEROP:BOOL=FALSE',
'-DSWIFT_ENABLE_EXPERIMENTAL_DISTRIBUTED:BOOL=FALSE',
'-DSWIFT_ENABLE_EXPERIMENTAL_OBSERVATION:BOOL=FALSE',
'-DSWIFT_ENABLE_BACKTRACING:BOOL=FALSE',
Expand All @@ -121,6 +123,7 @@ def test_swift_runtime_tsan(self):
'-DSWIFT_STDLIB_ENABLE_STDLIBCORE_EXCLUSIVITY_CHECKING:BOOL=FALSE',
'-DSWIFT_ENABLE_EXPERIMENTAL_DIFFERENTIABLE_PROGRAMMING:BOOL=FALSE',
'-DSWIFT_ENABLE_EXPERIMENTAL_CONCURRENCY:BOOL=FALSE',
'-DSWIFT_ENABLE_EXPERIMENTAL_CXX_INTEROP:BOOL=FALSE',
'-DSWIFT_ENABLE_EXPERIMENTAL_DISTRIBUTED:BOOL=FALSE',
'-DSWIFT_ENABLE_EXPERIMENTAL_OBSERVATION:BOOL=FALSE',
'-DSWIFT_ENABLE_BACKTRACING:BOOL=FALSE',
Expand Down Expand Up @@ -355,6 +358,18 @@ def test_experimental_concurrency_flags(self):
[x for x in swift.cmake_options
if 'DSWIFT_ENABLE_EXPERIMENTAL_CONCURRENCY' in x])

def test_experimental_cxx_interop_flags(self):
self.args.enable_experimental_cxx_interop = True
swift = Swift(
args=self.args,
toolchain=self.toolchain,
source_dir='/path/to/src',
build_dir='/path/to/build')
self.assertEqual(
['-DSWIFT_ENABLE_EXPERIMENTAL_CXX_INTEROP:BOOL=TRUE'],
[option for option in swift.cmake_options
if 'DSWIFT_ENABLE_EXPERIMENTAL_CXX_INTEROP' in option])

def test_experimental_distributed_flags(self):
self.args.enable_experimental_distributed = True
swift = Swift(
Expand Down