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

Commit 706074e

Browse files
committed
Merge pull request #69 from japaric/arm
linux-cross: use glibc-2.14/gcc-4.8 for the arm toolchain
2 parents 693268d + c12d174 commit 706074e

File tree

6 files changed

+1323
-2
lines changed

6 files changed

+1323
-2
lines changed

slaves/linux-cross/Dockerfile

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ RUN apt-get install -y --force-yes --no-install-recommends \
55
curl make git wget file \
66
python-dev python-pip stunnel \
77
g++ gcc libc6-dev \
8-
gcc-4.7-arm-linux-gnueabi libc6-dev-armel-cross \
9-
gcc-4.7-arm-linux-gnueabihf libc6-dev-armhf-cross \
108
gcc-4.8-aarch64-linux-gnu libc6-dev-arm64-cross \
119
gcc-4.8-powerpc-linux-gnu libc6-dev-powerpc-cross \
1210
gcc-4.8-powerpc64le-linux-gnu libc6-dev-ppc64el-cross \
@@ -38,6 +36,36 @@ RUN pip install buildbot-slave
3836
RUN groupadd -r rustbuild && useradd -r -g rustbuild rustbuild
3937
RUN mkdir /buildslave && chown rustbuild:rustbuild /buildslave
4038

39+
# Install arm cross compiler
40+
# NOTE crosstool-ng can't be executed by root so we execute it under the rustbuild user. /x-tools
41+
# is the crosstool-ng output directory and /build is the crosstool-ng build directory so both must
42+
# be writable by rustbuild
43+
WORKDIR /build
44+
COPY linux-cross/build_toolchain_root.sh /build/
45+
RUN /bin/bash build_toolchain_root.sh && \
46+
mkdir /x-tools && \
47+
chown rustbuild:rustbuild /build && \
48+
chown rustbuild:rustbuild /x-tools
49+
COPY linux-cross/build_toolchain.sh \
50+
linux-cross/arm-linux-gnueabi.config \
51+
linux-cross/arm-linux-gnueabihf.config \
52+
/build/
53+
USER rustbuild
54+
RUN /bin/bash build_toolchain.sh arm-linux-gnueabi && \
55+
/bin/bash build_toolchain.sh arm-linux-gnueabihf
56+
USER root
57+
RUN rm -rf /build
58+
59+
RUN \
60+
for f in `ls /x-tools/arm-unknown-linux-gnueabi/bin/arm-unknown-linux-gnueabi-*`; do \
61+
g=`basename $f`; \
62+
ln -vs $f /usr/bin/`echo $g | sed -e 's/-unknown//'`; \
63+
done && \
64+
for f in `ls /x-tools/arm-unknown-linux-gnueabihf/bin/arm-unknown-linux-gnueabihf-*`; do \
65+
g=`basename $f`; \
66+
ln -vs $f /usr/bin/`echo $g | sed -e 's/-unknown//'`; \
67+
done
68+
4169
# When running this container, startup buildbot
4270
WORKDIR /buildslave
4371
USER rustbuild

