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 ad080db

Browse files
committedDec 9, 2024
Auto merge of rust-lang#133801 - Gelbpunkt:powerpc64le-unknown-linux-musl-tier-2, r=<try>
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
2 parents f6cb952 + 286de9f commit ad080db

File tree

10 files changed

+104
-8
lines changed

10 files changed

+104
-8
lines changed
 

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ pub(crate) fn target() -> Target {
1111
llvm_target: "powerpc64le-unknown-linux-musl".into(),
1212
metadata: crate::spec::TargetMetadata {
1313
description: Some("64-bit PowerPC Linux with musl 1.2.3, Little Endian".into()),
14-
tier: Some(3),
15-
host_tools: Some(false),
14+
tier: Some(2),
15+
host_tools: Some(true),
1616
std: Some(true),
1717
},
1818
pointer_width: 64,

‎src/bootstrap/configure.py

+5
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,11 @@ def v(*args):
245245
"target.mips64el-unknown-linux-muslabi64.musl-root",
246246
"mips64el-unknown-linux-muslabi64 install directory",
247247
)
248+
v(
249+
"musl-root-powerpc64le",
250+
"target.powerpc64le-unknown-linux-musl.musl-root",
251+
"powerpc64le-unknown-linux-musl install directory",
252+
)
248253
v(
249254
"musl-root-riscv32gc",
250255
"target.riscv32gc-unknown-linux-musl.musl-root",

‎src/bootstrap/src/core/build_steps/llvm.rs

+1
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,7 @@ pub(crate) fn is_ci_llvm_available(config: &Config, asserts: bool) -> bool {
217217
("powerpc-unknown-linux-gnu", false),
218218
("powerpc64-unknown-linux-gnu", false),
219219
("powerpc64le-unknown-linux-gnu", false),
220+
("powerpc64le-unknown-linux-musl", false),
220221
("riscv64gc-unknown-linux-gnu", false),
221222
("s390x-unknown-linux-gnu", false),
222223
("x86_64-unknown-freebsd", false),

‎src/ci/docker/host-x86_64/dist-powerpc64le-linux/Dockerfile

+27-4
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,46 @@ FROM ubuntu:22.04
33
COPY scripts/cross-apt-packages.sh /scripts/
44
RUN sh /scripts/cross-apt-packages.sh
55

6+
COPY scripts/crosstool-ng-git.sh /scripts/
7+
RUN sh /scripts/crosstool-ng-git.sh
8+
69
COPY scripts/rustbuild-setup.sh /scripts/
710
RUN sh /scripts/rustbuild-setup.sh
11+
812
WORKDIR /tmp
913

14+
COPY scripts/crosstool-ng-build.sh /scripts/
15+
COPY host-x86_64/dist-powerpc64le-linux/powerpc64le-unknown-linux-musl.defconfig /tmp/crosstool.defconfig
16+
RUN /scripts/crosstool-ng-build.sh
17+
18+
WORKDIR /build
19+
1020
RUN apt-get install -y --no-install-recommends rpm2cpio cpio
11-
COPY host-x86_64/dist-powerpc64le-linux/shared.sh host-x86_64/dist-powerpc64le-linux/build-powerpc64le-toolchain.sh /tmp/
21+
COPY host-x86_64/dist-powerpc64le-linux/shared.sh host-x86_64/dist-powerpc64le-linux/build-powerpc64le-toolchain.sh /build/
1222
RUN ./build-powerpc64le-toolchain.sh
1323

1424
COPY scripts/sccache.sh /scripts/
1525
RUN sh /scripts/sccache.sh
1626

27+
ENV PATH=$PATH:/x-tools/powerpc64le-unknown-linux-musl/bin
28+
1729
ENV \
1830
AR_powerpc64le_unknown_linux_gnu=powerpc64le-linux-gnu-ar \
1931
CC_powerpc64le_unknown_linux_gnu=powerpc64le-linux-gnu-gcc \
20-
CXX_powerpc64le_unknown_linux_gnu=powerpc64le-linux-gnu-g++
32+
CXX_powerpc64le_unknown_linux_gnu=powerpc64le-linux-gnu-g++ \
33+
AR_powerpc64le_unknown_linux_musl=powerpc64le-unknown-linux-musl-ar \
34+
CC_powerpc64le_unknown_linux_musl=powerpc64le-unknown-linux-musl-gcc \
35+
CXX_powerpc64le_unknown_linux_musl=powerpc64le-unknown-linux-musl-g++
36+
37+
ENV HOSTS=powerpc64le-unknown-linux-gnu,powerpc64le-unknown-linux-musl
2138

22-
ENV HOSTS=powerpc64le-unknown-linux-gnu
39+
ENV RUST_CONFIGURE_ARGS \
40+
--enable-extended \
41+
--enable-full-tools \
42+
--enable-profiler \
43+
--enable-sanitizers \
44+
--disable-docs \
45+
--set target.powerpc64le-unknown-linux-musl.crt-static=false \
46+
--musl-root-powerpc64le=/x-tools/powerpc64le-unknown-linux-musl/powerpc64le-unknown-linux-musl/sysroot/usr
2347

24-
ENV RUST_CONFIGURE_ARGS --enable-extended --enable-profiler --disable-docs
2548
ENV SCRIPT python3 ../x.py dist --host $HOSTS --target $HOSTS
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
CT_CONFIG_VERSION="4"
2+
CT_EXPERIMENTAL=y
3+
CT_PREFIX_DIR="/x-tools/${CT_TARGET}"
4+
CT_USE_MIRROR=y
5+
CT_MIRROR_BASE_URL="https://ci-mirrors.rust-lang.org/rustc"
6+
CT_ARCH_POWERPC=y
7+
CT_ARCH_LE=y
8+
CT_ARCH_64=y
9+
# CT_DEMULTILIB is not set
10+
CT_ARCH_ARCH="powerpc64le"
11+
CT_KERNEL_LINUX=y
12+
CT_LINUX_V_4_19=y
13+
CT_LIBC_MUSL=y
14+
CT_MUSL_V_1_2_3=y
15+
CT_CC_LANG_CXX=y
16+
CT_GETTEXT_NEEDED=y

‎src/ci/github-actions/jobs.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ auto:
189189
<<: *job-linux-4c
190190

191191
- image: dist-powerpc64le-linux
192-
<<: *job-linux-4c
192+
<<: *job-linux-4c-largedisk
193193

194194
- image: dist-riscv64-linux
195195
<<: *job-linux-4c

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

+1
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666
- [powerpc-unknown-openbsd](platform-support/powerpc-unknown-openbsd.md)
6767
- [powerpc-unknown-linux-muslspe](platform-support/powerpc-unknown-linux-muslspe.md)
6868
- [powerpc64-ibm-aix](platform-support/aix.md)
69+
- [powerpc64le-unknown-linux-musl](platform-support/powerpc64le-unknown-linux-musl.md)
6970
- [riscv32e*-unknown-none-elf](platform-support/riscv32e-unknown-none-elf.md)
7071
- [riscv32i*-unknown-none-elf](platform-support/riscv32-unknown-none-elf.md)
7172
- [riscv32im-risc0-zkvm-elf](platform-support/riscv32im-risc0-zkvm-elf.md)

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ target | notes
9797
`powerpc-unknown-linux-gnu` | PowerPC Linux (kernel 3.2, glibc 2.17)
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)
100+
[`powerpc64le-unknown-linux-musl`](platform-support/powerpc64le-unknown-linux-musl.md) | PPC64LE Linux (kernel 4.19, musl 1.2.3)
100101
[`riscv64gc-unknown-linux-gnu`](platform-support/riscv64gc-unknown-linux-gnu.md) | RISC-V Linux (kernel 4.20, glibc 2.29)
101102
[`riscv64gc-unknown-linux-musl`](platform-support/riscv64gc-unknown-linux-musl.md) | RISC-V Linux (kernel 4.20, musl 1.2.3)
102103
[`s390x-unknown-linux-gnu`](platform-support/s390x-unknown-linux-gnu.md) | S390x Linux (kernel 3.2, glibc 2.17)
@@ -348,7 +349,6 @@ target | std | host | notes
348349
`powerpc-unknown-freebsd` | ? | | PowerPC FreeBSD
349350
`powerpc64-unknown-linux-musl` | ? | | 64-bit PowerPC Linux with musl 1.2.3
350351
[`powerpc64-wrs-vxworks`](platform-support/vxworks.md) | ✓ | |
351-
`powerpc64le-unknown-linux-musl` | ? | | 64-bit PowerPC Linux with musl 1.2.3, Little Endian
352352
[`powerpc64-unknown-openbsd`](platform-support/openbsd.md) | ✓ | ✓ | OpenBSD/powerpc64
353353
[`powerpc64-ibm-aix`](platform-support/aix.md) | ? | | 64-bit AIX (7.2 and newer)
354354
`riscv32gc-unknown-linux-gnu` | ✓ | | RISC-V Linux (kernel 5.4, glibc 2.33)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# powerpc64le-unknown-linux-musl
2+
3+
**Tier: 2**
4+
5+
Target for 64-bit little endian PowerPC Linux programs using musl libc.
6+
7+
## Target maintainers
8+
9+
- [@Gelbpunkt](https://github.com/Gelbpunkt)
10+
- [@famfo](https://github.com/famfo)
11+
- [@neuschaefer](https://github.com/neuschaefer)
12+
13+
## Requirements
14+
15+
Building the target itself requires a 64-bit little endian PowerPC compiler that is supported by `cc-rs`.
16+
17+
## Building the target
18+
19+
The target can be built by enabling it for a `rustc` build.
20+
21+
```toml
22+
[build]
23+
target = ["powerpc64le-unknown-linux-musl"]
24+
```
25+
26+
Make sure your C compiler is included in `$PATH`, then add it to the `config.toml`:
27+
28+
```toml
29+
[target.powerpc64le-unknown-linux-musl]
30+
cc = "powerpc64le-linux-musl-gcc"
31+
cxx = "powerpc64le-linux-musl-g++"
32+
ar = "powerpc64le-linux-musl-ar"
33+
linker = "powerpc64le-linux-musl-gcc"
34+
```
35+
36+
## Building Rust programs
37+
38+
This target are distributed through `rustup`, and otherwise require no
39+
special configuration.
40+
41+
## Cross-compilation
42+
43+
This target can be cross-compiled from any host.
44+
45+
## Testing
46+
47+
This target can be tested as normal with `x.py` on a 64-bit little endian
48+
PowerPC host or via QEMU emulation.

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

+2
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ static HOSTS: &[&str] = &[
3737
"powerpc-unknown-linux-gnu",
3838
"powerpc64-unknown-linux-gnu",
3939
"powerpc64le-unknown-linux-gnu",
40+
"powerpc64le-unknown-linux-musl",
4041
"riscv64gc-unknown-linux-gnu",
4142
"s390x-unknown-linux-gnu",
4243
"x86_64-apple-darwin",
@@ -131,6 +132,7 @@ static TARGETS: &[&str] = &[
131132
"powerpc-unknown-linux-gnu",
132133
"powerpc64-unknown-linux-gnu",
133134
"powerpc64le-unknown-linux-gnu",
135+
"powerpc64le-unknown-linux-musl",
134136
"riscv32i-unknown-none-elf",
135137
"riscv32im-risc0-zkvm-elf",
136138
"riscv32im-unknown-none-elf",

0 commit comments

Comments
 (0)
Failed to load comments.