The CARGO_CFG_TARGET_OS environment variable should be used for this, as cfg!() represents the target the build.rs script was compiled for and will contain the wrong value when cross-compiling for a different target.
Empirical evidence suggests that it's not necessary to explicitly set target_os anyway since it is already conveyed in the TARGET triple environment variable. It's not passed directly to ispc but at least ispc-rs uses it to identify the architecture, and it should should be irrelevant when not linking against external libraries.
The
CARGO_CFG_TARGET_OS
environment variable should be used for this, ascfg!()
represents the target thebuild.rs
script was compiled for and will contain the wrong value when cross-compiling for a different target.Empirical evidence suggests that it's not necessary to explicitly set
target_os
anyway since it is already conveyed in theTARGET
triple environment variable. It's not passed directly to ispc but at leastispc-rs
uses it to identify the architecture, and it should should be irrelevant when not linking against external libraries.