Skip to content

Commit 088ac1d

Browse files
finagolfinartemcm
authored andcommitted
Android: add the right suffix for the compiler-rt profiler library
1 parent 9c61dd1 commit 088ac1d

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

Sources/SwiftDriver/Jobs/GenericUnixToolchain+LinkerSupport.swift

+2-1
Original file line numberDiff line numberDiff line change
@@ -285,9 +285,10 @@ extension GenericUnixToolchain {
285285
}
286286

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

293294
// HACK: Hard-coded from llvm::getInstrProfRuntimeHookVarName()

Tests/SwiftDriverTests/SwiftDriverTests.swift

+7-3
Original file line numberDiff line numberDiff line change
@@ -4416,15 +4416,19 @@ final class SwiftDriverTests: XCTestCase {
44164416
// FIXME: This will fail when run on macOS, because
44174417
// swift-autolink-extract is not present
44184418
#if os(Linux) || os(Android) || os(Windows)
4419-
do {
4420-
var driver = try Driver(args: ["swiftc", "-profile-generate", "-target", "x86_64-unknown-linux-gnu", "test.swift"])
4419+
for triple in ["aarch64-unknown-linux-android", "x86_64-unknown-linux-gnu"] {
4420+
var driver = try Driver(args: ["swiftc", "-profile-generate", "-target", triple, "test.swift"])
44214421
let plannedJobs = try driver.planBuild().removingAutolinkExtractJobs()
44224422

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

44264426
XCTAssertEqual(plannedJobs[1].kind, .link)
4427-
XCTAssert(plannedJobs[1].commandLine.containsPathWithBasename("libclang_rt.profile-x86_64.a"))
4427+
if triple == "aarch64-unknown-linux-android" {
4428+
XCTAssert(plannedJobs[1].commandLine.containsPathWithBasename("libclang_rt.profile-aarch64-android.a"))
4429+
} else {
4430+
XCTAssert(plannedJobs[1].commandLine.containsPathWithBasename("libclang_rt.profile-x86_64.a"))
4431+
}
44284432
XCTAssert(plannedJobs[1].commandLine.contains { $0 == .flag("-u__llvm_profile_runtime") })
44294433
}
44304434
#endif

0 commit comments

Comments
 (0)