Skip to content

Commit

Permalink
Rollup merge of rust-lang#91381 - Amanieu:android_libdl, r=petrochenkov
Browse files Browse the repository at this point in the history
Android: -ldl must appear after -lgcc when linking

rust-lang#90846 accidentally broke Android builds because it causes the standard library to no longer use `dlsym` on Android. This results in `libdl` being ignored by the linker since no symbols are needed from it. However, we later import `libgcc` for unwinding which *does* depend on `libdl` for `dl_iterate_phdr`. Since linkers don't revisit previous libraries when resolving symbols, this causes a linker error due to an undefined reference to `dl_iterate_phdr`.

This is resolved by adding a second `-ldl` after `-lgcc` in the linker command-line.
  • Loading branch information
matthiaskrgr authored Dec 3, 2021
2 parents 7af2859 + 41e2a53 commit c441004
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions library/unwind/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ fn main() {
} else {
println!("cargo:rustc-link-lib=gcc");
}

// Android's unwinding library depends on dl_iterate_phdr in `libdl`.
println!("cargo:rustc-link-lib=dl");
} else if target.contains("freebsd") {
println!("cargo:rustc-link-lib=gcc_s");
} else if target.contains("netbsd") {
Expand Down

0 comments on commit c441004

Please sign in to comment.