Some checks failed
Periodic Merges (6h) / master → staging-nixos (push) Failing after 12m50s
Periodic Merges (6h) / master → staging-next (push) Failing after 12m54s
Periodic Merges (24h) / merge-base(master,staging) → haskell-updates (push) Failing after 11m54s
Periodic Merges (6h) / staging-next → staging (push) Failing after 12m13s
Periodic Merges (24h) / staging-next-25.05 → staging-25.05 (push) Failing after 13m24s
Periodic Merges (24h) / release-25.05 → staging-next-25.05 (push) Failing after 14m28s
41 lines
1.9 KiB
Diff
41 lines
1.9 KiB
Diff
diff --git a/Sources/SwiftDriver/Jobs/GenericUnixToolchain+LinkerSupport.swift b/Sources/SwiftDriver/Jobs/GenericUnixToolchain+LinkerSupport.swift
|
|
index a4a735f498..381522cc1f 100644
|
|
--- a/Sources/SwiftDriver/Jobs/GenericUnixToolchain+LinkerSupport.swift
|
|
+++ b/Sources/SwiftDriver/Jobs/GenericUnixToolchain+LinkerSupport.swift
|
|
@@ -10,6 +10,7 @@
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
+import Foundation
|
|
import SwiftOptions
|
|
|
|
import func TSCBasic.lookupExecutablePath
|
|
@@ -120,7 +121,18 @@
|
|
// just using `clang` and avoid a dependency on the C++ runtime.
|
|
let clangTool: Tool =
|
|
parsedOptions.hasArgument(.enableExperimentalCxxInterop) ? .clangxx : .clang
|
|
- var clangPath = try getToolPath(clangTool)
|
|
+
|
|
+ // For Nix, prefer linking using the wrapped Nixpkgs clang, instead of using
|
|
+ // the unwrapped clang packaged with swift. The latter is unable to link, but
|
|
+ // we still want to use it for other purposes (clang importer).
|
|
+ var clangPath: AbsolutePath
|
|
+ if let binPath = try? AbsolutePath(validating: "@clang@/bin"),
|
|
+ let tool = lookupExecutablePath(filename: parsedOptions.hasArgument(.enableExperimentalCxxInterop)
|
|
+ ? "clang++" : "clang",
|
|
+ searchPaths: [binPath]) {
|
|
+ clangPath = tool
|
|
+ } else {
|
|
+ clangPath = try getToolPath(clangTool)
|
|
if let toolsDirPath = parsedOptions.getLastArgument(.toolsDirectory) {
|
|
// FIXME: What if this isn't an absolute path?
|
|
let toolsDir = try AbsolutePath(validating: toolsDirPath.asSingle)
|
|
@@ -136,6 +148,7 @@
|
|
commandLine.appendFlag("-B")
|
|
commandLine.appendPath(toolsDir)
|
|
}
|
|
+ } // Nix
|
|
|
|
// Executables on Linux get -pie
|
|
if targetTriple.os == .linux && linkerOutputType == .executable {
|