-
Notifications
You must be signed in to change notification settings - Fork 12
Description
Build scripts, such as your build.rs
, since they are built for execution on the compiling machine, don't receive the --target i686-β¦
memo. As a result, their cfg!(target_arch)
always matches the architecture of the rustc
which compiles them - usually x86_64
.
Because build.rs
always sees x86_64
, cross-compilation of your library from x86_64 hosts always fails, except for the scenario where a Windows user installs the whole 32-bit Rust toolchain (which 64-bit Windows happens to be able to execute thanks to WOW64) and uses it to compile the 32-bit plugin - I believe this is what you did.
When I removed build.rs in my fork, cross-compilation from x86_64 Windows (using the default stable-x86_64-pc-windows-msvc
toolchain) to the i686-unknown-linux-gnu
target worked perfectly! π There is no need to install a linux toolchain (which wouldn't even execute on Windows if you tried) nor the 32-bit windows toolchain. All that's needed to compile for Linux is:
rustup target add i686-unknown-linux-gnu
cargo build --target=i686-unknown-linux-gnu
And likewise, for 32-bit Windows:
rustup target add i686-pc-windows-msvc
cargo build --target=i686-pc-windows-msvc
You don't have to run the 32-bit version of rustc
to compile for 32-bit targets. You're only supposed to change the target. The library, because of the build.rs
quirk, needlessly restricts cross-compilation. π