Skip to content

Commit 1845414

Browse files
authored
Merge pull request #60225 from bnbarham/move-cxx-interop-back-to-driver
[Options] Move CXX interop back to a driver option
2 parents 9f052eb + 3ac5802 commit 1845414

File tree

4 files changed

+12
-12
lines changed

4 files changed

+12
-12
lines changed

docs/CppInteroperability/GettingStartedWithC++Interop.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,12 @@ module Cxx {
3434
Add the C++ module to the include path and enable C++ interop:
3535
- Navigate to your project directory
3636
- In `Project` navigate to `Build Settings` -> `Swift Compiler`
37-
- Under `Custom Flags` -> `Other Swift Flags` add`-Xfrontend -enable-experimental-cxx-interop`
37+
- Under `Custom Flags` -> `Other Swift Flags` add`-enable-experimental-cxx-interop`
3838
- Under `Search Paths` -> `Import Paths` add your search path to the C++ module (i.e, `./ProjectName/Cxx`). Repeat this step in `Other Swift Flags`
3939

4040
```
4141
//Add to Other Swift Flags and Import Paths respectively
42-
-Xfrontend -enable-experimental-cxx-interop
42+
-enable-experimental-cxx-interop
4343
-I./ProjectName/Cxx
4444
```
4545

@@ -118,7 +118,7 @@ let package = Package(
118118
sources: [ "main.swift" ],
119119
swiftSettings: [.unsafeFlags([
120120
"-I", "Sources/Cxx",
121-
"-Xfrontend", "-enable-experimental-cxx-interop",
121+
"-enable-experimental-cxx-interop",
122122
])]
123123
),
124124
]
@@ -151,7 +151,7 @@ After creating your project follow the steps [Creating a Module to contain your
151151
- Create a `CMakeLists.txt` file and configure for your project
152152
- In`add_library` invoke `cxx-support` with the path to the C++ implementation file
153153
- Add the `target_include_directories` with `cxx-support` and path to the C++ Module `${CMAKE_SOURCE_DIR}/Sources/Cxx`
154-
- Add the `add_executable` to the specific files/directory you would like to generate source, with`SHELL:-Xfrontend -enable-experimental-cxx-interop`.
154+
- Add the `add_executable` to the specific files/directory you would like to generate source, with`SHELL:-enable-experimental-cxx-interop`.
155155
- In the example below we will be following the file structure used in [Creating a Swift Package](#Creating-a-Swift-Package)
156156

157157
```
@@ -176,7 +176,7 @@ target_include_directories(cxx-support PUBLIC
176176
177177
add_executable(CxxInterop ./Sources/CxxInterop/main.swift)
178178
target_compile_options(CxxInterop PRIVATE
179-
"SHELL:-Xfrontend -enable-experimental-cxx-interop"
179+
"SHELL:-enable-experimental-cxx-interop"
180180
target_link_libraries(CxxInterop PRIVATE cxx-support)
181181
182182
```

include/swift/Option/FrontendOptions.td

-4
Original file line numberDiff line numberDiff line change
@@ -282,10 +282,6 @@ def enable_experimental_concurrency :
282282
Flag<["-"], "enable-experimental-concurrency">,
283283
HelpText<"Enable experimental concurrency model">;
284284

285-
def enable_experimental_cxx_interop :
286-
Flag<["-"], "enable-experimental-cxx-interop">,
287-
HelpText<"Enable C++ interop code generation and config directives">;
288-
289285
def enable_lexical_borrow_scopes :
290286
Joined<["-"], "enable-lexical-borrow-scopes=">,
291287
HelpText<"Whether to emit lexical borrow scopes (default: true)">,

include/swift/Option/Options.td

+6
Original file line numberDiff line numberDiff line change
@@ -612,8 +612,14 @@ def enable_experimental_concise_pound_file : Flag<["-"],
612612
Flags<[FrontendOption, ModuleInterfaceOption]>,
613613
HelpText<"Enable experimental concise '#file' identifier">;
614614

615+
def enable_experimental_cxx_interop :
616+
Flag<["-"], "enable-experimental-cxx-interop">,
617+
Flags<[FrontendOption, HelpHidden]>,
618+
HelpText<"Enable experimental C++ interop code generation and config directives">;
619+
615620
def experimental_cxx_stdlib :
616621
Separate<["-"], "experimental-cxx-stdlib">,
622+
Flags<[HelpHidden]>,
617623
HelpText<"C++ standard library to use; forwarded to Clang's -stdlib flag">;
618624

619625
def experimental_emit_module_separately:

lib/Driver/ToolChains.cpp

+1-3
Original file line numberDiff line numberDiff line change
@@ -189,9 +189,6 @@ void ToolChain::addCommonFrontendArgs(const OutputInfo &OI,
189189
}
190190

191191
// Add flags for C++ interop.
192-
if (inputArgs.hasArg(options::OPT_enable_experimental_cxx_interop)) {
193-
arguments.push_back("-enable-experimental-cxx-interop");
194-
}
195192
if (const Arg *arg =
196193
inputArgs.getLastArg(options::OPT_experimental_cxx_stdlib)) {
197194
arguments.push_back("-Xcc");
@@ -302,6 +299,7 @@ void ToolChain::addCommonFrontendArgs(const OutputInfo &OI,
302299
inputArgs.AddLastArg(arguments, options::OPT_access_notes_path);
303300
inputArgs.AddLastArg(arguments, options::OPT_library_level);
304301
inputArgs.AddLastArg(arguments, options::OPT_enable_bare_slash_regex);
302+
inputArgs.AddLastArg(arguments, options::OPT_enable_experimental_cxx_interop);
305303

306304
// Pass on any build config options
307305
inputArgs.AddAllArgs(arguments, options::OPT_D);

0 commit comments

Comments
 (0)