Skip to content
This repository was archived by the owner on Nov 21, 2018. It is now read-only.

Commit 23b0839

Browse files
authored
Merge pull request #149 from cuviper/custom-powerpc-s390x
Add custom toolchains for powerpc* and s390x
2 parents a679a6d + 5959a3c commit 23b0839

12 files changed

+1834
-12
lines changed

slaves/linux-cross/Dockerfile

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,9 @@ RUN apt-get install -y --force-yes --no-install-recommends \
77
zlib1g-dev \
88
bzip2 xz-utils \
99
g++ libc6-dev \
10-
g++-powerpc-linux-gnu libc6-dev-powerpc-cross \
11-
g++-5-powerpc64-linux-gnu libc6-dev-ppc64-powerpc-cross \
12-
g++-powerpc64le-linux-gnu libc6-dev-ppc64el-cross \
13-
g++-s390x-linux-gnu \
1410
bsdtar \
1511
cmake \
12+
rpm2cpio cpio \
1613
g++-5-mips-linux-gnu libc6-dev-mips-cross \
1714
g++-5-mipsel-linux-gnu libc6-dev-mipsel-cross \
1815
pkg-config
@@ -60,7 +57,11 @@ COPY linux-cross/build_toolchain.sh \
6057
linux-cross/mipsel-linux-musl.config \
6158
linux-cross/armv7-linux-gnueabihf.config \
6259
linux-cross/armv7-linux-musleabihf.config \
60+
linux-cross/powerpc-linux-gnu.config \
61+
linux-cross/powerpc64-linux-gnu.config \
62+
linux-cross/s390x-linux-gnu.config \
6363
/build/
64+
COPY linux-cross/patches /build/patches
6465
USER rustbuild
6566

6667
# Build three full toolchains for the `arm-unknown-linux-gneuabi`,
@@ -108,11 +109,18 @@ RUN /bin/bash build_toolchain.sh arm-linux-musleabi
108109
RUN /bin/bash build_toolchain.sh arm-linux-musleabihf
109110
RUN /bin/bash build_toolchain.sh armv7-linux-musleabihf
110111

112+
# Also build toolchains for {powerpc{,64},s390x}-unknown-linux-gnu,
113+
# primarily to support older glibc than found in the Ubuntu root.
114+
RUN /bin/bash build_toolchain.sh powerpc-linux-gnu
115+
RUN /bin/bash build_toolchain.sh powerpc64-linux-gnu
116+
RUN /bin/bash build_toolchain.sh s390x-linux-gnu
117+
111118
USER root
112119

113120
# Rename all the compilers we just built into /usr/bin and also without
114121
# `-unknown-` in the name because it appears lots of other compilers in Ubuntu
115122
# don't have this name in the component by default either.
123+
# Also rename `-ibm-` out of the s390x compilers.
116124
# Also the aarch64 compiler is prefixed with `aarch64-unknown-linux-gnueabi`
117125
# by crosstool-ng, but Ubuntu just prefixes it with `aarch64-linux-gnu` so
118126
# we'll, additionally, strip the eabi part from its binaries.
@@ -121,6 +129,10 @@ RUN \
121129
g=`basename $f`; \
122130
ln -vs $f /usr/bin/`echo $g | sed -e 's/-unknown//'`; \
123131
done && \
132+
for f in `ls /x-tools/*-ibm-linux-*/bin/*-ibm-linux-*`; do \
133+
g=`basename $f`; \
134+
ln -vs $f /usr/bin/`echo $g | sed -e 's/-ibm//'`; \
135+
done && \
124136
for f in `ls /usr/bin/aarch64-linux-gnueabi-*`; do \
125137
g=`basename $f`; \
126138
mv -v $f /usr/bin/`echo $g | sed -e 's/eabi//'`; \
@@ -134,6 +146,11 @@ RUN bash /tmp/build_dragonfly_toolchain.sh
134146
COPY linux-cross/build_netbsd_toolchain.sh /tmp/
135147
RUN bash /tmp/build_netbsd_toolchain.sh
136148

