Skip to content

Commit

Permalink
Rollup merge of rust-lang#133801 - Gelbpunkt:powerpc64le-unknown-linu…
Browse files Browse the repository at this point in the history
…x-musl-tier-2, r=jieyouxu,Urgau,Kobzol

Promote powerpc64le-unknown-linux-musl to tier 2 with host tools

MCP: rust-lang/compiler-team#803

I'm using crosstool-ng for building a toolchain because GCC 9 from `musl-toolchain.sh` has float ABI issues (?) and can't compile LLVM, and writing a crosstool-ng config for a target feels less hacky than yet another target specific shell script. I also defined a kernel version, since there wasn't one specified before. If a lower version is desired, just let me know. I also tried to match the rust configure args with the loongarch64 musl tier 2 target.

The resulting compiler works fine, built with `DEPLOY=1 ./src/ci/docker/run.sh dist-powerpc64le-linux` and tested on Alpine Linux in a VM and on a bare metal POWER8 machine:
```
qemu-ppc64le:/tmp/rust-nightly-powerpc64le-unknown-linux-musl$ ash install.sh
install: creating uninstall script at /usr/local/lib/rustlib/uninstall.sh
install: installing component 'rustc'
install: installing component 'rust-std-powerpc64le-unknown-linux-musl'
install: installing component 'cargo'
install: installing component 'rustfmt-preview'
install: installing component 'rls-preview'
install: installing component 'rust-analyzer-preview'
install: installing component 'llvm-tools-preview'
install: installing component 'clippy-preview'
install: installing component 'miri-preview'
install: installing component 'rust-analysis-powerpc64le-unknown-linux-musl'
install: installing component 'llvm-bitcode-linker-preview'
install: WARNING: failed to run ldconfig. this may happen when not installing as root. run with --verbose to see the error

    rust installed.

qemu-ppc64le:~$ echo 'fn main() { println!("hello world"); }' > test.rs
qemu-ppc64le:~$ rustc test.rs
qemu-ppc64le:~$ ./test
hello world
qemu-ppc64le:~$ file test
test: ELF 64-bit LSB executable, 64-bit PowerPC or cisco 7500, OpenPOWER ELF V2 ABI, version 1 (SYSV), statically linked, BuildID[sha1]=596ee6abf9add487ebc54fb71c2076fb6faea013, with debug_info, not stripped
```

try-job: dist-powerpc64le-linux
  • Loading branch information
