Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ pub(crate) fn target() -> Target {
metadata: TargetMetadata {
description: Some("RISC-V Linux (kernel 4.20, musl 1.2.5)".into()),
tier: Some(2),
host_tools: Some(false),
host_tools: Some(true),
std: Some(true),
},
pointer_width: 64,
Expand Down
2 changes: 1 addition & 1 deletion src/bootstrap/download-ci-llvm-stamp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Change this file to make users of the `download-ci-llvm` configuration download
a new version of LLVM from CI, even if the LLVM submodule hasn’t changed.

Last change is for: https://github.com/rust-lang/rust/pull/157385
Last change is for: https://github.com/rust-lang/rust/pull/158766
1 change: 1 addition & 0 deletions src/bootstrap/src/core/build_steps/llvm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ pub(crate) fn is_ci_llvm_available_for_target(
("powerpc64le-unknown-linux-gnu", false),
("powerpc64le-unknown-linux-musl", false),
("riscv64gc-unknown-linux-gnu", false),
("riscv64gc-unknown-linux-musl", false),
("s390x-unknown-linux-gnu", false),
("x86_64-pc-windows-gnullvm", false),
("x86_64-unknown-freebsd", false),
Expand Down
1 change: 1 addition & 0 deletions src/bootstrap/src/core/download.rs
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,7 @@ pub(crate) fn is_download_ci_available(target_triple: &str, llvm_assertions: boo
"powerpc64le-unknown-linux-gnu",
"powerpc64le-unknown-linux-musl",
"riscv64gc-unknown-linux-gnu",
"riscv64gc-unknown-linux-musl",
"s390x-unknown-linux-gnu",
"x86_64-apple-darwin",
"x86_64-pc-windows-gnu",
Expand Down
16 changes: 16 additions & 0 deletions src/ci/docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,22 @@ For targets: `riscv64-unknown-linux-gnu`
- C compiler > gcc version = 8.5.0
- C compiler > C++ = ENABLE -- to cross compile LLVM

### `riscv64-unknown-linux-musl.defconfig`

For targets: `riscv64-unknown-linux-musl`

- Path and misc options > Prefix directory = /x-tools/${CT\_TARGET}
- Path and misc options > Use a mirror = ENABLE
- Path and misc options > Base URL = https://ci-mirrors.rust-lang.org/rustc
- Target options > Target Architecture = riscv
- Target options > Bitness = 64-bit
- Operating System > Target OS = linux
- Operating System > Linux kernel version = 4.20.17
- Binary utilities > Version of binutils = 2.40
- C-library > musl version = 1.2.5
- C compiler > gcc version = 8.5.0
- C compiler > C++ = ENABLE -- to cross compile LLVM

### `s390x-linux-gnu.defconfig`

For targets: `s390x-unknown-linux-gnu`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ RUN sh /scripts/rustbuild-setup.sh
WORKDIR /tmp

COPY scripts/crosstool-ng-build.sh /scripts/
COPY host-x86_64/dist-riscv64-linux/riscv64-unknown-linux-gnu.defconfig /tmp/crosstool.defconfig
COPY host-x86_64/dist-riscv64-linux-gnu/riscv64-unknown-linux-gnu.defconfig /tmp/crosstool.defconfig
RUN /scripts/crosstool-ng-build.sh

COPY scripts/sccache.sh /scripts/
Expand Down
39 changes: 39 additions & 0 deletions src/ci/docker/host-x86_64/dist-riscv64-linux-musl/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
FROM ubuntu:22.04

COPY scripts/cross-apt-packages.sh /scripts/
RUN sh /scripts/cross-apt-packages.sh

COPY scripts/crosstool-ng.sh /scripts/
COPY scripts/crosstool-ng-sha256-20260705.diff /scripts/
RUN sh /scripts/crosstool-ng.sh

COPY scripts/rustbuild-setup.sh /scripts/
RUN sh /scripts/rustbuild-setup.sh

WORKDIR /tmp

COPY scripts/crosstool-ng-build.sh /scripts/
COPY host-x86_64/dist-riscv64-linux-musl/riscv64-unknown-linux-musl.defconfig /tmp/crosstool.defconfig
RUN /scripts/crosstool-ng-build.sh

COPY scripts/sccache.sh /scripts/
RUN sh /scripts/sccache.sh

ENV PATH=$PATH:/x-tools/riscv64-unknown-linux-musl/bin

ENV CC_riscv64gc_unknown_linux_musl=riscv64-unknown-linux-musl-gcc \
AR_riscv64gc_unknown_linux_musl=riscv64-unknown-linux-musl-ar \
CXX_riscv64gc_unknown_linux_musl=riscv64-unknown-linux-musl-g++

ENV HOSTS=riscv64gc-unknown-linux-musl
ENV TARGETS=riscv64gc-unknown-linux-musl

ENV RUST_CONFIGURE_ARGS="--enable-extended \
--enable-full-tools \
--enable-profiler \
--enable-sanitizers \
--disable-docs \
--set target.riscv64gc-unknown-linux-musl.crt-static=false \
--musl-root-riscv64gc=/x-tools/riscv64-unknown-linux-musl/riscv64-unknown-linux-musl/sysroot/usr"

ENV SCRIPT="python3 ../x.py dist --target $TARGETS --host $HOSTS"
Comment thread
eshattow marked this conversation as resolved.
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
CT_CONFIG_VERSION="4"
CT_PREFIX_DIR="/x-tools/${CT_TARGET}"
CT_USE_MIRROR=y
CT_MIRROR_BASE_URL="https://ci-mirrors.rust-lang.org/rustc"
Comment thread
eshattow marked this conversation as resolved.
CT_VERIFY_DOWNLOAD_DIGEST_SHA256=y
CT_ARCH_RISCV=y
CT_ARCH_USE_MMU=y
CT_ARCH_64=y
CT_ARCH_ARCH="rv64gc"
CT_KERNEL_LINUX=y
CT_LINUX_V_4_20=y
CT_LIBC_MUSL=y
CT_BINUTILS_V_2_40=y
CT_MUSL_V_1_2_5=y
CT_GCC_V_8=y
CT_CC_LANG_CXX=y
14 changes: 2 additions & 12 deletions src/ci/docker/host-x86_64/dist-various-2/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ RUN apt-get update && apt-get build-dep -y clang llvm && apt-get install -y --no
# Needed for apt-key to work:
dirmngr \
gpg-agent \
g++-9-arm-linux-gnueabi \
g++-11-riscv64-linux-gnu
g++-9-arm-linux-gnueabi

ENV \
AR_x86_64_unknown_fuchsia=x86_64-unknown-fuchsia-ar \
Expand Down Expand Up @@ -71,10 +70,6 @@ RUN env \
CC=arm-linux-gnueabi-gcc-9 CFLAGS="-march=armv7-a" \
CXX=arm-linux-gnueabi-g++-9 CXXFLAGS="-march=armv7-a" \
bash musl.sh armv7 && \
env \
CC=riscv64-linux-gnu-gcc-11 \
CXX=riscv64-linux-gnu-g++-11 \
bash musl.sh riscv64gc && \
rm -rf /build/*

WORKDIR /tmp
Expand Down Expand Up @@ -120,7 +115,6 @@ ENV TARGETS=$TARGETS,x86_64-unknown-none
ENV TARGETS=$TARGETS,aarch64-unknown-uefi
ENV TARGETS=$TARGETS,i686-unknown-uefi
ENV TARGETS=$TARGETS,x86_64-unknown-uefi
ENV TARGETS=$TARGETS,riscv64gc-unknown-linux-musl

ENV TARGETS_SANITIZERS=x86_64-unknown-linux-gnuasan
ENV TARGETS_SANITIZERS=$TARGETS_SANITIZERS,x86_64-unknown-linux-gnumsan
Expand All @@ -132,11 +126,7 @@ ENV TARGETS_SANITIZERS=$TARGETS_SANITIZERS,x86_64-unknown-linux-gnutsan
# Luckily one of the folders is /usr/local/include so symlink /usr/include/x86_64-linux-gnu/asm there
RUN ln -s /usr/include/x86_64-linux-gnu/asm /usr/local/include/asm

# musl-gcc can't find libgcc_s.so.1 since it doesn't use the standard search paths.
RUN ln -s /usr/riscv64-linux-gnu/lib/libgcc_s.so.1 /usr/lib/gcc-cross/riscv64-linux-gnu/11/

ENV RUST_CONFIGURE_ARGS="--enable-extended --enable-lld --enable-llvm-bitcode-linker --disable-docs \
--musl-root-armv7=/musl-armv7 \
--musl-root-riscv64gc=/musl-riscv64gc"
--musl-root-armv7=/musl-armv7"

ENV SCRIPT="python3 ../x.py dist --host= --target $TARGETS && python3 ../x.py dist --host= --set build.sanitizers=true --target $TARGETS_SANITIZERS"
5 changes: 4 additions & 1 deletion src/ci/github-actions/jobs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,10 @@ auto:
- name: dist-powerpc64le-linux-musl
<<: *job-linux-4c

- name: dist-riscv64-linux
- name: dist-riscv64-linux-gnu
<<: *job-linux-4c

- name: dist-riscv64-linux-musl
<<: *job-linux-4c

- name: dist-s390x-linux
Expand Down
2 changes: 1 addition & 1 deletion src/doc/rustc/src/platform-support.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ target | notes
[`powerpc64le-unknown-linux-gnu`](platform-support/powerpc64le-unknown-linux-gnu.md) | PPC64LE Linux (kernel 3.10+, glibc 2.17)
[`powerpc64le-unknown-linux-musl`](platform-support/powerpc64le-unknown-linux-musl.md) | PPC64LE Linux (kernel 4.19+, musl 1.2.5)
[`riscv64gc-unknown-linux-gnu`](platform-support/riscv64gc-unknown-linux-gnu.md) | RISC-V Linux (kernel 4.20+, glibc 2.29)
[`riscv64gc-unknown-linux-musl`](platform-support/riscv64gc-unknown-linux-musl.md) | RISC-V Linux (kernel 4.20+, musl 1.2.5)
[`s390x-unknown-linux-gnu`](platform-support/s390x-unknown-linux-gnu.md) | S390x Linux (kernel 3.2+, glibc 2.17)
[`x86_64-apple-darwin`](platform-support/apple-darwin.md) | 64-bit macOS (10.12+, Sierra+)
[`x86_64-pc-windows-gnullvm`](platform-support/windows-gnullvm.md) | 64-bit x86 MinGW (Windows 10+), LLVM ABI
Expand Down Expand Up @@ -196,7 +197,6 @@ target | std | notes
[`riscv32imafc-unknown-none-elf`](platform-support/riscv32-unknown-none-elf.md) | * | Bare RISC-V (RV32IMAFC ISA)
[`riscv32imc-unknown-none-elf`](platform-support/riscv32-unknown-none-elf.md) | * | Bare RISC-V (RV32IMC ISA)
[`riscv64a23-unknown-linux-gnu`](platform-support/riscv64a23-unknown-linux-gnu.md) | ✓ | RISC-V Linux (kernel 6.8.0+, glibc 2.39)
[`riscv64gc-unknown-linux-musl`](platform-support/riscv64gc-unknown-linux-musl.md) | ✓ |RISC-V Linux (kernel 4.20+, musl 1.2.5)
`riscv64gc-unknown-none-elf` | * | Bare RISC-V (RV64IMAFDC ISA)
[`riscv64im-unknown-none-elf`](platform-support/riscv64im-unknown-none-elf.md) | * | Bare RISC-V (RV64IM ISA)
`riscv64imac-unknown-none-elf` | * | Bare RISC-V (RV64IMAC ISA)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

**Tier: 2 (with Host Tools)**

RISC-V targets using the *RV64I* base instruction set with the *G* collection of extensions, as well as the *C* extension.
Linux GNU libc RISC-V target using the *RV64I* base instruction set with the
*G* collection of extensions, as well as the *C* extension.


## Target maintainers
Expand All @@ -22,10 +23,10 @@ This target requires:

## Building the target

These targets are distributed through `rustup`, and otherwise require no
This target is distributed through `rustup`, and otherwise requires no
special configuration.

If you need to build your own Rust for some reason though, the targets can be
If you need to build your own Rust for some reason though, the target can be
enabled in `bootstrap.toml`. For example:

```toml
Expand All @@ -37,10 +38,10 @@ target = ["riscv64gc-unknown-linux-gnu"]
## Building Rust programs


On a RISC-V host, the `riscv64gc-unknown-linux-gnu` target should be automatically
installed and used by default.
On a riscv64gc-unknown-linux-gnu host, the `riscv64gc-unknown-linux-gnu`
target should be automatically installed and used by default.

On a non-RISC-V host, add the target:
On all other hosts, add the target:

```bash
rustup target add riscv64gc-unknown-linux-gnu
Expand All @@ -55,7 +56,7 @@ cargo build --target riscv64gc-unknown-linux-gnu

## Testing

There are no special requirements for testing and running the targets.
There are no special requirements for testing and running the target.
For testing cross builds on the host, please refer to the "Cross-compilation
toolchains and C code"
section below.
Expand Down
45 changes: 27 additions & 18 deletions src/doc/rustc/src/platform-support/riscv64gc-unknown-linux-musl.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# riscv64gc-unknown-linux-musl

**Tier: 2**
**Tier: 2 (with Host Tools)**

Linux musl libc RISC-V target using the *RV64I* base instruction set with the
*G* collection of extensions, as well as the *C* extension.

Target for RISC-V Linux programs using musl libc.

## Target maintainers

Expand All @@ -11,37 +13,44 @@ Target for RISC-V Linux programs using musl libc.

## Requirements

Building the target itself requires a RISC-V compiler that is supported by `cc-rs`.
This target requires:

* Linux Kernel version 4.20 or later
* musl libc 1.2.5 or later


## Building the target

The target can be built by enabling it for a `rustc` build.
This target is distributed through `rustup`, and otherwise requires no
special configuration.

If you need to build your own Rust then the targets can be enabled in
`bootstrap.toml`. For example:

```toml
[build]
target = ["riscv64gc-unknown-linux-musl"]
```

Make sure your C compiler is included in `$PATH`, then add it to the `bootstrap.toml`:

```toml
[target.riscv64gc-unknown-linux-musl]
cc = "riscv64-linux-gnu-gcc"
cxx = "riscv64-linux-gnu-g++"
ar = "riscv64-linux-gnu-ar"
linker = "riscv64-linux-gnu-gcc"
```

## Building Rust programs

This target are distributed through `rustup`, and otherwise require no
special configuration.
On a riscv64gc-unknown-linux-musl host, the `riscv64gc-unknown-linux-musl`
target should be automatically installed and used by default.

On all other hosts, add the target:

## Cross-compilation
```bash
rustup target add riscv64gc-unknown-linux-musl
```

Then cross compile crates with:

This target can be cross-compiled from any host.
```bash
cargo build --target riscv64gc-unknown-linux-musl
```

## Testing

This target can be tested as normal with `x.py` on a RISC-V host or via QEMU
The target can be tested as normal with `x.py` on a RISC-V host or via QEMU
emulation.
Loading