Skip to content

Commit 9287256

Browse files
committed
Pass -Xcc -std=c++2b to Swift when CLANG_CXX_LANGUAGE_STANDARD is set to c++2b
If pbxproj contains this line: ``` CLANG_CXX_LANGUAGE_STANDARD = "c++2b"; ``` then we should pass the corresponding flag to Swift compiler invocations that enable Swift/C++ interop. Prior to this change, this worked fine for `c++23`, but not `c++2b`. rdar://149474443
1 parent 143dcf4 commit 9287256

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

Sources/SWBUniversalPlatform/Specs/Swift.xcspec

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1420,6 +1420,8 @@
14201420
"objcxx-gnu++20" = ("-Xcc", "-std=$(CLANG_CXX_LANGUAGE_STANDARD)");
14211421
"objcxx-c++23" = ("-Xcc", "-std=$(CLANG_CXX_LANGUAGE_STANDARD)");
14221422
"objcxx-gnu++23" = ("-Xcc", "-std=$(CLANG_CXX_LANGUAGE_STANDARD)");
1423+
"objcxx-c++2b" = ("-Xcc", "-std=$(CLANG_CXX_LANGUAGE_STANDARD)");
1424+
"objcxx-gnu++2b" = ("-Xcc", "-std=$(CLANG_CXX_LANGUAGE_STANDARD)");
14231425
"<<otherwise>>" = ();
14241426
};
14251427
},

Tests/SWBTaskConstructionTests/SwiftTaskConstructionTests.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4052,6 +4052,15 @@ fileprivate struct SwiftTaskConstructionTests: CoreBasedTests {
40524052
}
40534053
}
40544054

4055+
try await withTemporaryDirectory { tmpDir in
4056+
let tester = try await setupInteropTest(tmpDir, enableInterop: true, cxxLangStandard: "c++2b")
4057+
await tester.checkBuild(runDestination: .macOS) { results in
4058+
results.checkTask(.matchRuleType("SwiftDriver Compilation")) { task in
4059+
task.checkCommandLineContainsUninterrupted(["-Xcc", "-std=c++2b"])
4060+
}
4061+
}
4062+
}
4063+
40554064
// Verify that we don't pass C++ settings to Swift compilations when C++
40564065
// interoperability is disabled.
40574066
try await withTemporaryDirectory { tmpDir in

0 commit comments

Comments
 (0)