Skip to content

Commit 2c9716b

Browse files
committed
Fix various problems
1 parent 9076ab2 commit 2c9716b

File tree

3 files changed

+24
-25
lines changed

3 files changed

+24
-25
lines changed

Sources/SwiftDriver/Jobs/Toolchain+LinkerSupport.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ extension Toolchain {
6060
let root = try? AbsolutePath(validating: vctools) {
6161
let archName: String = {
6262
switch triple.arch {
63-
case .aarch64, .aarch64_32: return "arm64"
63+
case .aarch64: return "arm64"
6464
case .arm: return "arm"
6565
case .x86: return "x86"
6666
case nil, .x86_64: return "x64"
@@ -280,4 +280,4 @@ extension DarwinToolchain {
280280

281281
}
282282

283-
// TODO: See whether Windows needs `addArgsToLinkStdlib`.
283+
// TODO: Implement `addArgsToLinkStdlib` for `WindowsToolchain`.

Sources/SwiftDriver/Jobs/WindowsToolchain+LinkerSupport.swift

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -27,24 +27,26 @@ extension WindowsToolchain {
2727
let targetTriple = targetInfo.target.triple
2828
switch linkerOutputType {
2929
case .dynamicLibrary:
30-
// Same options as an executable, just with '-shared'
3130
commandLine.appendFlags("-parse-as-library", "-emit-library")
32-
fallthrough
3331
case .executable:
3432
if !targetTriple.triple.isEmpty {
3533
commandLine.appendFlag("-target")
3634
commandLine.appendFlag(targetTriple.triple)
3735
}
38-
commandLine.appendFlag("-emit-executable")
36+
commandLine.appendFlag("-emit-executable")
3937
default:
4038
break
4139
}
42-
40+
4341
switch linkerOutputType {
4442
case .staticLibrary:
45-
commandLine.append(.joinedOptionAndPath("-out:", outputFile))
46-
commandLine.append(contentsOf: inputs.map { .path($0.file) })
43+
commandLine.append(.joinedOptionAndPath("-out:", outputFile))
44+
commandLine.append(contentsOf: inputs.map { .path($0.file) })
45+
if commandLine.contains(.flag("-use-ld=lld")) {
46+
return try lookup(executable: "llvm-lib.exe")
47+
}
4748
return try getToolPath(.staticLinker)
49+
// TODO: Check for `-use-ld=lld`.
4850
default:
4951
// Configure the toolchain.
5052
//
@@ -93,17 +95,6 @@ extension WindowsToolchain {
9395
isShared: hasRuntimeArgs
9496
)
9597

96-
if hasRuntimeArgs {
97-
// FIXME: We probably shouldn't be adding an rpath here unless we know
98-
// ahead of time the standard library won't be copied.
99-
for path in runtimePaths {
100-
commandLine.appendFlag(.Xlinker)
101-
commandLine.appendFlag("-rpath")
102-
commandLine.appendFlag(.Xlinker)
103-
commandLine.appendPath(path)
104-
}
105-
}
106-
10798
let sharedResourceDirPath = try computeResourceDirPath(
10899
for: targetTriple,
109100
parsedOptions: &parsedOptions,
@@ -214,6 +205,5 @@ extension WindowsToolchain {
214205
commandLine.appendPath(outputFile)
215206
return clangPath
216207
}
217-
218208
}
219209
}

Sources/SwiftDriver/Toolchains/WindowsToolchain.swift

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,16 +55,16 @@ public final class WindowsToolchain: Toolchain {
5555
case .swiftCompiler:
5656
return try lookup(executable: "swift-frontend.exe")
5757
case .staticLinker:
58-
return try lookup(executable: "llvm-lib.exe")
58+
return try lookup(executable: "lib.exe")
5959
case .dynamicLinker:
6060
// FIXME: This needs to look in the tools_directory first.
61-
return try lookup(executable: "lld-link.exe")
61+
return try lookup(executable: "link.exe")
6262
case .clang:
6363
return try lookup(executable: "clang.exe")
6464
case .swiftAutolinkExtract:
65-
return try lookup(executable: "swift-autolink-extract.exe")
65+
fatalError("Trying to look up \"swift-autolink-extract\" on Windows")
6666
case .dsymutil:
67-
return try lookup(executable: "dsymutil.exe")
67+
fatalError("Trying to look up \"dsymutil\" on Windows")
6868
case .lldb:
6969
return try lookup(executable: "lldb.exe")
7070
case .dwarfdump:
@@ -89,6 +89,15 @@ public final class WindowsToolchain: Toolchain {
8989
targetTriple: Triple,
9090
isShared: Bool
9191
) throws -> String {
92-
return "clang_rt.\(sanitizer.libraryName)-\(targetTriple.archName).dll"
92+
let archName: String = {
93+
switch targetTriple.arch {
94+
case .aarch64: return "aarch64"
95+
case .arm: return "armv7"
96+
case .x86: return "i386"
97+
case nil, .x86_64: return "x86_64"
98+
default: fatalError("unknown arch \(targetTriple.archName) on Windows")
99+
}
100+
}()
101+
return "clang_rt.\(sanitizer.libraryName)-\(archName).lib"
93102
}
94103
}

0 commit comments

Comments
 (0)