Skip to content

Commit

Permalink
Compiling wireguard-go-rs to unsupported target arch is a hard error
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkusPettersson98 committed Jan 15, 2025
1 parent 91b7359 commit fce1457
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions wireguard-go-rs/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,15 @@ const fn host_os() -> Os {
HOST
}

fn host_arch() -> anyhow::Result<Arch> {
if cfg!(target_arch = "x86_64") {
Ok(Arch::Amd64)
const fn host_arch() -> Arch {
const ARCH: Arch = if cfg!(target_arch = "x86_64") {
Arch::Amd64
} else if cfg!(target_arch = "aarch64") {
Ok(Arch::Arm64)
Arch::Arm64
} else {
bail!("Unsupported host architecture")
}
panic!("Unsupported host architecture")
};
ARCH
}

/// Compile libwg as a library and place it in `OUT_DIR`.
Expand All @@ -105,7 +106,7 @@ fn build_desktop_lib(target_os: Os) -> anyhow::Result<()> {
go_build.env("CGO_ENABLED", "1").current_dir("./libwg");

// are we cross compiling?
let cross_compiling = host_os() != target_os || host_arch()? != target_arch;
let cross_compiling = host_os() != target_os || host_arch() != target_arch;

match target_arch {
Arch::Amd64 => go_build.env("GOARCH", "amd64"),
Expand Down

0 comments on commit fce1457

Please sign in to comment.