From 9f44e0d56b466c9e004af54b2c58c8bb9e127765 Mon Sep 17 00:00:00 2001 From: Egor Zhdan Date: Tue, 17 Sep 2024 18:20:21 +0100 Subject: [PATCH] [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. --- benchmark/Package.swift | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/benchmark/Package.swift b/benchmark/Package.swift index 1a3b2f5b44f..47156834803 100644 --- a/benchmark/Package.swift +++ b/benchmark/Package.swift @@ -1,4 +1,4 @@ -// swift-tools-version:5.4 +// swift-tools-version:5.9 import PackageDescription import Foundation @@ -127,11 +127,9 @@ targets.append( dependencies: swiftBenchDeps, path: "utils", sources: ["main.swift"], - swiftSettings: [.unsafeFlags(["-cxx-interoperability-mode=default", - "-I", - "utils/CxxTests", - // FIXME(rdar://136138941): these flags should be redundant because of cxxLanguageStandard - "-Xcc", "-std=c++20"])])) + swiftSettings: [.interoperabilityMode(.Cxx), + .unsafeFlags(["-I", + "utils/CxxTests"])])) #if os(macOS) || os(iOS) || os(watchOS) || os(tvOS) targets.append( @@ -167,11 +165,9 @@ targets += cxxSingleSourceLibraries.map { name in dependencies: singleSourceDeps, path: "cxx-source", sources: ["\(name).swift"], - swiftSettings: [.unsafeFlags(["-cxx-interoperability-mode=default", - "-I", + swiftSettings: [.interoperabilityMode(.Cxx), + .unsafeFlags(["-I", "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 "-Xfrontend", "-validate-tbd-against-ir=none"])]) }