Skip to content

Cross compiling

Stephen M. Coakley edited this page Sep 2, 2021 · 1 revision

Since Isahc doesn't have a pure-Rust dependency tree, cross-compiling it isn't always straightforward. This page contains some tips that may help you when trying to cross-compile to other targets.

musl

musl is an alternative implementation of libc for Linux. You can cross-compile to musl-based targets (targets ending in -unknown-linux-musl) from a glibc-based system (most popular Linux distributions), but there's sometimes some gotchas.

If you have SSL/TLS enabled, then you should almost certainly enable the static-ssl feature. By default Rust statically links everything when compiling to a musl target, though you can disable this behavior by setting RUSTFLAGS=-Ctarget-feature=-crt-static. Static linking is a problem when linking to OpenSSL, which for its own reasons is usually dynamically linked to musl even on a musl system. This can cause weird problems at runtime when a program that is statically linked tries to call into OpenSSL dynamically which is dynamically linked to OpenSSL. The static-ssl feature causes OpenSSL to be statically linked instead, which avoids the problem. See also https://github.com/sfackler/rust-openssl/issues/1462.

Clone this wiki locally