Skip to content

Android: add the right suffix for the compiler-rt profiler library #1685

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 1 commit into from
Aug 28, 2024
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