1
0
Fork 0
mirror of https://github.com/NixOS/nixpkgs.git synced 2025-06-27 11:36:29 +03:00
nixpkgs/pkgs/development/compilers/swift/swift-driver/patches/nix-resource-root.patch

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

29 lines
1.1 KiB
Diff
Raw Permalink Normal View History

2022-08-26 08:09:17 +02:00
Swift normally looks for the Clang resource dir in a subdir/symlink of its own
resource dir. We provide a symlink to the Swift build-time Clang as a default
there, but we also here patch a check to try locate it via NIX_CC.
--- a/Sources/SwiftDriver/Jobs/Toolchain+LinkerSupport.swift
+++ b/Sources/SwiftDriver/Jobs/Toolchain+LinkerSupport.swift
2023-04-01 21:43:12 +02:00
@@ -10,6 +10,7 @@
2022-08-26 08:09:17 +02:00
//
//===----------------------------------------------------------------------===//
2023-04-01 21:43:12 +02:00
2022-08-26 08:09:17 +02:00
+import Foundation
import SwiftOptions
2023-04-01 21:43:12 +02:00
import protocol TSCBasic.FileSystem
@@ -26,6 +27,13 @@ extension Toolchain {
2022-08-26 08:09:17 +02:00
for targetInfo: FrontendTargetInfo,
parsedOptions: inout ParsedOptions
) throws -> VirtualPath {
+ let env = ProcessInfo.processInfo.environment
+ if let nixCC = env["NIX_CC"] {
+ return try VirtualPath(path: nixCC)
+ .appending(components: "resource-root", "lib",
+ targetInfo.target.triple.platformName(conflatingDarwin: true)!)
+ }
+
return VirtualPath.lookup(targetInfo.runtimeResourcePath.path)
.appending(components: "clang", "lib",
targetInfo.target.triple.platformName(conflatingDarwin: true)!)