jieyouxu authored Dec 17, 2024
2 parents 18989bc + 286de9f commit 21b8fe1
Show file tree
Hide file tree
Showing 10 changed files with 104 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ pub(crate) fn target() -> Target {
llvm_target: "powerpc64le-unknown-linux-musl".into(),
metadata: crate::spec::TargetMetadata {
description: Some("64-bit PowerPC Linux with musl 1.2.3, Little Endian".into()),
tier: Some(3),
host_tools: Some(false),
tier: Some(2),
host_tools: Some(true),
std: Some(true),
},
pointer_width: 64,
Expand Down
5 changes: 5 additions & 0 deletions src/bootstrap/configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,11 @@ def v(*args):
"target.mips64el-unknown-linux-muslabi64.musl-root",
"mips64el-unknown-linux-muslabi64 install directory",
)
v(
"musl-root-powerpc64le",
"target.powerpc64le-unknown-linux-musl.musl-root",
"powerpc64le-unknown-linux-musl install directory",
)
v(
"musl-root-riscv32gc",
"target.riscv32gc-unknown-linux-musl.musl-root",
Expand Down
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 @@ -217,6 +217,7 @@ pub(crate) fn is_ci_llvm_available(config: &Config, asserts: bool) -> bool {
("powerpc-unknown-linux-gnu", false),
("powerpc64-unknown-linux-gnu", false),
("powerpc64le-unknown-linux-gnu", false),
("powerpc64le-unknown-linux-musl", false),
("riscv64gc-unknown-linux-gnu", false),
("s390x-unknown-linux-gnu", false),
("x86_64-unknown-freebsd", false),
Expand Down
31 changes: 27 additions & 4 deletions src/ci/docker/host-x86_64/dist-powerpc64le-linux/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,46 @@ FROM ubuntu:22.04
COPY scripts/cross-apt-packages.sh /scripts/
RUN sh /scripts/cross-apt-packages.sh

COPY scripts/crosstool-ng-git.sh /scripts/
RUN sh /scripts/crosstool-ng-git.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-powerpc64le-linux/powerpc64le-unknown-linux-musl.defconfig /tmp/crosstool.defconfig
RUN /scripts/crosstool-ng-build.sh

WORKDIR /build

RUN apt-get install -y --no-install-recommends rpm2cpio cpio
COPY host-x86_64/dist-powerpc64le-linux/shared.sh host-x86_64/dist-powerpc64le-linux/build-powerpc64le-toolchain.sh /tmp/
COPY host-x86_64/dist-powerpc64le-linux/shared.sh host-x86_64/dist-powerpc64le-linux/build-powerpc64le-toolchain.sh /build/
RUN ./build-powerpc64le-toolchain.sh

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

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

ENV \
AR_powerpc64le_unknown_linux_gnu=powerpc64le-linux-gnu-ar \
CC_powerpc64le_unknown_linux_gnu=powerpc64le-linux-gnu-gcc \
CXX_powerpc64le_unknown_linux_gnu=powerpc64le-linux-gnu-g++
CXX_powerpc64le_unknown_linux_gnu=powerpc64le-linux-gnu-g++ \
AR_powerpc64le_unknown_linux_musl=powerpc64le-unknown-linux-musl-ar \
CC_powerpc64le_unknown_linux_musl=powerpc64le-unknown-linux-musl-gcc \
CXX_powerpc64le_unknown_linux_musl=powerpc64le-unknown-linux-musl-g++

ENV HOSTS=powerpc64le-unknown-linux-gnu,powerpc64le-unknown-linux-musl

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

ENV RUST_CONFIGURE_ARGS --enable-extended --enable-profiler --disable-docs
ENV SCRIPT python3 ../x.py dist --host $HOSTS --target $HOSTS
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
CT_CONFIG_VERSION="4"
CT_EXPERIMENTAL=y
CT_PREFIX_DIR="/x-tools/${CT_TARGET}"
CT_USE_MIRROR=y
CT_MIRROR_BASE_URL="https://ci-mirrors.rust-lang.org/rustc"
CT_ARCH_POWERPC=y
CT_ARCH_LE=y
CT_ARCH_64=y
# CT_DEMULTILIB is not set
CT_ARCH_ARCH="powerpc64le"
CT_KERNEL_LINUX=y
CT_LINUX_V_4_19=y
CT_LIBC_MUSL=y
CT_MUSL_V_1_2_3=y
CT_CC_LANG_CXX=y
CT_GETTEXT_NEEDED=y
2 changes: 1 addition & 1 deletion src/ci/github-actions/jobs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ auto:
<<: *job-linux-4c

- image: dist-powerpc64le-linux
<<: *job-linux-4c
<<: *job-linux-4c-largedisk

- image: dist-riscv64-linux
<<: *job-linux-4c
Expand Down
1 change: 1 addition & 0 deletions src/doc/rustc/src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
- [powerpc-unknown-openbsd](platform-support/powerpc-unknown-openbsd.md)
- [powerpc-unknown-linux-muslspe](platform-support/powerpc-unknown-linux-muslspe.md)
- [powerpc64-ibm-aix](platform-support/aix.md)
- [powerpc64le-unknown-linux-musl](platform-support/powerpc64le-unknown-linux-musl.md)
- [riscv32e*-unknown-none-elf](platform-support/riscv32e-unknown-none-elf.md)
- [riscv32i*-unknown-none-elf](platform-support/riscv32-unknown-none-elf.md)
- [riscv32im-risc0-zkvm-elf](platform-support/riscv32im-risc0-zkvm-elf.md)
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 @@ -97,6 +97,7 @@ target | notes
`powerpc-unknown-linux-gnu` | PowerPC Linux (kernel 3.2, glibc 2.17)
`powerpc64-unknown-linux-gnu` | PPC64 Linux (kernel 3.2, glibc 2.17)
`powerpc64le-unknown-linux-gnu` | 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.3)
[`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.3)
[`s390x-unknown-linux-gnu`](platform-support/s390x-unknown-linux-gnu.md) | S390x Linux (kernel 3.2, glibc 2.17)
Expand Down Expand Up @@ -348,7 +349,6 @@ target | std | host | notes
`powerpc-unknown-freebsd` | ? | | PowerPC FreeBSD
`powerpc64-unknown-linux-musl` | ? | | 64-bit PowerPC Linux with musl 1.2.3
[`powerpc64-wrs-vxworks`](platform-support/vxworks.md) | ✓ | |
`powerpc64le-unknown-linux-musl` | ? | | 64-bit PowerPC Linux with musl 1.2.3, Little Endian
[`powerpc64-unknown-openbsd`](platform-support/openbsd.md) | ✓ | ✓ | OpenBSD/powerpc64
[`powerpc64-ibm-aix`](platform-support/aix.md) | ? | | 64-bit AIX (7.2 and newer)
`riscv32gc-unknown-linux-gnu` | ✓ | | RISC-V Linux (kernel 5.4, glibc 2.33)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# powerpc64le-unknown-linux-musl

**Tier: 2**

Target for 64-bit little endian PowerPC Linux programs using musl libc.

## Target maintainers

- [@Gelbpunkt](https://github.com/Gelbpunkt)
- [@famfo](https://github.com/famfo)
- [@neuschaefer](https://github.com/neuschaefer)

## Requirements

Building the target itself requires a 64-bit little endian PowerPC compiler that is supported by `cc-rs`.

## Building the target

The target can be built by enabling it for a `rustc` build.

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

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

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

## Building Rust programs

This target are distributed through `rustup`, and otherwise require no
special configuration.

## Cross-compilation

This target can be cross-compiled from any host.

## Testing

This target can be tested as normal with `x.py` on a 64-bit little endian
PowerPC host or via QEMU emulation.
2 changes: 2 additions & 0 deletions src/tools/build-manifest/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ static HOSTS: &[&str] = &[
"powerpc-unknown-linux-gnu",
"powerpc64-unknown-linux-gnu",
"powerpc64le-unknown-linux-gnu",
"powerpc64le-unknown-linux-musl",
"riscv64gc-unknown-linux-gnu",
"s390x-unknown-linux-gnu",
"x86_64-apple-darwin",
Expand Down Expand Up @@ -131,6 +132,7 @@ static TARGETS: &[&str] = &[
"powerpc-unknown-linux-gnu",
"powerpc64-unknown-linux-gnu",
"powerpc64le-unknown-linux-gnu",
"powerpc64le-unknown-linux-musl",
"riscv32i-unknown-none-elf",
"riscv32im-risc0-zkvm-elf",
"riscv32im-unknown-none-elf",
Expand Down

0 comments on commit 21b8fe1

Please sign in to comment.