Frequently Asked Questions
Build for Linux alpine
https://github.com/rust-lang/rust/pull/40113#issuecomment-323193341 (opens in a new tab)
You can not set compile crate-type
to cdylib
when compile target is *-unknown-linux-musl
by default.
If you want to do so, you need pass -C target-feature=-crt-static
to rustc
.
There are two ways to pass this argument:
-
Set
RUSTFLAGS
env,RUSTFLAGS="-C target-feature=-crt-static"
-
Set it in
.cargo/config.toml
:[target.x86_64-unknown-linux-musl] rustflags = ["-C", "target-feature=-crt-static"]
Build for Windows i686
There is codegen
error when compile target is i686-windows-*
: Rust issue 67497 (opens in a new tab).
There is a workaround to avoid this issue:
- Set
lto
to false, if you haven't set lto in yourCargo.toml
, the value is false by default, you can ignore this one. - Set
codegen-units
to32
(or bigger). The default value ofcodegen-units
is16
by default when compile target is release, you can setCARGO_PROFILE_RELEASE_CODEGEN_UNITS=32
andCARGO_PROFILE_RELEASE_LTO='false'
to make the compiler happy when targetingi686-windows-*
. Here is an example (opens in a new tab).