Skip to content

Commit 9f44e0d

Browse files
committed
[cxx-interop] Build benchmarks with modern C++ interop flag
To build benchmarks that use C++ `std::span`, we need to use C++20 standard. SwiftPM supports `.interoperabilityMode(.Cxx)` build setting starting from version 5.9. In more recent versions, SwiftPM is also able to correctly propagate the C++ standard version (e.g. `-Xcc -std=c++20`) to the Swift compiler invocation, when C++ interop is enabled. The C++ standard version is only propagated if the modern build setting is used. This has caused Linux CI failures in the past. This change switches the package manifest to use the modern build setting to enable C++ interop.
1 parent ad503af commit 9f44e0d

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

benchmark/Package.swift

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// swift-tools-version:5.4
1+
// swift-tools-version:5.9
22

33
import PackageDescription
44
import Foundation
@@ -127,11 +127,9 @@ targets.append(
127127
dependencies: swiftBenchDeps,
128128
path: "utils",
129129
sources: ["main.swift"],
130-
swiftSettings: [.unsafeFlags(["-cxx-interoperability-mode=default",
131-
"-I",
132-
"utils/CxxTests",
133-
// FIXME(rdar://136138941): these flags should be redundant because of cxxLanguageStandard
134-
"-Xcc", "-std=c++20"])]))
130+
swiftSettings: [.interoperabilityMode(.Cxx),
131+
.unsafeFlags(["-I",
132+
"utils/CxxTests"])]))
135133

136134
#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS)
137135
targets.append(
@@ -167,11 +165,9 @@ targets += cxxSingleSourceLibraries.map { name in
167165
dependencies: singleSourceDeps,
168166
path: "cxx-source",
169167
sources: ["\(name).swift"],
170-
swiftSettings: [.unsafeFlags(["-cxx-interoperability-mode=default",
171-
"-I",
168+
swiftSettings: [.interoperabilityMode(.Cxx),
169+
.unsafeFlags(["-I",
172170
"utils/CxxTests",
173-
// FIXME(rdar://136138941): these flags should be redundant because of cxxLanguageStandard
174-
"-Xcc", "-std=c++20",
175171
// FIXME: https://github.com/apple/swift/issues/61453
176172
"-Xfrontend", "-validate-tbd-against-ir=none"])])
177173
}

0 commit comments

Comments
 (0)