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

Add --build-id to the linker flags #159

Merged
merged 1 commit into from
Jan 7, 2025
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
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,10 @@ cargo {
}
```

### generateBuildId

Generate a build-id for the shared library during the link phase.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Any suggestions on how to better describe this? I think a link would be great, but when I did a quick search I didn't find a good page to send people to.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm also open to changing the config name.

Copy link
Member

Choose a reason for hiding this comment

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

I don't see a better link either; maybe https://linux.die.net/man/1/ld? I see some options, but that can be for the next person to monkey with.

### exec

This is a callback taking the `ExecSpec` we're going to use to invoke `cargo build`, and
Expand Down
6 changes: 5 additions & 1 deletion plugin/src/main/kotlin/com/nishtahir/CargoBuildTask.kt
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,11 @@ open class CargoBuildTask : DefaultTask() {
environment("RUST_ANDROID_GRADLE_LINKER_WRAPPER_PY",
File(project.rootProject.buildDir, "linker-wrapper/linker-wrapper.py").path)
environment("RUST_ANDROID_GRADLE_CC", cc)
environment("RUST_ANDROID_GRADLE_CC_LINK_ARG", "-Wl,-soname,lib${cargoExtension.libname!!}.so")
if (cargoExtension.generateBuildId) {
environment("RUST_ANDROID_GRADLE_CC_LINK_ARG", "-Wl,--build-id,-soname,lib${cargoExtension.libname!!}.so")
} else {
environment("RUST_ANDROID_GRADLE_CC_LINK_ARG", "-Wl,-soname,lib${cargoExtension.libname!!}.so")
}
}

cargoExtension.extraCargoBuildArguments?.let {
Expand Down
1 change: 1 addition & 0 deletions plugin/src/main/kotlin/com/nishtahir/CargoExtension.kt
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ open class CargoExtension {
var apiLevel: Int? = null
var apiLevels: Map<String, Int> = mapOf()
var extraCargoBuildArguments: List<String>? = null
var generateBuildId: Boolean = false

// It would be nice to use a receiver here, but there are problems interoperating with Groovy
// and Kotlin that are just not worth working out. Another JVM language, yet another dynamic
Expand Down
Loading