diff options
Diffstat (limited to 'pkgs/development/compilers/swift/swiftpm/patches/fix-clang-cxx.patch')
-rw-r--r-- | pkgs/development/compilers/swift/swiftpm/patches/fix-clang-cxx.patch | 48 |
1 files changed, 24 insertions, 24 deletions
diff --git a/pkgs/development/compilers/swift/swiftpm/patches/fix-clang-cxx.patch b/pkgs/development/compilers/swift/swiftpm/patches/fix-clang-cxx.patch index 60c4e33eb154f..93c43c664ed36 100644 --- a/pkgs/development/compilers/swift/swiftpm/patches/fix-clang-cxx.patch +++ b/pkgs/development/compilers/swift/swiftpm/patches/fix-clang-cxx.patch @@ -2,9 +2,20 @@ Swiftpm may invoke clang, not clang++, to compile C++. Our cc-wrapper also doesn't pick up the arguments that enable C++ compilation in this case. Patch swiftpm to properly invoke clang++. +--- a/Sources/Build/BuildPlan.swift ++++ b/Sources/Build/BuildPlan.swift +@@ -2089,7 +2089,7 @@ public class BuildPlan: SPMBuildCore.BuildPlan { + for target in dependencies.staticTargets { + if case let target as ClangTarget = target.underlyingTarget, target.isCXX { + if buildParameters.hostTriple.isDarwin() { +- buildProduct.additionalFlags += ["-lc++"] ++ buildProduct.additionalFlags += ["-lc++", "-lc++abi"] + } else if buildParameters.hostTriple.isWindows() { + // Don't link any C++ library. + } else { --- a/Sources/Build/LLBuildManifestBuilder.swift +++ b/Sources/Build/LLBuildManifestBuilder.swift -@@ -782,7 +782,7 @@ extension LLBuildManifestBuilder { +@@ -786,7 +786,7 @@ extension LLBuildManifestBuilder { args += ["-c", path.source.pathString, "-o", path.object.pathString] @@ -13,21 +24,10 @@ swiftpm to properly invoke clang++. args.insert(clangCompiler, at: 0) let objectFileNode: Node = .file(path.object) ---- a/Sources/PackageModel/Destination.swift -+++ b/Sources/PackageModel/Destination.swift -@@ -153,7 +153,7 @@ public struct Destination: Encodable, Equatable { - - var extraCPPFlags: [String] = [] - #if os(macOS) -- extraCPPFlags += ["-lc++"] -+ extraCPPFlags += ["-lc++", "-lc++abi"] - #elseif os(Windows) - extraCPPFlags += [] - #else --- a/Sources/PackageModel/Toolchain.swift +++ b/Sources/PackageModel/Toolchain.swift -@@ -20,7 +20,7 @@ public protocol Toolchain { - var macosSwiftStdlib: AbsolutePath { get } +@@ -23,7 +23,7 @@ public protocol Toolchain { + var macosSwiftStdlib: AbsolutePath { get throws } /// Path of the `clang` compiler. - func getClangCompiler() throws -> AbsolutePath @@ -46,7 +46,7 @@ swiftpm to properly invoke clang++. private let environment: EnvironmentVariables -@@ -150,29 +150,31 @@ public final class UserToolchain: Toolchain { +@@ -196,29 +196,31 @@ public final class UserToolchain: Toolchain { } /// Returns the path to clang compiler tool. @@ -70,7 +70,7 @@ swiftpm to properly invoke clang++. // Then, check the toolchain. + let tool = isCXX ? "clang++" : "clang"; do { -- if let toolPath = try? UserToolchain.getTool("clang", binDir: self.destination.binDir) { +- if let toolPath = try? UserToolchain.getTool("clang", binDir: self.destination.toolchainBinDir) { - self._clangCompiler = toolPath + if let toolPath = try? UserToolchain.getTool(tool, binDir: self.destination.binDir) { + self._clangCompiler[isCXX] = toolPath @@ -88,18 +88,18 @@ swiftpm to properly invoke clang++. --- a/Sources/SPMBuildCore/BuildParameters.swift +++ b/Sources/SPMBuildCore/BuildParameters.swift -@@ -342,7 +342,7 @@ private struct _Toolchain: Encodable { +@@ -394,7 +394,7 @@ private struct _Toolchain: Encodable { public func encode(to encoder: Encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) try container.encode(toolchain.swiftCompilerPath, forKey: .swiftCompiler) - try container.encode(toolchain.getClangCompiler(), forKey: .clangCompiler) + try container.encode(toolchain.getClangCompiler(isCXX: false), forKey: .clangCompiler) - try container.encode(toolchain.extraCCFlags, forKey: .extraCCFlags) - try container.encode(toolchain.extraCPPFlags, forKey: .extraCPPFlags) + try container.encode(toolchain.extraFlags.cCompilerFlags, forKey: .extraCCFlags) + // Maintaining `extraCPPFlags` key for compatibility with older encoding. --- a/Sources/XCBuildSupport/XcodeBuildSystem.swift +++ b/Sources/XCBuildSupport/XcodeBuildSystem.swift -@@ -172,7 +172,7 @@ public final class XcodeBuildSystem: SPMBuildCore.BuildSystem { +@@ -182,7 +182,7 @@ public final class XcodeBuildSystem: SPMBuildCore.BuildSystem { // Generate a table of any overriding build settings. var settings: [String: String] = [:] // An error with determining the override should not be fatal here. @@ -107,15 +107,15 @@ swiftpm to properly invoke clang++. + settings["CC"] = try? buildParameters.toolchain.getClangCompiler(isCXX: false).pathString // Always specify the path of the effective Swift compiler, which was determined in the same way as for the native build system. settings["SWIFT_EXEC"] = buildParameters.toolchain.swiftCompilerPath.pathString - settings["LIBRARY_SEARCH_PATHS"] = "$(inherited) \(buildParameters.toolchain.toolchainLibDir.pathString)" + settings["LIBRARY_SEARCH_PATHS"] = "$(inherited) \(try buildParameters.toolchain.toolchainLibDir.pathString)" --- a/Tests/BuildTests/MockBuildTestHelper.swift +++ b/Tests/BuildTests/MockBuildTestHelper.swift -@@ -15,7 +15,7 @@ struct MockToolchain: PackageModel.Toolchain { +@@ -23,7 +23,7 @@ struct MockToolchain: PackageModel.Toolchain { #else - let extraCPPFlags: [String] = ["-lstdc++"] + let extraFlags = BuildFlags(cxxCompilerFlags: ["-lstdc++"]) #endif - func getClangCompiler() throws -> AbsolutePath { + func getClangCompiler(isCXX: Bool) throws -> AbsolutePath { - return AbsolutePath("/fake/path/to/clang") + return AbsolutePath(path: "/fake/path/to/clang") } |