Skip to content

Commit

Permalink
fix cross-compiling static loader
Browse files Browse the repository at this point in the history
The build script used the `cfg!` macro to check the target os, but the "target" in a build script is actually the host.
Use the `CARGO_CFG_TARGET_OS` environment variable instead.

Issue #42 [has been worked around](KhronosGroup/OpenXR-SDK-Source#198),
and then [fixed upstream](KhronosGroup/OpenXR-SDK-Source#239),
so the additional flag on windows is no longer necessary.

Linking the filesystem library is also done correctly upstream now:
https://github.com/KhronosGroup/OpenXR-SDK-Source/blob/main/src/cmake/StdFilesystemFlags.cmake
  • Loading branch information
Timbals authored and Ralith committed Jul 18, 2024
1 parent 155efe0 commit 48fa26e
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ fn main() {
);
println!("cargo:rustc-link-lib=static=openxr_loader");

if cfg!(any(target_os = "macos", target_os = "freebsd")) {
let target_os = std::env::var_os("CARGO_CFG_TARGET_OS")
.expect("missing CARGO_CFG_TARGET_OS environment variable");

if target_os == "macos" || target_os == "freebsd" {
println!("cargo:rustc-link-lib=c++");
} else if cfg!(target_os = "windows") {
println!("cargo:rustc-link-lib=pathcch");
} else {
} else if target_os != "windows" {
println!("cargo:rustc-link-lib=stdc++");
println!("cargo:rustc-link-lib=stdc++fs");
}
}
#[cfg(all(not(feature = "static"), feature = "linked"))]
Expand Down

0 comments on commit 48fa26e

Please sign in to comment.