Skip to content

Driver: do not create a dSYM bundle for static archives #669

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 2 commits into from
May 20, 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
14 changes: 12 additions & 2 deletions Sources/SwiftDriver/Jobs/Planning.swift
Original file line number Diff line number Diff line change
Expand Up @@ -472,8 +472,18 @@ extension Driver {

let linkJ = try linkJob(inputs: linkerInputs)
addJob(linkJ)
guard targetTriple.isDarwin, debugInfo.level != nil
else {return }
guard targetTriple.isDarwin
else { return }

switch linkerOutputType {
case .none, .some(.staticLibrary):
// Cannot generate a dSYM bundle for a non-image target.
return

case .some(.dynamicLibrary), .some(.executable):
guard debugInfo.level != nil
else { return }
}

let dsymJob = try generateDSYMJob(inputs: linkJ.outputs)
addJob(dsymJob)
Expand Down
18 changes: 18 additions & 0 deletions Tests/SwiftDriverTests/SwiftDriverTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3066,6 +3066,24 @@ final class SwiftDriverTests: XCTestCase {
XCTAssertFalse(plannedJobs.contains { $0.kind == .generateDSYM })
}

do {
var env = ProcessEnv.vars
// As per Unix conventions, /var/empty is expected to exist and be empty.
// This gives us a non-existent path that we can use for libtool which
// allows us to run this this on non-Darwin platforms.
env["SWIFT_DRIVER_LIBTOOL_EXEC"] = "/var/empty/libtool"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, I expected this to work.


// No dSYM generation (-g -emit-library -static)
var driver = try Driver(args: [
"swiftc", "-target", "x86_64-apple-macosx10.15", "-g", "-emit-library",
"-static", "-o", "library.a", "library.swift"
], env: env)
let jobs = try driver.planBuild()

XCTAssertEqual(jobs.count, 3)
XCTAssertFalse(jobs.contains { $0.kind == .generateDSYM })
}

do {
// dSYM generation (-g)
var driver = try Driver(args: commonArgs + ["-g"])
Expand Down