Skip to content

Commit

Permalink
Set --host when configuring elfutils to enable cross-compilation
Browse files Browse the repository at this point in the history
  • Loading branch information
kxxt authored and danielocfb committed Aug 19, 2024
1 parent b7ff6c6 commit 47546ba
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,19 @@ fn make_elfutils(compiler: &cc::Tool, src_dir: &path::Path, out_dir: &path::Path
.arg("--without-zstd")
.arg("--prefix")
.arg(&src_dir.join("elfutils/prefix_dir"))
.arg("--host")
.arg({
let arch = env::var("CARGO_CFG_TARGET_ARCH").unwrap();
let arch = match arch.as_str() {
"riscv64gc" => "riscv64",
"riscv32gc" => "riscv32",
other => other,
};
let vendor = env::var("CARGO_CFG_TARGET_VENDOR").unwrap();
let env = env::var("CARGO_CFG_TARGET_ENV").unwrap();
let os = env::var("CARGO_CFG_TARGET_OS").unwrap();
format!("{arch}-{vendor}-{os}-{env}")
})
.arg("--libdir")
.arg(out_dir)
.env("CC", compiler.path())
Expand Down

0 comments on commit 47546ba

Please sign in to comment.