slaves/linux-cross/README.md

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
# `linux-cross`
2+
3+
This image is used to cross compile libstd/rustc to targets that run linux but are not the
4+
`x86_64-unknown-linux-gnu` triple which is the "host" triple.
5+
6+
To cross compile libstd/rustc we need a C cross toolchain: a cross gcc and a cross compiled libc.
7+
For some targets, we use crosstool-ng to build these toolchains ourselves instead of using the ones
8+
packaged for Ubuntu because:
9+
10+
- We can control the glibc version of the toolchain. In particular, we can lower its version as much
11+
as possible, this lets us generate libstd/rustc binaries that run in systems with old glibcs.
12+
- We can create toolchains for targets that don't have an equivalent package available in Ubuntu.
13+
14+
crosstool-ng uses a `.config` file, generated via a menuconfig interface, to specify the target,
15+
glibc version, etc. of the toolchain to build. Because this menuconfig interface requires user
16+
intervention we store pre-generated `.config` files in this repository to keep the `docker build`
17+
command free of user intervention.
18+
19+
The next section explains how to generate a `.config` file for a new target, and the one after that
20+
contains the changes, on top of the default toolchain configuration, used to generate the `.config`
21+
files stored in this repository.
22+
23+
## Generating a `.config` file
24+
25+
If you have a `linux-cross` image lying around you can use that and skip the next two steps.
26+
27+
- First we spin up a container and copy `build_toolchain_root.sh` into it. All these steps are
28+
outside the container:
29+
30+
```
31+
# Note: We use ubuntu:15.10 because that's the "base" of linux-cross Docker image
32+
$ docker run -it ubuntu:15.10 bash
33+
$ docker ps
34+
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
35+
cfbec05ed730 ubuntu:15.10 "bash" 16 seconds ago Up 15 seconds drunk_murdock
36+
$ docker cp build_toolchain_root.sh drunk_murdock:/
37+
```
38+
39+
- Then inside the container we build crosstool-ng by simply calling the bash script we copied in the
40+
previous step:
41+
42+
```
43+
$ bash build_toolchain_root.sh
44+
```
45+
46+
- Now, inside the container run the following command to configure the toolchain. To get a clue of
47+
which options need to be changed check the next section and come back.
48+
49+
```
50+
$ ct-ng menuconfig
51+
```
52+
53+
- Finally, we retrieve the `.config` file from the container and give it a meaningful name. This is
54+
done outside the container.
55+
56+
```
57+
$ docker drunk_murdock:/.config arm-linux-gnueabi.config
58+
```
59+
60+
- Now you can shutdown the container or repeat the two last steps to generate a new `.config` file.
61+
62+
## Toolchain configuration
63+
64+
Changes on top of the default toolchain configuration used to generate the `.config` files in this
65+
directory. The changes are formatted as follows:
66+
67+
```
68+
$category > $option = $value -- $comment
69+
```
70+
71+
## `arm-linux-gnueabi.config`
72+
73+
For targets: `arm-unknown-linux-gnueabi`
74+
75+
- Path and misc options > Prefix directory = /x-tools/${CT_TARGET}
76+
- Target options > Target Architecture = arm
77+
- Target options > Architecture level = armv6 -- (+)
78+
- Target options > Floating point = software (no FPU) -- (*)
79+
- Operating System > Target OS = linux
80+
- Operating System > Linux kernel version = 3.2.72 -- Precise kernel
81+
- C-library > glibc version = 2.14.1
82+
- C compiler > gcc version = 4.9.3
83+
- C compiler > C++ = ENABLE -- to cross compile LLVM
84+
85+
## `arm-linux-gnueabihf.config`
86+
87+
For targets: `arm-unknown-linux-gnueabihf`, `armv7-unknown-linux-gnueabihf`
88+
89+
- Path and misc options > Prefix directory = /x-tools/${CT_TARGET}
90+
- Target options > Target Architecture = arm
91+
- Target options > Architecture level = armv6 -- (+)
92+
- Target options > Use specific FPU = vfpv3-d16 -- (*)
93+
- Target options > Floating point = hardware (FPU) -- (*)
94+
- Target options > Default instruction set mode (thumb) -- (*)
95+
- Operating System > Target OS = linux
96+
- Operating System > Linux kernel version = 3.2.72 -- Precise kernel
97+
- C-library > glibc version = 2.14.1
98+
- C compiler > gcc version = 4.9.3
99+
- C compiler > C++ = ENABLE -- to cross compile LLVM
100+
101+
(*) These options have been selected to match the configuration of the arm toolchains shipped with
102+
Ubuntu 15.10
103+
(+) These options have been selected to match the gcc flags we use to compile C libraries like
104+
jemalloc. See the mk/cfg/arm-uknown-linux-gnueabi{,hf}.mk file in Rust's source code.

0 commit comments

Comments
 (0)