Do not assume dynamic linking for musl/mips[el] targets
All musl targets except mips[el] assume static linking by default. This can be confusing https://users.rust-lang.org/t/static-cross-compiled-binaries-arent-really-static/6084 When the musl/mips[el] targets was [added](https://github.com/rust-lang/rust/pull/31298), dynamic linking was chosen because of binary size concerns, and probably also because libunwind [didn't](https://users.rust-lang.org/t/static-cross-compiled-binaries-arent-really-static/6084/8) supported mips. Now that we have `crt-static` target-feature (the user can choose dynamic link for musl targets), and libunwind [6.0](https://github.com/llvm-mirror/libunwind/commits/release_60) add support to mips, we do not need to assume dynamic linking.
This commit is contained in:
parent
fdc18b3067
commit
68db72d8cd
9 changed files with 56 additions and 38 deletions
|
@ -80,7 +80,7 @@ impl Step for Std {
|
||||||
|
|
||||||
// Even if we're not building std this stage, the new sysroot must
|
// Even if we're not building std this stage, the new sysroot must
|
||||||
// still contain the musl startup objects.
|
// still contain the musl startup objects.
|
||||||
if target.contains("musl") && !target.contains("mips") {
|
if target.contains("musl") {
|
||||||
let libdir = builder.sysroot_libdir(compiler, target);
|
let libdir = builder.sysroot_libdir(compiler, target);
|
||||||
copy_musl_third_party_objects(build, target, &libdir);
|
copy_musl_third_party_objects(build, target, &libdir);
|
||||||
}
|
}
|
||||||
|
@ -97,7 +97,7 @@ impl Step for Std {
|
||||||
println!("Building stage{} std artifacts ({} -> {})", compiler.stage,
|
println!("Building stage{} std artifacts ({} -> {})", compiler.stage,
|
||||||
&compiler.host, target);
|
&compiler.host, target);
|
||||||
|
|
||||||
if target.contains("musl") && !target.contains("mips") {
|
if target.contains("musl") {
|
||||||
let libdir = builder.sysroot_libdir(compiler, target);
|
let libdir = builder.sysroot_libdir(compiler, target);
|
||||||
copy_musl_third_party_objects(build, target, &libdir);
|
copy_musl_third_party_objects(build, target, &libdir);
|
||||||
}
|
}
|
||||||
|
|
|
@ -120,6 +120,10 @@ v("musl-root-armv7", "target.armv7-unknown-linux-musleabihf.musl-root",
|
||||||
"armv7-unknown-linux-musleabihf install directory")
|
"armv7-unknown-linux-musleabihf install directory")
|
||||||
v("musl-root-aarch64", "target.aarch64-unknown-linux-musl.musl-root",
|
v("musl-root-aarch64", "target.aarch64-unknown-linux-musl.musl-root",
|
||||||
"aarch64-unknown-linux-musl install directory")
|
"aarch64-unknown-linux-musl install directory")
|
||||||
|
v("musl-root-mips", "target.mips-unknown-linux-musl.musl-root",
|
||||||
|
"mips-unknown-linux-musl install directory")
|
||||||
|
v("musl-root-mipsel", "target.mipsel-unknown-linux-musl.musl-root",
|
||||||
|
"mipsel-unknown-linux-musl install directory")
|
||||||
v("qemu-armhf-rootfs", "target.arm-unknown-linux-gnueabihf.qemu-rootfs",
|
v("qemu-armhf-rootfs", "target.arm-unknown-linux-gnueabihf.qemu-rootfs",
|
||||||
"rootfs in qemu testing, you probably don't want to use this")
|
"rootfs in qemu testing, you probably don't want to use this")
|
||||||
v("qemu-aarch64-rootfs", "target.aarch64-unknown-linux-gnu.qemu-rootfs",
|
v("qemu-aarch64-rootfs", "target.aarch64-unknown-linux-gnu.qemu-rootfs",
|
||||||
|
|
|
@ -170,7 +170,7 @@ pub fn check(build: &mut Build) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure musl-root is valid
|
// Make sure musl-root is valid
|
||||||
if target.contains("musl") && !target.contains("mips") {
|
if target.contains("musl") {
|
||||||
// If this is a native target (host is also musl) and no musl-root is given,
|
// If this is a native target (host is also musl) and no musl-root is given,
|
||||||
// fall back to the system toolchain in /usr before giving up
|
// fall back to the system toolchain in /usr before giving up
|
||||||
if build.musl_root(*target).is_none() && build.config.build == *target {
|
if build.musl_root(*target).is_none() && build.config.build == *target {
|
||||||
|
|
|
@ -30,6 +30,15 @@ RUN ./build-rumprun.sh
|
||||||
COPY dist-various-1/install-x86_64-redox.sh /build
|
COPY dist-various-1/install-x86_64-redox.sh /build
|
||||||
RUN ./install-x86_64-redox.sh
|
RUN ./install-x86_64-redox.sh
|
||||||
|
|
||||||
|
COPY dist-various-1/install-mips-musl.sh /build
|
||||||
|
RUN ./install-mips-musl.sh
|
||||||
|
|
||||||
|
COPY dist-various-1/install-mipsel-musl.sh /build
|
||||||
|
RUN ./install-mipsel-musl.sh
|
||||||
|
|
||||||
|
# Suppress some warnings in the openwrt toolchains we downloaded
|
||||||
|
ENV STAGING_DIR=/tmp
|
||||||
|
|
||||||
COPY scripts/musl.sh /build
|
COPY scripts/musl.sh /build
|
||||||
RUN env \
|
RUN env \
|
||||||
CC=arm-linux-gnueabi-gcc CFLAGS="-march=armv6 -marm" \
|
CC=arm-linux-gnueabi-gcc CFLAGS="-march=armv6 -marm" \
|
||||||
|
@ -47,14 +56,16 @@ RUN env \
|
||||||
CC=aarch64-linux-gnu-gcc \
|
CC=aarch64-linux-gnu-gcc \
|
||||||
CXX=aarch64-linux-gnu-g++ \
|
CXX=aarch64-linux-gnu-g++ \
|
||||||
bash musl.sh aarch64 && \
|
bash musl.sh aarch64 && \
|
||||||
|
env \
|
||||||
|
CC=mips-openwrt-linux-gcc \
|
||||||
|
CXX=mips-openwrt-linux-g++ \
|
||||||
|
bash musl.sh mips && \
|
||||||
|
env \
|
||||||
|
CC=mipsel-openwrt-linux-gcc \
|
||||||
|
CXX=mipsel-openwrt-linux-g++ \
|
||||||
|
bash musl.sh mipsel && \
|
||||||
rm -rf /build/*
|
rm -rf /build/*
|
||||||
|
|
||||||
COPY dist-various-1/install-mips-musl.sh /build
|
|
||||||
RUN ./install-mips-musl.sh
|
|
||||||
|
|
||||||
COPY dist-various-1/install-mipsel-musl.sh /build
|
|
||||||
RUN ./install-mipsel-musl.sh
|
|
||||||
|
|
||||||
ENV TARGETS=asmjs-unknown-emscripten
|
ENV TARGETS=asmjs-unknown-emscripten
|
||||||
ENV TARGETS=$TARGETS,wasm32-unknown-emscripten
|
ENV TARGETS=$TARGETS,wasm32-unknown-emscripten
|
||||||
ENV TARGETS=$TARGETS,x86_64-rumprun-netbsd
|
ENV TARGETS=$TARGETS,x86_64-rumprun-netbsd
|
||||||
|
@ -77,16 +88,16 @@ ENV CC_mipsel_unknown_linux_musl=mipsel-openwrt-linux-gcc \
|
||||||
CC_armv5te_unknown_linux_gnueabi=arm-linux-gnueabi-gcc \
|
CC_armv5te_unknown_linux_gnueabi=arm-linux-gnueabi-gcc \
|
||||||
CFLAGS_armv5te_unknown_linux_gnueabi="-march=armv5te -marm -mfloat-abi=soft"
|
CFLAGS_armv5te_unknown_linux_gnueabi="-march=armv5te -marm -mfloat-abi=soft"
|
||||||
|
|
||||||
# Suppress some warnings in the openwrt toolchains we downloaded
|
|
||||||
ENV STAGING_DIR=/tmp
|
|
||||||
|
|
||||||
ENV RUST_CONFIGURE_ARGS \
|
ENV RUST_CONFIGURE_ARGS \
|
||||||
--enable-extended \
|
--enable-extended \
|
||||||
--target=$TARGETS \
|
--target=$TARGETS \
|
||||||
--musl-root-arm=/musl-arm \
|
--musl-root-arm=/musl-arm \
|
||||||
--musl-root-armhf=/musl-armhf \
|
--musl-root-armhf=/musl-armhf \
|
||||||
--musl-root-armv7=/musl-armv7 \
|
--musl-root-armv7=/musl-armv7 \
|
||||||
--musl-root-aarch64=/musl-aarch64
|
--musl-root-aarch64=/musl-aarch64 \
|
||||||
|
--musl-root-mips=/musl-mips \
|
||||||
|
--musl-root-mipsel=/musl-mipsel
|
||||||
|
|
||||||
ENV SCRIPT python2.7 ../x.py dist --target $TARGETS
|
ENV SCRIPT python2.7 ../x.py dist --target $TARGETS
|
||||||
|
|
||||||
# sccache
|
# sccache
|
||||||
|
|
|
@ -49,7 +49,16 @@ hide_output make clean
|
||||||
|
|
||||||
cd ..
|
cd ..
|
||||||
|
|
||||||
|
# use version 60 for all targets after llvm 6.0 release
|
||||||
|
case $TAG in
|
||||||
|
mips|mipsel)
|
||||||
|
LLVM=60
|
||||||
|
;;
|
||||||
|
*)
|
||||||
LLVM=39
|
LLVM=39
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
# may have been downloaded in a previous run
|
# may have been downloaded in a previous run
|
||||||
if [ ! -d libunwind-release_$LLVM ]; then
|
if [ ! -d libunwind-release_$LLVM ]; then
|
||||||
curl -L https://github.com/llvm-mirror/llvm/archive/release_$LLVM.tar.gz | tar xzf -
|
curl -L https://github.com/llvm-mirror/llvm/archive/release_$LLVM.tar.gz | tar xzf -
|
||||||
|
|
|
@ -9,9 +9,15 @@
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
use LinkerFlavor;
|
use LinkerFlavor;
|
||||||
use target::{Target, TargetOptions, TargetResult};
|
use target::{Target, TargetResult};
|
||||||
|
|
||||||
pub fn target() -> TargetResult {
|
pub fn target() -> TargetResult {
|
||||||
|
let mut base = super::linux_musl_base::opts();
|
||||||
|
base.cpu = "mips32r2".to_string();
|
||||||
|
base.features = "+mips32r2,+soft-float".to_string();
|
||||||
|
base.max_atomic_width = Some(32);
|
||||||
|
// see #36994
|
||||||
|
base.exe_allocation_crate = None;
|
||||||
Ok(Target {
|
Ok(Target {
|
||||||
llvm_target: "mips-unknown-linux-musl".to_string(),
|
llvm_target: "mips-unknown-linux-musl".to_string(),
|
||||||
target_endian: "big".to_string(),
|
target_endian: "big".to_string(),
|
||||||
|
@ -23,15 +29,6 @@ pub fn target() -> TargetResult {
|
||||||
target_env: "musl".to_string(),
|
target_env: "musl".to_string(),
|
||||||
target_vendor: "unknown".to_string(),
|
target_vendor: "unknown".to_string(),
|
||||||
linker_flavor: LinkerFlavor::Gcc,
|
linker_flavor: LinkerFlavor::Gcc,
|
||||||
options: TargetOptions {
|
options: base,
|
||||||
cpu: "mips32r2".to_string(),
|
|
||||||
features: "+mips32r2,+soft-float".to_string(),
|
|
||||||
max_atomic_width: Some(32),
|
|
||||||
|
|
||||||
// see #36994
|
|
||||||
exe_allocation_crate: None,
|
|
||||||
|
|
||||||
..super::linux_base::opts()
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,9 +9,15 @@
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
use LinkerFlavor;
|
use LinkerFlavor;
|
||||||
use target::{Target, TargetOptions, TargetResult};
|
use target::{Target, TargetResult};
|
||||||
|
|
||||||
pub fn target() -> TargetResult {
|
pub fn target() -> TargetResult {
|
||||||
|
let mut base = super::linux_musl_base::opts();
|
||||||
|
base.cpu = "mips32".to_string();
|
||||||
|
base.features = "+mips32,+soft-float".to_string();
|
||||||
|
base.max_atomic_width = Some(32);
|
||||||
|
// see #36994
|
||||||
|
base.exe_allocation_crate = None;
|
||||||
Ok(Target {
|
Ok(Target {
|
||||||
llvm_target: "mipsel-unknown-linux-musl".to_string(),
|
llvm_target: "mipsel-unknown-linux-musl".to_string(),
|
||||||
target_endian: "little".to_string(),
|
target_endian: "little".to_string(),
|
||||||
|
@ -23,15 +29,6 @@ pub fn target() -> TargetResult {
|
||||||
target_env: "musl".to_string(),
|
target_env: "musl".to_string(),
|
||||||
target_vendor: "unknown".to_string(),
|
target_vendor: "unknown".to_string(),
|
||||||
linker_flavor: LinkerFlavor::Gcc,
|
linker_flavor: LinkerFlavor::Gcc,
|
||||||
options: TargetOptions {
|
options: base,
|
||||||
cpu: "mips32".to_string(),
|
|
||||||
features: "+mips32,+soft-float".to_string(),
|
|
||||||
max_atomic_width: Some(32),
|
|
||||||
|
|
||||||
// see #36994
|
|
||||||
exe_allocation_crate: None,
|
|
||||||
|
|
||||||
..super::linux_base::opts()
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@ fn main() {
|
||||||
let target = env::var("TARGET").expect("TARGET was not set");
|
let target = env::var("TARGET").expect("TARGET was not set");
|
||||||
|
|
||||||
if target.contains("linux") {
|
if target.contains("linux") {
|
||||||
if target.contains("musl") && !target.contains("mips") {
|
if target.contains("musl") {
|
||||||
// musl is handled in lib.rs
|
// musl is handled in lib.rs
|
||||||
} else if !target.contains("android") {
|
} else if !target.contains("android") {
|
||||||
println!("cargo:rustc-link-lib=gcc_s");
|
println!("cargo:rustc-link-lib=gcc_s");
|
||||||
|
|
|
@ -35,7 +35,7 @@ cfg_if! {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(all(target_env = "musl", not(target_arch = "mips")))]
|
#[cfg(target_env = "musl")]
|
||||||
#[link(name = "unwind", kind = "static", cfg(target_feature = "crt-static"))]
|
#[link(name = "unwind", kind = "static", cfg(target_feature = "crt-static"))]
|
||||||
#[link(name = "gcc_s", cfg(not(target_feature = "crt-static")))]
|
#[link(name = "gcc_s", cfg(not(target_feature = "crt-static")))]
|
||||||
extern {}
|
extern {}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue