Skip to content

Commit fc6b2c5

Browse files
committed
Auto merge of #50423 - hberntsen:armv5te_unknown_linux_musl, r=alexcrichton
Add armv5te-unknown-linux-musl target This PR adds the armv5te-unknown-linux-musl target. The following steps should let you produce a fully statically linked binary now: 1. Running `./src/ci/docker/run.sh dist-armv5te-linux-musl` 2. Changing the run.sh script to start bash instead of the build process and running the container 3. ```sh export USER=root export PATH=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin:/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin:$PATH ``` 4. Configuring Cargo ```yaml [target.armv5te-unknown-linux-musl] linker = "arm-linux-gnueabi-gcc" ``` 5. Building a project ```sh cargo new --bin hello cd hello cargo build --target=armv5te-unknown-linux-musl --release ```
2 parents 5d6c757 + 235af75 commit fc6b2c5

File tree

5 files changed

+51
-1
lines changed

5 files changed

+51
-1
lines changed

src/bootstrap/configure.py

+2
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,8 @@ def v(*args):
120120
"arm-unknown-linux-musleabi install directory")
121121
v("musl-root-armhf", "target.arm-unknown-linux-musleabihf.musl-root",
122122
"arm-unknown-linux-musleabihf install directory")
123+
v("musl-root-armv5te", "target.armv5te-unknown-linux-musleabi.musl-root",
124+
"armv5te-unknown-linux-musleabi install directory")
123125
v("musl-root-armv7", "target.armv7-unknown-linux-musleabihf.musl-root",
124126
"armv7-unknown-linux-musleabihf install directory")
125127
v("musl-root-aarch64", "target.aarch64-unknown-linux-musl.musl-root",

src/ci/docker/dist-various-1/Dockerfile

+9-1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ ENV STAGING_DIR=/tmp
4343

4444
COPY scripts/musl.sh /build
4545
RUN env \
46+
CC=arm-linux-gnueabi-gcc CFLAGS="-march=armv5te -marm -mfloat-abi=soft" \
47+
CXX=arm-linux-gnueabi-g++ CXXFLAGS="-march=armv5te -marm -mfloat-abi=soft" \
48+
bash musl.sh armv5te && \
49+
env \
4650
CC=arm-linux-gnueabi-gcc CFLAGS="-march=armv6 -marm" \
4751
CXX=arm-linux-gnueabi-g++ CXXFLAGS="-march=armv6 -marm" \
4852
bash musl.sh arm && \
@@ -84,6 +88,7 @@ ENV TARGETS=$TARGETS,mipsel-unknown-linux-musl
8488
ENV TARGETS=$TARGETS,arm-unknown-linux-musleabi
8589
ENV TARGETS=$TARGETS,arm-unknown-linux-musleabihf
8690
ENV TARGETS=$TARGETS,armv5te-unknown-linux-gnueabi
91+
ENV TARGETS=$TARGETS,armv5te-unknown-linux-musleabi
8792
ENV TARGETS=$TARGETS,armv7-unknown-linux-musleabihf
8893
ENV TARGETS=$TARGETS,aarch64-unknown-linux-musl
8994
ENV TARGETS=$TARGETS,sparc64-unknown-linux-gnu
@@ -100,9 +105,12 @@ ENV CC_mipsel_unknown_linux_musl=mipsel-openwrt-linux-gcc \
100105
CC_sparc64_unknown_linux_gnu=sparc64-linux-gnu-gcc \
101106
CC_x86_64_unknown_redox=x86_64-unknown-redox-gcc \
102107
CC_armv5te_unknown_linux_gnueabi=arm-linux-gnueabi-gcc \
103-
CFLAGS_armv5te_unknown_linux_gnueabi="-march=armv5te -marm -mfloat-abi=soft"
108+
CFLAGS_armv5te_unknown_linux_gnueabi="-march=armv5te -marm -mfloat-abi=soft" \
109+
CC_armv5te_unknown_linux_musleabi=arm-linux-gnueabi-gcc \
110+
CFLAGS_armv5te_unknown_linux_musleabi="-march=armv5te -marm -mfloat-abi=soft"
104111

105112
ENV RUST_CONFIGURE_ARGS \
113+
--musl-root-armv5te=/musl-armv5te \
106114
--musl-root-arm=/musl-arm \
107115
--musl-root-armhf=/musl-armhf \
108116
--musl-root-armv7=/musl-armv7 \
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
use spec::{LinkerFlavor, Target, TargetOptions, TargetResult};
12+
13+
pub fn target() -> TargetResult {
14+
let base = super::linux_musl_base::opts();
15+
Ok(Target {
16+
// It's important we use "gnueabihf" and not "musleabihf" here. LLVM
17+
// uses it to determine the calling convention and float ABI, and LLVM
18+
// doesn't support the "musleabihf" value.
19+
llvm_target: "armv5te-unknown-linux-gnueabi".to_string(),
20+
target_endian: "little".to_string(),
21+
target_pointer_width: "32".to_string(),
22+
target_c_int_width: "32".to_string(),
23+
data_layout: "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64".to_string(),
24+
arch: "arm".to_string(),
25+
target_os: "linux".to_string(),
26+
target_env: "musl".to_string(),
27+
target_vendor: "unknown".to_string(),
28+
linker_flavor: LinkerFlavor::Gcc,
29+
30+
options: TargetOptions {
31+
features: "+soft-float,+strict-align".to_string(),
32+
// Atomic operations provided by compiler-builtins
33+
max_atomic_width: Some(32),
34+
abi_blacklist: super::arm_base::abi_blacklist(),
35+
.. base
36+
}
37+
})
38+
}

src/librustc_target/spec/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,7 @@ supported_targets! {
283283
("arm-unknown-linux-musleabihf", arm_unknown_linux_musleabihf),
284284
("armv4t-unknown-linux-gnueabi", armv4t_unknown_linux_gnueabi),
285285
("armv5te-unknown-linux-gnueabi", armv5te_unknown_linux_gnueabi),
286+
("armv5te-unknown-linux-musleabi", armv5te_unknown_linux_musleabi),
286287
("armv7-unknown-linux-gnueabihf", armv7_unknown_linux_gnueabihf),
287288
("armv7-unknown-linux-musleabihf", armv7_unknown_linux_musleabihf),
288289
("aarch64-unknown-linux-gnu", aarch64_unknown_linux_gnu),

src/tools/build-manifest/src/main.rs

+1
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ static TARGETS: &'static [&'static str] = &[
5757
"arm-unknown-linux-musleabi",
5858
"arm-unknown-linux-musleabihf",
5959
"armv5te-unknown-linux-gnueabi",
60+
"armv5te-unknown-linux-musleabi",
6061
"armv7-apple-ios",
6162
"armv7-linux-androideabi",
6263
"armv7-unknown-cloudabi-eabihf",

0 commit comments

Comments
 (0)