Skip to content

[5.5] Pass .tbd inputs down to the linker invocation. #704

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Sources/SwiftDriver/Jobs/DarwinToolchain+LinkerSupport.swift
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,8 @@ extension DarwinToolchain {
inputModules.append(input.file)
} else if input.type == .object {
inputPaths.append(input.file)
} else if input.type == .tbd {
inputPaths.append(input.file)
} else if input.type == .llvmBitcode {
inputPaths.append(input.file)
}
Expand All @@ -291,6 +293,8 @@ extension DarwinToolchain {
return [.flag("-add_ast_path"), .path(path.file)]
} else if path.type == .object {
return [.path(path.file)]
} else if path.type == .tbd {
return [.path(path.file)]
} else if path.type == .llvmBitcode {
return [.path(path.file)]
} else {
Expand Down
2 changes: 1 addition & 1 deletion Sources/SwiftDriver/Jobs/Planning.swift
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ extension Driver {
addCompileJobGroup: addCompileJobGroup,
addJobOutputs: addJobOutputs)

case .object, .autolink, .llvmBitcode:
case .object, .autolink, .llvmBitcode, .tbd:
if linkerOutputType != nil {
addLinkerInput(input)
} else {
Expand Down
11 changes: 11 additions & 0 deletions Tests/SwiftDriverTests/SwiftDriverTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1018,6 +1018,17 @@ final class SwiftDriverTests: XCTestCase {
XCTAssertFalse(cmd.contains(.flag("-shared")))
}

do {
// .tbd inputs are passed down to the linker.
var driver = try Driver(args: commonArgs + ["foo.dylib", "foo.tbd", "-target", "x86_64-apple-macosx10.15"], env: env)
let plannedJobs = try driver.planBuild()
let linkJob = plannedJobs[2]
XCTAssertEqual(linkJob.kind, .link)
let cmd = linkJob.commandLine
XCTAssertTrue(cmd.contains(.path(try VirtualPath(path: "foo.tbd"))))
XCTAssertTrue(cmd.contains(.path(try VirtualPath(path: "foo.dylib"))))
}

do {
// iOS target
var driver = try Driver(args: commonArgs + ["-emit-library", "-target", "arm64-apple-ios10.0"], env: env)
Expand Down