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

Commit 1237574

Browse files
committed
Push powerpc* and s390x back even further.
For crosstool-ng with powerpc, powerpc64, and s390x, a few small patches are now applied to glibc-2.12 to get it to compile with newer GCC. This should now be compatible with RHEL6, Debian 7 (wheezy), and Ubuntu 12.04 (precise). For powerpc64le, the challenge was that only glibc-2.19 officially added support, but el7 backported those changes to glibc-2.17. The backport patches are complex and numerous, so instead of trying to push those into crosstool-ng, just use glibc binaries directly from centos7 and build the toolchain manually.
1 parent b57086c commit 1237574

10 files changed

+278
-603
lines changed

slaves/linux-cross/Dockerfile

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ RUN apt-get install -y --force-yes --no-install-recommends \
99
g++ libc6-dev \
1010
bsdtar \
1111
cmake \
12+
rpm2cpio cpio \
1213
g++-5-mips-linux-gnu libc6-dev-mips-cross \
1314
g++-5-mipsel-linux-gnu libc6-dev-mipsel-cross \
1415
pkg-config
@@ -58,9 +59,9 @@ COPY linux-cross/build_toolchain.sh \
5859
linux-cross/armv7-linux-musleabihf.config \
5960
linux-cross/powerpc-linux-gnu.config \
6061
linux-cross/powerpc64-linux-gnu.config \
61-
linux-cross/powerpc64le-linux-gnu.config \
6262
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,10 @@ 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

111-
# Also build toolchains for {powerpc{,64{,le}},s390x}-unknown-linux-gnu,
112+
# Also build toolchains for {powerpc{,64},s390x}-unknown-linux-gnu,
112113
# primarily to support older glibc than found in the Ubuntu root.
113114
RUN /bin/bash build_toolchain.sh powerpc-linux-gnu
114115
RUN /bin/bash build_toolchain.sh powerpc64-linux-gnu
115-
RUN /bin/bash build_toolchain.sh powerpc64le-linux-gnu
116116
RUN /bin/bash build_toolchain.sh s390x-linux-gnu
117117

118118
USER root
@@ -146,6 +146,11 @@ RUN bash /tmp/build_dragonfly_toolchain.sh
146146
COPY linux-cross/build_netbsd_toolchain.sh /tmp/
147147
RUN bash /tmp/build_netbsd_toolchain.sh
148148

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+
149154
# Also build libunwind.a for the ARM musl targets
150155
COPY linux-cross/build-libunwind.sh \
151156
/build/

slaves/linux-cross/README.md

Lines changed: 15 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -229,50 +229,41 @@ For targets: `mipsel-unknown-linux-musl`
229229
For targets: `powerpc-unknown-linux-gnu`
230230

231231
- 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
232234
- Target options > Target Architecture = powerpc
233235
- Operating System > Target OS = linux
234-
- Operating System > Linux kernel version = 3.10.93 -- ~RHEL7 kernel
235-
- C-library > glibc version = 2.17 -- ~RHEL7 glibc
236-
- C compiler > gcc version = 5.2
236+
- Operating System > Linux kernel version = 2.6.32.68 -- ~RHEL6 kernel
237+
- C-library > glibc version = 2.12.2 -- ~RHEL6 glibc
238+
- C compiler > gcc version = 4.9.3
237239
- C compiler > C++ = ENABLE -- to cross compile LLVM
238240

239241
## `powerpc64-linux-gnu.config`
240242

241243
For targets: `powerpc64-unknown-linux-gnu`
242244

243245
- Path and misc options > Prefix directory = /x-tools/${CT\_TARGET}
246+
- Path and misc options > Patches origin = Bundled, then local
247+
- Path and misc options > Local patch directory = /build/patches
244248
- Target options > Target Architecture = powerpc
245249
- Target options > Bitness = 64-bit
246250
- Operating System > Target OS = linux
247-
- Operating System > Linux kernel version = 3.10.93 -- ~RHEL7 kernel
248-
- C-library > glibc version = 2.17 -- ~RHEL7 glibc
249-
- C compiler > gcc version = 5.2
250-
- C compiler > C++ = ENABLE -- to cross compile LLVM
251-
252-
## `powerpc64le-linux-gnu.config`
253-
254-
For targets: `powerpc64le-unknown-linux-gnu`
255-
256-
- Path and misc options > Prefix directory = /x-tools/${CT\_TARGET}
257-
- Target options > Target Architecture = powerpc
258-
- Target options > Endianness = **Little** endian
259-
- Target options > Bitness = 64-bit
260-
- Target options > Emit assembly for CPU = power8
261-
- Operating System > Target OS = linux
262-
- Operating System > Linux kernel version = 3.14.57 -- ppc64le support was introduced in 3.13
263-
- C-library > glibc version = 2.19 -- ppc64le support was introduced in this version
264-
- C compiler > gcc version = 5.2.0
251+
- Operating System > Linux kernel version = 2.6.32.68 -- ~RHEL6 kernel
252+
- C-library > glibc version = 2.12.2 -- ~RHEL6 glibc
253+
- C compiler > gcc version = 4.9.3
265254
- C compiler > C++ = ENABLE -- to cross compile LLVM
266255

267256
## `s390x-linux-gnu.config`
268257

269258
For targets: `s390x-unknown-linux-gnu`
270259

271260
- Path and misc options > Prefix directory = /x-tools/${CT\_TARGET}
261+
- Path and misc options > Patches origin = Bundled, then local
262+
- Path and misc options > Local patch directory = /build/patches
272263
- Target options > Target Architecture = s390
273264
- Target options > Bitness = 64-bit
274265
- Operating System > Target OS = linux
275-
- Operating System > Linux kernel version = 3.10.93 -- ~RHEL7 kernel
276-
- C-library > glibc version = 2.17 -- ~RHEL7 glibc
277-
- C compiler > gcc version = 5.2
266+
- Operating System > Linux kernel version = 2.6.32.68 -- ~RHEL6 kernel
267+
- C-library > glibc version = 2.12.2 -- ~RHEL6 glibc
268+
- C compiler > gcc version = 4.9.3
278269
- C compiler > C++ = ENABLE -- to cross compile LLVM
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
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-sysroot=$SYSROOT \
53+
--disable-libcilkrts \
54+
--disable-multilib \
55+
--disable-nls \
56+
--disable-libgomp \
57+
--disable-libquadmath \
58+
--disable-libssp \
59+
--disable-libvtv \
60+
--disable-libcilkrt \
61+
--disable-libada \
62+
--disable-libsanitizer \
63+
--disable-libquadmath-support \
64+
--disable-lto
65+
make -j10
66+
make install
67+
68+
popd
69+
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 <tuliom@linux.vnet.ibm.com>
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 <jistone@redhat.com>
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 <Andreas.Krebbel@de.ibm.com>
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)