Skip to content
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 @@ -285,9 +285,10 @@ extension GenericUnixToolchain {
}

if parsedOptions.hasArgument(.profileGenerate) {
let environment = (targetTriple.environment == .android) ? "-android" : ""
let libProfile = VirtualPath.lookup(targetInfo.runtimeResourcePath.path)
.appending(components: "clang", "lib", targetTriple.osName,
"libclang_rt.profile-\(targetTriple.archName).a")
"libclang_rt.profile-\(targetTriple.archName)\(environment).a")
commandLine.appendPath(libProfile)

// HACK: Hard-coded from llvm::getInstrProfRuntimeHookVarName()
Expand Down
10 changes: 7 additions & 3 deletions Tests/SwiftDriverTests/SwiftDriverTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4416,15 +4416,19 @@ final class SwiftDriverTests: XCTestCase {
// FIXME: This will fail when run on macOS, because
// swift-autolink-extract is not present
#if os(Linux) || os(Android) || os(Windows)
do {
var driver = try Driver(args: ["swiftc", "-profile-generate", "-target", "x86_64-unknown-linux-gnu", "test.swift"])
for triple in ["aarch64-unknown-linux-android", "x86_64-unknown-linux-gnu"] {
var driver = try Driver(args: ["swiftc", "-profile-generate", "-target", triple, "test.swift"])
let plannedJobs = try driver.planBuild().removingAutolinkExtractJobs()

XCTAssertEqual(plannedJobs.count, 2)
XCTAssertEqual(plannedJobs[0].kind, .compile)

XCTAssertEqual(plannedJobs[1].kind, .link)
XCTAssert(plannedJobs[1].commandLine.containsPathWithBasename("libclang_rt.profile-x86_64.a"))
if triple == "aarch64-unknown-linux-android" {
XCTAssert(plannedJobs[1].commandLine.containsPathWithBasename("libclang_rt.profile-aarch64-android.a"))
} else {
XCTAssert(plannedJobs[1].commandLine.containsPathWithBasename("libclang_rt.profile-x86_64.a"))
}
XCTAssert(plannedJobs[1].commandLine.contains { $0 == .flag("-u__llvm_profile_runtime") })
}
#endif
Expand Down