149+
# powerpc64le is built using centos7 glibc, because that has
150+
# backports that weren't committed upstream until glibc-2.19.
151+
COPY linux-cross/build_powerpc64le_linux_toolchain.sh /tmp/
152+
RUN bash /tmp/build_powerpc64le_linux_toolchain.sh
153+
137154
# Also build libunwind.a for the ARM musl targets
138155
COPY linux-cross/build-libunwind.sh \
139156
/build/
@@ -183,9 +200,12 @@ ENV AR_armv7_unknown_linux_gnueabihf=armv7-linux-gnueabihf-ar \
183200
AR_mipsel_unknown_linux_musl=mipsel-linux-musl-ar \
184201
CC_mipsel_unknown_linux_musl=mipsel-linux-musl-gcc \
185202
CXX_mipsel_unknown_linux_musl=mipsel-linux-musl-g++ \
203+
AR_powerpc_unknown_linux_gnu=powerpc-linux-gnu-ar \
204+
CC_powerpc_unknown_linux_gnu=powerpc-linux-gnu-gcc \
205+
CXX_powerpc_unknown_linux_gnu=powerpc-linux-gnu-g++ \
186206
AR_powerpc64_unknown_linux_gnu=powerpc64-linux-gnu-ar \
187-
CC_powerpc64_unknown_linux_gnu=powerpc64-linux-gnu-gcc-5 \
188-
CXX_powerpc64_unknown_linux_gnu=powerpc64-linux-gnu-g++-5 \
207+
CC_powerpc64_unknown_linux_gnu=powerpc64-linux-gnu-gcc \
208+
CXX_powerpc64_unknown_linux_gnu=powerpc64-linux-gnu-g++ \
189209
AR_powerpc64le_unknown_linux_gnu=powerpc64le-linux-gnu-ar \
190210
CC_powerpc64le_unknown_linux_gnu=powerpc64le-linux-gnu-gcc \
191211
CXX_powerpc64le_unknown_linux_gnu=powerpc64le-linux-gnu-g++ \

slaves/linux-cross/README.md

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,3 +223,58 @@ For targets: `mipsel-unknown-linux-musl`
223223
(+) These options have been selected to match the gcc flags we use to compile C
224224
libraries like jemalloc. See the mk/cfg/mips(el)-uknown-linux-musl.mk
225225
file in Rust's source code.
226+
227+
## `powerpc-linux-gnu.config`
228+
229+
For targets: `powerpc-unknown-linux-gnu`
230+
231+
- Path and misc options > Prefix directory = /x-tools/${CT\_TARGET}
232+
- Path and misc options > Patches origin = Bundled, then local
233+
- Path and misc options > Local patch directory = /build/patches
234+
- Target options > Target Architecture = powerpc
235+
- Target options > Emit assembly for CPU = power4 -- (+)
236+
- Target options > Tune for CPU = power6 -- (+)
237+
- Operating System > Target OS = linux
238+
- Operating System > Linux kernel version = 2.6.32.68 -- ~RHEL6 kernel
239+
- C-library > glibc version = 2.12.2 -- ~RHEL6 glibc
240+
- C compiler > gcc version = 4.9.3
241+
- C compiler > Core gcc extra config = --with-cpu-32=power4 --with-cpu=default32 -- (+)
242+
- C compiler > gcc extra config = --with-cpu-32=power4 --with-cpu=default32 -- (+)
243+
- C compiler > C++ = ENABLE -- to cross compile LLVM
244+
245+
(+) These CPU options match the configuration of the toolchains in RHEL6.
246+
247+
## `powerpc64-linux-gnu.config`
248+
249+
For targets: `powerpc64-unknown-linux-gnu`
250+
251+
- Path and misc options > Prefix directory = /x-tools/${CT\_TARGET}
252+
- Path and misc options > Patches origin = Bundled, then local
253+
- Path and misc options > Local patch directory = /build/patches
254+
- Target options > Target Architecture = powerpc
255+
- Target options > Bitness = 64-bit
256+
- Target options > Emit assembly for CPU = power4 -- (+)
257+
- Target options > Tune for CPU = power6 -- (+)
258+
- Operating System > Target OS = linux
259+
- Operating System > Linux kernel version = 2.6.32.68 -- ~RHEL6 kernel
260+
- C-library > glibc version = 2.12.2 -- ~RHEL6 glibc
261+
- C compiler > gcc version = 4.9.3
262+
- C compiler > C++ = ENABLE -- to cross compile LLVM
263+
264+
(+) These CPU options match the configuration of the toolchains in RHEL6.
265+
266+
## `s390x-linux-gnu.config`
267+
268+
For targets: `s390x-unknown-linux-gnu`
269+
270+
- Path and misc options > Prefix directory = /x-tools/${CT\_TARGET}
271+
- Path and misc options > Patches origin = Bundled, then local
272+
- Path and misc options > Local patch directory = /build/patches
273+
- Target options > Target Architecture = s390
274+
- Target options > Bitness = 64-bit
275+
- Operating System > Target OS = linux
276+
- Operating System > Linux kernel version = 2.6.32.68 -- ~RHEL6 kernel
277+
- C-library > glibc version = 2.12.2 -- ~RHEL6 glibc
278+
- C compiler > gcc version = 4.9.3
279+
- C compiler > gcc extra config = --with-arch=z10 -- LLVM's minimum support
280+
- C compiler > C++ = ENABLE -- to cross compile LLVM

