With this change, it's possible to build on a linux-gnu target and pass RUSTFLAGS='-C target-feature=+crt-static' or the equivalent via a `.cargo/config.toml` file, and get a statically linked executable. This requires libc 0.2.79, which adds support for static linking with glibc. Add `crt_static_respected` to the `linux_base` target spec. Update `android_base` and `linux_musl_base` accordingly. Avoid enabling crt_static_respected on Android platforms, since that hasn't been tested.
16 lines
481 B
Rust
16 lines
481 B
Rust
use crate::spec::crt_objects::{self, CrtObjectsFallback};
|
|
use crate::spec::TargetOptions;
|
|
|
|
pub fn opts() -> TargetOptions {
|
|
let mut base = super::linux_base::opts();
|
|
|
|
base.pre_link_objects_fallback = crt_objects::pre_musl_fallback();
|
|
base.post_link_objects_fallback = crt_objects::post_musl_fallback();
|
|
base.crt_objects_fallback = Some(CrtObjectsFallback::Musl);
|
|
|
|
// These targets statically link libc by default
|
|
base.crt_static_default = true;
|
|
|
|
base
|
|
}
|