Skip to content

Add powerpc-unknown-linux-musl target #45422

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from
Closed
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
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ matrix:
- env: IMAGE=armhf-gnu
if: branch = auto
- env: IMAGE=cross DEPLOY=1
if: branch = auto
# if: branch = auto
- env: IMAGE=cross2 DEPLOY=1
if: branch = auto
- env: IMAGE=dist-aarch64-linux DEPLOY=1
Expand Down
2 changes: 2 additions & 0 deletions src/bootstrap/configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ def v(*args):
"armv7-unknown-linux-musleabihf install directory")
v("musl-root-aarch64", "target.aarch64-unknown-linux-musl.musl-root",
"aarch64-unknown-linux-musl install directory")
v("musl-root-ppc", "target.powerpc-unknown-linux-musl.musl-root",
"powerpc-unknown-linux-musl install directory")
v("qemu-armhf-rootfs", "target.arm-unknown-linux-gnueabihf.qemu-rootfs",
"rootfs in qemu testing, you probably don't want to use this")
v("qemu-aarch64-rootfs", "target.aarch64-unknown-linux-gnu.qemu-rootfs",
Expand Down
1 change: 1 addition & 0 deletions src/bootstrap/native.rs
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,7 @@ impl Step for Openssl {
"mips64el-unknown-linux-gnuabi64" => "linux64-mips64",
"mipsel-unknown-linux-gnu" => "linux-mips32",
"powerpc-unknown-linux-gnu" => "linux-ppc",
"powerpc-unknown-linux-musl" => "linux-ppc",
"powerpc64-unknown-linux-gnu" => "linux-ppc64",
"powerpc64le-unknown-linux-gnu" => "linux-ppc64le",
"s390x-unknown-linux-gnu" => "linux64-s390x",
Expand Down
5 changes: 4 additions & 1 deletion src/ci/docker/cross/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
g++-arm-linux-gnueabi \
g++-arm-linux-gnueabihf \
g++-aarch64-linux-gnu \
g++-powerpc-linux-gnu \
gcc-sparc64-linux-gnu \
libc6-dev-sparc64-cross \
bzip2 \
Expand Down Expand Up @@ -48,6 +49,7 @@ ENV TARGETS=$TARGETS,arm-unknown-linux-musleabi
ENV TARGETS=$TARGETS,arm-unknown-linux-musleabihf
ENV TARGETS=$TARGETS,armv7-unknown-linux-musleabihf
ENV TARGETS=$TARGETS,aarch64-unknown-linux-musl
ENV TARGETS=$TARGETS,powerpc-unknown-linux-musl
ENV TARGETS=$TARGETS,sparc64-unknown-linux-gnu
ENV TARGETS=$TARGETS,x86_64-unknown-redox

Expand All @@ -65,7 +67,8 @@ ENV RUST_CONFIGURE_ARGS \
--musl-root-arm=/usr/local/arm-linux-musleabi \
--musl-root-armhf=/usr/local/arm-linux-musleabihf \
--musl-root-armv7=/usr/local/armv7-linux-musleabihf \
--musl-root-aarch64=/usr/local/aarch64-linux-musl
--musl-root-aarch64=/usr/local/aarch64-linux-musl \
--musl-root-ppc=/usr/local/ppc-linux-musl
ENV SCRIPT python2.7 ../x.py dist --target $TARGETS

# sccache
Expand Down
27 changes: 27 additions & 0 deletions src/ci/docker/cross/build-arm-musl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,25 @@ CFLAGS="" \
hide_output make -j$(nproc)
hide_output make install
cd ..
rm -rf musl-$MUSL

tar xf musl-$MUSL.tar.gz
cd musl-$MUSL
CC=powerpc-linux-gnu-gcc \
CFLAGS="-mlong-double-64" \
hide_output ./configure \
--prefix=/usr/local/ppc-linux-musl \
--enable-wrapper=gcc
hide_output make -j$(nproc)
hide_output make install
cd ..
rm -rf musl-$MUSL*

ln -nsf ../arm-linux-musleabi/bin/musl-gcc /usr/local/bin/arm-linux-musleabi-gcc
ln -nsf ../arm-linux-musleabihf/bin/musl-gcc /usr/local/bin/arm-linux-musleabihf-gcc
ln -nsf ../armv7-linux-musleabihf/bin/musl-gcc /usr/local/bin/armv7-linux-musleabihf-gcc
ln -nsf ../aarch64-linux-musl/bin/musl-gcc /usr/local/bin/aarch64-unknown-linux-musl-gcc
ln -nsf ../ppc-linux-musl/bin/musl-gcc /usr/local/bin/powerpc-unknown-linux-musl-gcc

curl -L https://github.com/llvm-mirror/llvm/archive/release_39.tar.gz | tar xzf -
curl -L https://github.com/llvm-mirror/libunwind/archive/release_39.tar.gz | tar xzf -
Expand Down Expand Up @@ -143,5 +156,19 @@ cp lib/libunwind.a /usr/local/aarch64-linux-musl/lib
cd ..
rm -rf libunwind-build

mkdir libunwind-build
cd libunwind-build
cmake ../libunwind-release_39 \
-DLLVM_PATH=/tmp/llvm-release_39 \
-DLIBUNWIND_ENABLE_SHARED=0 \
-DCMAKE_C_COMPILER=powerpc-linux-gnu-gcc \
-DCMAKE_CXX_COMPILER=powerpc-linux-gnu-g++ \
-DCMAKE_C_FLAGS="-D__ppc__ -mlong-double-64" \
-DCMAKE_CXX_FLAGS="-D__ppc__ -mlong-double-64"
make -j$(nproc)
cp lib/libunwind.a /usr/local/ppc-linux-musl/lib
cd ..
rm -rf libunwind-build

rm -rf libunwind-release_39
rm -rf llvm-release_39
1 change: 1 addition & 0 deletions src/librustc_back/target/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ supported_targets! {
("mips64el-unknown-linux-gnuabi64", mips64el_unknown_linux_gnuabi64),
("mipsel-unknown-linux-gnu", mipsel_unknown_linux_gnu),
("powerpc-unknown-linux-gnu", powerpc_unknown_linux_gnu),
("powerpc-unknown-linux-musl", powerpc_unknown_linux_musl),
("powerpc64-unknown-linux-gnu", powerpc64_unknown_linux_gnu),
("powerpc64le-unknown-linux-gnu", powerpc64le_unknown_linux_gnu),
("s390x-unknown-linux-gnu", s390x_unknown_linux_gnu),
Expand Down
35 changes: 35 additions & 0 deletions src/librustc_back/target/powerpc_unknown_linux_musl.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

use LinkerFlavor;
use target::{Target, TargetResult};

pub fn target() -> TargetResult {
let mut base = super::linux_musl_base::opts();
base.pre_link_args.get_mut(&LinkerFlavor::Gcc).unwrap().push("-m32".to_string());
base.max_atomic_width = Some(32);

// see #36994
base.exe_allocation_crate = None;

Ok(Target {
llvm_target: "powerpc-unknown-linux-musl".to_string(),
target_endian: "big".to_string(),
target_pointer_width: "32".to_string(),
target_c_int_width: "32".to_string(),
data_layout: "E-m:e-p:32:32-i64:64-n32".to_string(),
arch: "powerpc".to_string(),
target_os: "linux".to_string(),
target_env: "musl".to_string(),
target_vendor: "unknown".to_string(),
linker_flavor: LinkerFlavor::Gcc,
options: base,
})
}
1 change: 1 addition & 0 deletions src/tools/build-manifest/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ static TARGETS: &'static [&'static str] = &[
"mipsel-unknown-linux-gnu",
"mipsel-unknown-linux-musl",
"powerpc-unknown-linux-gnu",
"powerpc-unknown-linux-musl",
"powerpc64-unknown-linux-gnu",
"powerpc64le-unknown-linux-gnu",
"s390x-unknown-linux-gnu",
Expand Down