slaves/linux-cross/build-libunwind.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ set -ex
55
# To build MUSL targets we're going to need a libunwind lying around, so acquire that
66
# here and build it.
77
if [ ! -d "llvm-3.8.0.src" ]; then
8-
curl http://llvm.org/releases/3.8.0/llvm-3.8.0.src.tar.xz | tar xJf -
8+
curl http://releases.llvm.org/3.8.0/llvm-3.8.0.src.tar.xz | tar xJf -
99
fi
1010

1111
if [ ! -d "libunwind-3.8.0.src" ]; then
12-
curl http://llvm.org/releases/3.8.0/libunwind-3.8.0.src.tar.xz | tar xJf -
12+
curl http://releases.llvm.org/3.8.0/libunwind-3.8.0.src.tar.xz | tar xJf -
1313
fi
1414

1515
rm -rf libunwind-build

slaves/linux-cross/build_netbsd_toolchain.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ cd gcc
6868
curl https://ftp.gnu.org/gnu/gcc/gcc-$GCC/gcc-$GCC.tar.bz2 | tar xjf -
6969
cd gcc-$GCC
7070
./contrib/download_prerequisites
71-
PATCHES="ftp://ftp.netbsd.org/pub/pkgsrc/pkgsrc-2016Q2/pkgsrc/lang/gcc5/patches/patch-libstdc%2B%2B-v3_config_os_bsd_netbsd_ctype__base.h \
72-
ftp://ftp.netbsd.org/pub/pkgsrc/pkgsrc-2016Q2/pkgsrc/lang/gcc5/patches/patch-libstdc%2B%2B-v3_config_os_bsd_netbsd_ctype__configure__char.cc"
71+
PATCHES="ftp://ftp.netbsd.org/pub/pkgsrc/pkgsrc-2016Q4/pkgsrc/lang/gcc5/patches/patch-libstdc%2B%2B-v3_config_os_bsd_netbsd_ctype__base.h \
72+
ftp://ftp.netbsd.org/pub/pkgsrc/pkgsrc-2016Q4/pkgsrc/lang/gcc5/patches/patch-libstdc%2B%2B-v3_config_os_bsd_netbsd_ctype__configure__char.cc"
7373

