Frequently Asked Questions
Build for Linux alpine
https://github.com/rust-lang/rust/pull/40113#issuecomment-323193341 (opens in a new tab)
You cannot set compile crate-type to cdylib when the compile target is *-unknown-linux-musl by default.
If you want to do so, you need to pass -C target-feature=-crt-static to rustc.
There are two ways to pass this argument:
-
Set
RUSTFLAGSenv,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
ltoto false. If you haven't set lto in yourCargo.toml, the value is false by default, so you can ignore this step. - Set
codegen-unitsto32(or higher). The default value ofcodegen-unitsis16when the compile target is release. You can setCARGO_PROFILE_RELEASE_CODEGEN_UNITS=32andCARGO_PROFILE_RELEASE_LTO='false'to make the compiler happy when targetingi686-windows-*. Here is an example (opens in a new tab).