Skip to content

Remove swiftmodule from linker filelist input #1581

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
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
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ extension DarwinToolchain {
var inputModules = [VirtualPath]()
for input in inputs {
if input.type == .swiftModule && linkerOutputType != .staticLibrary {
inputPaths.append(input.file)
inputModules.append(input.file)
} else if input.type == .object {
inputPaths.append(input.file)
Expand Down
29 changes: 29 additions & 0 deletions Tests/SwiftDriverTests/SwiftDriverTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3097,6 +3097,35 @@ final class SwiftDriverTests: XCTestCase {
XCTAssertTrue(firstKeyOutputs.keys.contains(where: { $0 == .swiftModule }))
}

func testLinkFilelistWithDebugInfo() throws {
func getFileListElements(for filelistOpt: String, job: Job) -> [VirtualPath] {
guard let optIdx = job.commandLine.firstIndex(of: .flag(filelistOpt)) else {
XCTFail("Argument '\(filelistOpt)' not in job command line")
return []
}
let value = job.commandLine[job.commandLine.index(after: optIdx)]
guard case let .path(.fileList(_, valueFileList)) = value else {
XCTFail("Argument wasn't a filelist")
return []
}
guard case let .list(inputs) = valueFileList else {
XCTFail("FileList wasn't a List")
return []
}
return inputs
}

var driver = try Driver(args: [
"swiftc", "-g", "/tmp/hello.swift", "-module-name", "Hello",
"-emit-library", "-driver-filelist-threshold=0"
])

var jobs = try driver.planBuild()
XCTAssertEqual(jobs.count, 4)
XCTAssertEqual(getFileListElements(for: "-filelist", job: jobs[2]),
[.temporary(try .init(validating: "hello-1.o"))])
}

func testDashDashPassingDownInput() throws {
do {
var driver = try Driver(args: ["swiftc", "-module-name=ThisModule", "-wmo", "-num-threads", "4", "-emit-module", "-o", "test.swiftmodule", "--", "main.swift", "multi-threaded.swift"])
Expand Down