Skip to content
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

Passthrough -tools-directory as -B to clang linker for Wasm target #1551

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -73,6 +73,10 @@ extension WebAssemblyToolchain {
if let tool = lookupExecutablePath(filename: "clang", searchPaths: [toolsDir]) {
clangPath = tool
}

// Look for binutils in the toolchain folder.
commandLine.appendFlag("-B")
commandLine.appendPath(toolsDir)
}

guard !parsedOptions.hasArgument(.noStaticStdlib, .noStaticExecutable) else {
Expand Down
20 changes: 20 additions & 0 deletions Tests/SwiftDriverTests/SwiftDriverTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4367,6 +4367,26 @@ final class SwiftDriverTests: XCTestCase {
XCTAssertEqual(frontendJobs.count, 2)
XCTAssertEqual(frontendJobs[1].kind, .link)
XCTAssertEqual(frontendJobs[1].tool.absolutePath!.pathString, ld.pathString)

// WebAssembly toolchain
kateinoigakukun marked this conversation as resolved.
Show resolved Hide resolved
do {
try withTemporaryDirectory { resourceDir in
try localFileSystem.writeFileContents(resourceDir.appending(components: "wasi", "static-executable-args.lnk")) {
$0.send("garbage")
}
var driver = try Driver(args: ["swiftc",
"-target", "wasm32-unknown-wasi",
"-resource-dir", resourceDir.pathString,
"-tools-directory", tmpDir.pathString,
"foo.swift"],
env: env)
let frontendJobs = try driver.planBuild().removingAutolinkExtractJobs()
XCTAssertEqual(frontendJobs.count, 2)
XCTAssertTrue(frontendJobs[1].commandLine.contains(subsequence: [
.flag("-B"), .path(.absolute(tmpDir))
]))
}
}
}
}

Expand Down