Skip to content

Commit 8af0dba

Browse files
committed
backtrace-sys: Use target_pointer_width for BACKTRACE_ELF_SIZE
The former code used `target.contains("64")` to detect Elf64 targets, but this is inaccurate in a few cases: - `s390x-unknown-linux-gnu` is 64-bit - `sparcv9-sun-solaris` is 64-bit - `x86_64-unknown-linux-gnux32` is 32-bit Instead the build script can use `CARGO_CFG_TARGET_POINTER_WIDTH` to reliably detect 64-bit targets.
1 parent 5efeedf commit 8af0dba

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

backtrace-sys/build.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ fn main() {
4040
build.flag("-fvisibility=hidden");
4141
build.file("src/libbacktrace/elf.c");
4242

43-
if target.contains("64") {
43+
let pointer_width = env::var("CARGO_CFG_TARGET_POINTER_WIDTH").unwrap();
44+
if pointer_width == "64" {
4445
build.define("BACKTRACE_ELF_SIZE", "64");
4546
} else {
4647
build.define("BACKTRACE_ELF_SIZE", "32");

0 commit comments

Comments
 (0)