Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 9ed8bd5

Browse files
committedAug 5, 2024
Auto merge of rust-lang#122049 - Amanieu:riscv64-musl-tier2, r=Mark-Simulacrum
Promote riscv64gc-unknown-linux-musl to tier 2
2 parents 9179d9b + 9963a6c commit 9ed8bd5

File tree

6 files changed

+63
-3
lines changed

6 files changed

+63
-3
lines changed
 

‎compiler/rustc_target/src/spec/targets/riscv64gc_unknown_linux_musl.rs

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ pub fn target() -> Target {
2121
llvm_abiname: "lp64d".into(),
2222
max_atomic_width: Some(64),
2323
supported_split_debuginfo: Cow::Borrowed(&[SplitDebuginfo::Off]),
24+
crt_static_default: false,
2425
..base::linux_musl::opts()
2526
},
2627
}

‎src/ci/docker/host-x86_64/dist-various-2/Dockerfile

+12-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ RUN apt-get update && apt-get build-dep -y clang llvm && apt-get install -y --no
2424
# Needed for apt-key to work:
2525
dirmngr \
2626
gpg-agent \
27-
g++-9-arm-linux-gnueabi
27+
g++-9-arm-linux-gnueabi \
28+
g++-11-riscv64-linux-gnu
2829

2930
RUN apt-key adv --batch --yes --keyserver keyserver.ubuntu.com --recv-keys 74DA7924C5513486
3031
RUN add-apt-repository -y 'deb https://apt.dilos.org/dilos dilos2 main'
@@ -73,6 +74,10 @@ RUN env \
7374
CC=arm-linux-gnueabi-gcc-9 CFLAGS="-march=armv7-a" \
7475
CXX=arm-linux-gnueabi-g++-9 CXXFLAGS="-march=armv7-a" \
7576
bash musl.sh armv7 && \
77+
env \
78+
CC=riscv64-linux-gnu-gcc-11 \
79+
CXX=riscv64-linux-gnu-g++-11 \
80+
bash musl.sh riscv64gc && \
7681
rm -rf /build/*
7782

7883
WORKDIR /tmp
@@ -125,14 +130,19 @@ ENV TARGETS=$TARGETS,x86_64-unknown-none
125130
ENV TARGETS=$TARGETS,aarch64-unknown-uefi
126131
ENV TARGETS=$TARGETS,i686-unknown-uefi
127132
ENV TARGETS=$TARGETS,x86_64-unknown-uefi
133+
ENV TARGETS=$TARGETS,riscv64gc-unknown-linux-musl
128134

129135
# As per https://bugs.launchpad.net/ubuntu/+source/gcc-defaults/+bug/1300211
130136
# we need asm in the search path for gcc-9 (for gnux32) but not in the search path of the
131137
# cross compilers.
132138
# Luckily one of the folders is /usr/local/include so symlink /usr/include/x86_64-linux-gnu/asm there
133139
RUN ln -s /usr/include/x86_64-linux-gnu/asm /usr/local/include/asm
134140

141+
# musl-gcc can't find libgcc_s.so.1 since it doesn't use the standard search paths.
142+
RUN ln -s /usr/riscv64-linux-gnu/lib/libgcc_s.so.1 /usr/lib/gcc-cross/riscv64-linux-gnu/11/
143+
135144
ENV RUST_CONFIGURE_ARGS --enable-extended --enable-lld --enable-llvm-bitcode-linker --disable-docs \
136-
--musl-root-armv7=/musl-armv7
145+
--musl-root-armv7=/musl-armv7 \
146+
--musl-root-riscv64gc=/musl-riscv64gc
137147

138148
ENV SCRIPT python3 ../x.py dist --host='' --target $TARGETS

‎src/doc/rustc/src/SUMMARY.md

+1
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666
- [riscv32imac-unknown-xous-elf](platform-support/riscv32imac-unknown-xous-elf.md)
6767
- [riscv32*-unknown-none-elf](platform-support/riscv32-unknown-none-elf.md)
6868
- [riscv64gc-unknown-linux-gnu](platform-support/riscv64gc-unknown-linux-gnu.md)
69+
- [riscv64gc-unknown-linux-musl](platform-support/riscv64gc-unknown-linux-musl.md)
6970
- [sparc-unknown-none-elf](./platform-support/sparc-unknown-none-elf.md)
7071
- [*-pc-windows-gnullvm](platform-support/pc-windows-gnullvm.md)
7172
- [\*-nto-qnx-\*](platform-support/nto-qnx.md)

‎src/doc/rustc/src/platform-support.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ target | notes
9898
`powerpc64-unknown-linux-gnu` | PPC64 Linux (kernel 3.2, glibc 2.17)
9999
`powerpc64le-unknown-linux-gnu` | PPC64LE Linux (kernel 3.10, glibc 2.17)
100100
[`riscv64gc-unknown-linux-gnu`](platform-support/riscv64gc-unknown-linux-gnu.md) | RISC-V Linux (kernel 4.20, glibc 2.29)
101+
[`riscv64gc-unknown-linux-musl`](platform-support/riscv64gc-unknown-linux-musl.md) | RISC-V Linux (kernel 4.20, musl 1.2.3)
101102
`s390x-unknown-linux-gnu` | S390x Linux (kernel 3.2, glibc 2.17)
102103
`x86_64-unknown-freebsd` | 64-bit FreeBSD
103104
`x86_64-unknown-illumos` | illumos
@@ -354,7 +355,6 @@ target | std | host | notes
354355
[`riscv64gc-unknown-hermit`](platform-support/hermit.md) | ✓ | | RISC-V Hermit
355356
`riscv64gc-unknown-freebsd` | | | RISC-V FreeBSD
356357
`riscv64gc-unknown-fuchsia` | | | RISC-V Fuchsia
357-
`riscv64gc-unknown-linux-musl` | | | RISC-V Linux (kernel 4.20, musl 1.2.3)
358358
[`riscv64gc-unknown-netbsd`](platform-support/netbsd.md) | ✓ | ✓ | RISC-V NetBSD
359359
[`riscv64gc-unknown-openbsd`](platform-support/openbsd.md) | ✓ | ✓ | OpenBSD/riscv64
360360
[`riscv64-linux-android`](platform-support/android.md) | | | RISC-V 64-bit Android
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# riscv64gc-unknown-linux-musl
2+
3+
**Tier: 2**
4+
5+
Target for RISC-V Linux programs using musl libc.
6+
7+
## Target maintainers
8+
9+
- [@Amanieu](https://github.com/Amanieu)
10+
- [@kraj](https://github.com/kraj)
11+
12+
## Requirements
13+
14+
Building the target itself requires a RISC-V compiler that is supported by `cc-rs`.
15+
16+
## Building the target
17+
18+
The target can be built by enabling it for a `rustc` build.
19+
20+
```toml
21+
[build]
22+
target = ["riscv64gc-unknown-linux-musl"]
23+
```
24+
25+
Make sure your C compiler is included in `$PATH`, then add it to the `config.toml`:
26+
27+
```toml
28+
[target.riscv64gc-unknown-linux-musl]
29+
cc = "riscv64-linux-gnu-gcc"
30+
cxx = "riscv64-linux-gnu-g++"
31+
ar = "riscv64-linux-gnu-ar"
32+
linker = "riscv64-linux-gnu-gcc"
33+
```
34+
35+
## Building Rust programs
36+
37+
This target are distributed through `rustup`, and otherwise require no
38+
special configuration.
39+
40+
## Cross-compilation
41+
42+
This target can be cross-compiled from any host.
43+
44+
## Testing
45+
46+
This target can be tested as normal with `x.py` on a RISC-V host or via QEMU
47+
emulation.

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

+1
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ static TARGETS: &[&str] = &[
141141
"riscv64gc-unknown-hermit",
142142
"riscv64gc-unknown-none-elf",
143143
"riscv64gc-unknown-linux-gnu",
144+
"riscv64gc-unknown-linux-musl",
144145
"s390x-unknown-linux-gnu",
145146
"sparc64-unknown-linux-gnu",
146147
"sparcv9-sun-solaris",

0 commit comments

Comments
 (0)
Failed to load comments.