Skip to content

Commit

Permalink
Merge pull request #159 from mozilla/build-id-linker-flag
Browse files Browse the repository at this point in the history
Add --build-id to the linker flags
  • Loading branch information
bendk authored Jan 7, 2025
2 parents c24dfbd + e0a4141 commit 9934bdf
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
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.

### 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

0 comments on commit 9934bdf

Please sign in to comment.