7474
for patch in $PATCHES; do
7575
curl $patch | patch -Np0
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
#!/bin/bash
2+
3+
set -ex
4+
5+
BINUTILS=2.25.1
6+
GCC=5.3.0
7+
TARGET=powerpc64le-linux-gnu
8+
SYSROOT=/usr/local/$TARGET/sysroot
9+
10+
# First, download the CentOS7 glibc.ppc64le and relevant header files.
11+
# (upstream ppc64le support wasn't added until 2.19, which el7 backported.)
12+
mkdir -p $SYSROOT
13+
pushd $SYSROOT
14+
15+
centos_base=http://mirror.centos.org/altarch/7.3.1611/os/ppc64le/Packages
16+
glibc_v=2.17-157.el7
17+
kernel_v=3.10.0-514.el7
18+
for package in glibc{,-devel,-headers}-$glibc_v kernel-headers-$kernel_v; do
19+
curl $centos_base/$package.ppc64le.rpm | \
20+
rpm2cpio - | cpio -idm
21+
done
22+
23+
ln -sT lib64 lib
24+
ln -sT lib64 usr/lib
25+
26+
popd
27+
28+
# Next, download and build binutils.
29+
mkdir binutils-$TARGET
30+
pushd binutils-$TARGET
31+
curl https://ftp.gnu.org/gnu/binutils/binutils-$BINUTILS.tar.bz2 | tar xjf -
32+
mkdir binutils-build
33+
cd binutils-build
34+
../binutils-$BINUTILS/configure --target=$TARGET --with-sysroot=$SYSROOT
35+
make -j10
36+
make install
37+
popd
38+
rm -rf binutils-$TARGET
39+
40+
# Finally, download and build gcc.
41+
mkdir gcc-$TARGET
42+
pushd gcc-$TARGET
43+
curl https://ftp.gnu.org/gnu/gcc/gcc-$GCC/gcc-$GCC.tar.bz2 | tar xjf -
44+
cd gcc-$GCC
45+
./contrib/download_prerequisites
46+
47+
mkdir ../gcc-build
48+
cd ../gcc-build
49+
../gcc-$GCC/configure \
50+
--enable-languages=c,c++ \
51+
--target=$TARGET \
52+
--with-cpu=power8 \
53+
--with-sysroot=$SYSROOT \
54+
--disable-libcilkrts \
55+
--disable-multilib \
56+
--disable-nls \
57+
--disable-libgomp \
58+
--disable-libquadmath \
59+
--disable-libssp \
60+
--disable-libvtv \
61+
--disable-libcilkrt \
62+
--disable-libada \
63+
--disable-libsanitizer \
64+
--disable-libquadmath-support \
65+
--disable-lto
66+
make -j10
67+
make install
68+
69+
popd
70+
rm -rf gcc-$TARGET
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
From b3563932f85d60bb0d38b0a5f3b8f4abc133f890 Mon Sep 17 00:00:00 2001
2+
From: Tulio Magno Quites Machado Filho <[email protected]>
3+
Date: Thu, 1 Nov 2012 18:00:06 -0500
4+
Subject: [PATCH] PowerPC: Remove unnecessary -mnew-mnemonics.
5+
6+
---
7+
sysdeps/powerpc/Makefile | 4 ----
8+
1 file changed, 4 deletions(-)
9+
10+
diff --git a/sysdeps/powerpc/Makefile b/sysdeps/powerpc/Makefile
11+
index 79dd6fa976d5..7442b6709ad1 100644
12+
--- a/sysdeps/powerpc/Makefile
13+
+++ b/sysdeps/powerpc/Makefile
14+
@@ -1,7 +1,3 @@
15+
-# We always want to use the new mnemonic syntax even if we are on a RS6000
16+
-# machine.
17+
-+cflags += -mnew-mnemonics
18+
-
19+
ifeq ($(subdir),gmon)
20+
sysdep_routines += ppc-mcount
21+
endif
22+
--
23+
2.9.3
24+
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
From a4f388e111ce05e2ab7912cff3c9070334bb74ae Mon Sep 17 00:00:00 2001
2+
From: Josh Stone <[email protected]>
3+
Date: Fri, 20 Jan 2017 15:41:56 -0800
4+
Subject: [PATCH] Prevent inlining in PPC64 initfini.s
5+
6+
Ref: https://sourceware.org/ml/libc-alpha/2012-01/msg00195.html
7+
---
8+
sysdeps/powerpc/powerpc64/Makefile | 2 +-
9+
1 file changed, 1 insertion(+), 1 deletion(-)
10+
11+
diff --git a/sysdeps/powerpc/powerpc64/Makefile b/sysdeps/powerpc/powerpc64/Makefile
12+
index 78d4f07e575f..fe96aae4d43e 100644
13+
--- a/sysdeps/powerpc/powerpc64/Makefile
14+
+++ b/sysdeps/powerpc/powerpc64/Makefile
15+
@@ -28,7 +28,7 @@ elide-routines.os += hp-timing
16+
ifneq ($(elf),no)
17+
# The initfini generation code doesn't work in the presence of -fPIC, so
18+
# we use -fpic instead which is much better.
19+
-CFLAGS-initfini.s += -fpic -O1
20+
+CFLAGS-initfini.s += -fpic -O1 -fno-inline
21+
endif
22+
endif
23+
24+
--
25+
2.9.3
26+
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
From 2739047682590b1df473401b4febf424f857fccf Mon Sep 17 00:00:00 2001
2+
From: Andreas Krebbel <[email protected]>
3+
Date: Sun, 17 Apr 2011 20:43:59 -0400
4+
Subject: [PATCH] Use .machine to prevent AS from complaining about z9-109
5+
instructions in iconv modules
6+
7+
---
8+
sysdeps/s390/s390-64/utf16-utf32-z9.c | 5 ++++-
9+
sysdeps/s390/s390-64/utf8-utf16-z9.c | 5 ++++-
10+
sysdeps/s390/s390-64/utf8-utf32-z9.c | 5 ++++-
11+
3 files changed, 12 insertions(+), 3 deletions(-)
12+
13+
diff --git a/sysdeps/s390/s390-64/utf16-utf32-z9.c b/sysdeps/s390/s390-64/utf16-utf32-z9.c
14+
index 14daf2118fe5..5bcaaaedec9c 100644
15+
--- a/sysdeps/s390/s390-64/utf16-utf32-z9.c
16+
+++ b/sysdeps/s390/s390-64/utf16-utf32-z9.c
17+
@@ -169,7 +169,10 @@ gconv_end (struct __gconv_step *data)
18+
register unsigned long long outlen asm("11") = outend - outptr; \
19+
uint64_t cc = 0; \
20+
\
21+
- asm volatile ("0: " INSTRUCTION " \n\t" \
22+
+ asm volatile (".machine push \n\t" \
23+
+ ".machine \"z9-109\" \n\t" \
24+
+ "0: " INSTRUCTION " \n\t" \
25+
+ ".machine pop \n\t" \
26+
" jo 0b \n\t" \
27+
" ipm %2 \n" \
28+
: "+a" (pOutput), "+a" (pInput), "+d" (cc), \
29+
diff --git a/sysdeps/s390/s390-64/utf8-utf16-z9.c b/sysdeps/s390/s390-64/utf8-utf16-z9.c
30+
index 5f73f3c59e21..812a42fae44c 100644
31+
--- a/sysdeps/s390/s390-64/utf8-utf16-z9.c
32+
+++ b/sysdeps/s390/s390-64/utf8-utf16-z9.c
33+
@@ -151,7 +151,10 @@ gconv_end (struct __gconv_step *data)
34+
register unsigned long long outlen asm("11") = outend - outptr; \
35+
uint64_t cc = 0; \
36+
\
37+
- asm volatile ("0: " INSTRUCTION " \n\t" \
38+
+ asm volatile (".machine push \n\t" \
39+
+ ".machine \"z9-109\" \n\t" \
40+
+ "0: " INSTRUCTION " \n\t" \
41+
+ ".machine pop \n\t" \
42+
" jo 0b \n\t" \
43+
" ipm %2 \n" \
44+
: "+a" (pOutput), "+a" (pInput), "+d" (cc), \
45+
diff --git a/sysdeps/s390/s390-64/utf8-utf32-z9.c b/sysdeps/s390/s390-64/utf8-utf32-z9.c
46+
index 17ef8bc890c3..0ffd848c8124 100644
47+
--- a/sysdeps/s390/s390-64/utf8-utf32-z9.c
48+
+++ b/sysdeps/s390/s390-64/utf8-utf32-z9.c
49+
@@ -155,7 +155,10 @@ gconv_end (struct __gconv_step *data)
50+
register unsigned long long outlen asm("11") = outend - outptr; \
51+
uint64_t cc = 0; \
52+
\
53+
- asm volatile ("0: " INSTRUCTION " \n\t" \
54+
+ asm volatile (".machine push \n\t" \
55+
+ ".machine \"z9-109\" \n\t" \
56+
+ "0: " INSTRUCTION " \n\t" \
57+
+ ".machine pop \n\t" \
58+
" jo 0b \n\t" \
59+
" ipm %2 \n" \
60+
: "+a" (pOutput), "+a" (pInput), "+d" (cc), \
61+
--
62+
2.9.3
63+

0 commit comments

Comments
 (0)