Skip to content

Commit

Permalink
build: fix missing libatomic on armv7 Linux
Browse files Browse the repository at this point in the history
  • Loading branch information
Brooooooklyn committed Sep 16, 2023
1 parent 0d21391 commit 3f38ca5
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ jobs:
target: armv7-unknown-linux-gnueabihf
setup: |
sudo apt-get update
sudo apt-get install gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf -y
sudo apt-get install gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf libatomic1-armhf-cross -y
build: |
yarn build --target armv7-unknown-linux-gnueabihf --zig --zig-link-only
arm-linux-gnueabihf-strip *.node
Expand Down
17 changes: 15 additions & 2 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,20 @@ extern crate napi_build;
fn main() {
napi_build::setup();
let compile_target = std::env::var("TARGET").unwrap();
if compile_target == "x86_64-unknown-linux-gnu" {
println!("cargo:rustc-link-search=/usr/x86_64-unknown-linux-gnu/lib");
match compile_target.as_str() {
"x86_64-unknown-linux-gnu" => {
println!("cargo:rustc-link-search=/usr/x86_64-unknown-linux-gnu/lib");
}
"armv7-unknown-linux-gnueabihf" => {
const CROSS_LIB_PATH: &str = "/usr/lib/gcc-cross/arm-linux-gnueabihf";
if let Ok(version) = std::process::Command::new("ls")
.arg(CROSS_LIB_PATH)
.output()
.map(|o| String::from_utf8(o.stdout).unwrap().trim().to_string())
{
println!("cargo:rustc-link-search={CROSS_LIB_PATH}/{version}");
};
}
_ => {}
}
}

0 comments on commit 3f38ca5

Please sign in to comment.