1
Fork 0

Auto merge of #77386 - joshtriplett:static-glibc, r=petrochenkov

Support static linking with glibc and target-feature=+crt-static

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.

Update to libc 0.2.78, 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.

Closes https://github.com/rust-lang/rust/issues/65447.
This commit is contained in:
bors 2020-10-06 21:11:04 +00:00
commit 98edd1fbf8
9 changed files with 17 additions and 32 deletions

View file

@ -461,15 +461,7 @@ impl ExitStatus {
}
fn exited(&self) -> bool {
// On Linux-like OSes this function is safe, on others it is not. See
// libc issue: https://github.com/rust-lang/libc/issues/1888.
#[cfg_attr(
any(target_os = "linux", target_os = "android", target_os = "emscripten"),
allow(unused_unsafe)
)]
unsafe {
libc::WIFEXITED(self.0)
}
libc::WIFEXITED(self.0)
}
pub fn success(&self) -> bool {
@ -477,23 +469,11 @@ impl ExitStatus {
}
pub fn code(&self) -> Option<i32> {
// On Linux-like OSes this function is safe, on others it is not. See
// libc issue: https://github.com/rust-lang/libc/issues/1888.
#[cfg_attr(
any(target_os = "linux", target_os = "android", target_os = "emscripten"),
allow(unused_unsafe)
)]
if self.exited() { Some(unsafe { libc::WEXITSTATUS(self.0) }) } else { None }
if self.exited() { Some(libc::WEXITSTATUS(self.0)) } else { None }
}
pub fn signal(&self) -> Option<i32> {
// On Linux-like OSes this function is safe, on others it is not. See
// libc issue: https://github.com/rust-lang/libc/issues/1888.
#[cfg_attr(
any(target_os = "linux", target_os = "android", target_os = "emscripten"),
allow(unused_unsafe)
)]
if !self.exited() { Some(unsafe { libc::WTERMSIG(self.0) }) } else { None }
if !self.exited() { Some(libc::WTERMSIG(self.0)) } else { None }
}
}