cfg(target_arch) in build scripts for FFI still refer to the host rather than the target #1285
-
Running
Will trigger this part of the build script:
Any ideas? I need to set up target specific optimizations or the software can get incredibly slow. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Instead, use the environment variable as noted in the text, ensure that you actually retrieve the env var at runtime using note that this behaviour is not changed by cross, rather it's how cargo/rust works |
Beta Was this translation helpful? Give feedback.
-
Thanks, this is helpful! |
Beta Was this translation helpful? Give feedback.
cfg(target_arch)
will always refer to the target the current crate is built for, and build scripts are always built for the host, not the target.Instead, use the environment variable
CARGO_CFG_TARGET_ARCH
as noted in the text, ensure that you actually retrieve the env var at runtime using
env::var("CARGO_CFG_TARGET_ARCH")
note that this behaviour is not changed by cross, rather it's how cargo/rust works