[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.
This commit is contained in:
Egor Zhdan
2024-09-17 18:20:21 +01:00
parent ad503afc72
commit 9f44e0d56b

View File

@@ -1,4 +1,4 @@
// swift-tools-version:5.4 // swift-tools-version:5.9
import PackageDescription import PackageDescription
import Foundation import Foundation
@@ -127,11 +127,9 @@ targets.append(
dependencies: swiftBenchDeps, dependencies: swiftBenchDeps,
path: "utils", path: "utils",
sources: ["main.swift"], sources: ["main.swift"],
swiftSettings: [.unsafeFlags(["-cxx-interoperability-mode=default", swiftSettings: [.interoperabilityMode(.Cxx),
"-I", .unsafeFlags(["-I",
"utils/CxxTests", "utils/CxxTests"])]))
// FIXME(rdar://136138941): these flags should be redundant because of cxxLanguageStandard
"-Xcc", "-std=c++20"])]))
#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS) #if os(macOS) || os(iOS) || os(watchOS) || os(tvOS)
targets.append( targets.append(
@@ -167,11 +165,9 @@ targets += cxxSingleSourceLibraries.map { name in
dependencies: singleSourceDeps, dependencies: singleSourceDeps,
path: "cxx-source", path: "cxx-source",
sources: ["\(name).swift"], sources: ["\(name).swift"],
swiftSettings: [.unsafeFlags(["-cxx-interoperability-mode=default", swiftSettings: [.interoperabilityMode(.Cxx),
"-I", .unsafeFlags(["-I",
"utils/CxxTests", "utils/CxxTests",
// FIXME(rdar://136138941): these flags should be redundant because of cxxLanguageStandard
"-Xcc", "-std=c++20",
// FIXME: https://github.com/apple/swift/issues/61453 // FIXME: https://github.com/apple/swift/issues/61453
"-Xfrontend", "-validate-tbd-against-ir=none"])]) "-Xfrontend", "-validate-tbd-against-ir=none"])])
} }