winresource icon indicating copy to clipboard operation
winresource copied to clipboard

Review all `cfg` usages for cross-compilation use-cases

Open BenjaminRi opened this issue 2 years ago • 0 comments

Using #[cfg(target_os = "windows")] in build.rs (and its dependencies like lib.rs of this crate) may not work as expected because build.rs is executed on the host. This means that target_os is always equal to host_os when compiling build.rs. E.g. if we use rustc on Linux and want to cross-compile binaries that run on Windows, target_os in build.rs is "linux".

Instead, we have to use environment variables like CARGO_CFG_TARGET_OS which are set to the actual build target properties.

This may also apply to other definitions like cfg!(target_arch = "x86_64"), etc.

BenjaminRi avatar Nov 20 '22 19:11 BenjaminRi