Skip to content

Commit 54ec38b

Browse files
authored
Merge pull request #1517 from phausler/pr/embedded_link_paths
[Embedded] correct link paths when building for embedded to avoid stray response file paths
2 parents 28ffedb + ce7b169 commit 54ec38b

File tree

2 files changed

+38
-2
lines changed

2 files changed

+38
-2
lines changed

Sources/SwiftDriver/Jobs/GenericUnixToolchain+LinkerSupport.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,9 +253,11 @@ extension GenericUnixToolchain {
253253
linkFilePath = linkFilePath?.appending(component: "static-executable-args.lnk")
254254
} else if staticStdlib {
255255
linkFilePath = linkFilePath?.appending(component: "static-stdlib-args.lnk")
256-
} else if !isEmbeddedEnabled {
256+
} else {
257257
linkFilePath = nil
258-
commandLine.appendFlag("-lswiftCore")
258+
if !isEmbeddedEnabled {
259+
commandLine.appendFlag("-lswiftCore")
260+
}
259261
}
260262

261263
if let linkFile = linkFilePath {

Tests/SwiftDriverTests/SwiftDriverTests.swift

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6494,6 +6494,40 @@ final class SwiftDriverTests: XCTestCase {
64946494
XCTAssertTrue(compileJob.commandLine.contains(.flag("-disable-objc-interop")))
64956495
XCTAssertFalse(linkJob.commandLine.contains(.flag("-force_load")))
64966496
}
6497+
6498+
do {
6499+
var driver = try Driver(args: [
6500+
"swiftc",
6501+
"-v",
6502+
"-L",
6503+
"/TestApp/.build/aarch64-none-none-elf/release",
6504+
"-o",
6505+
"/TestApp/.build/aarch64-none-none-elf/release/TestApp",
6506+
"-module-name",
6507+
"TestApp",
6508+
"-emit-executable",
6509+
"-Xlinker",
6510+
"--gc-sections",
6511+
"@/TestApp/.build/aarch64-none-none-elf/release/TestApp.product/Objects.LinkFileList",
6512+
"-target",
6513+
"aarch64-none-none-elf",
6514+
"-enable-experimental-feature", "Embedded",
6515+
"-Xfrontend",
6516+
"-function-sections",
6517+
"-Xfrontend",
6518+
"-disable-stack-protector",
6519+
"-use-ld=lld",
6520+
"-tools-directory",
6521+
"/Tools/swift.xctoolchain/usr/bin",
6522+
], env: env)
6523+
6524+
let jobs = try driver.planBuild()
6525+
let linkJob = try jobs.findJob(.link)
6526+
let invalidPath = try VirtualPath(path: "/Tools/swift.xctoolchain/usr/lib/swift")
6527+
let invalid = linkJob.commandLine.contains(.responseFilePath(invalidPath))
6528+
XCTAssertFalse(invalid) // ensure the driver does not emit invalid responseFilePaths to the clang invocation
6529+
}
6530+
64976531
do {
64986532
var driver = try Driver(args: ["swiftc", "-target", "wasm32-none-none-wasm", "test.swift", "-enable-experimental-feature", "Embedded", "-wmo", "-o", "a.wasm"], env: env)
64996533
let plannedJobs = try driver.planBuild()

0 commit comments

Comments
 (0)