]> git.lizzy.rs Git - rust.git/blob - src/ci/docker/README.md
Add 'compiler/rustc_smir/' from commit '9abcb5c7b574cf316eb23d3f469187bb86ba3019'
[rust.git] / src / ci / docker / README.md
1 # Docker images for CI
2
3 This folder contains a bunch of docker images used by the continuous integration
4 (CI) of Rust. An script is accompanied (`run.sh`) with these images to actually
5 execute them. To test out an image execute:
6
7 ```
8 ./src/ci/docker/run.sh $image_name
9 ```
10
11 for example:
12
13 ```
14 ./src/ci/docker/run.sh x86_64-gnu
15 ```
16
17 Images will output artifacts in an `obj` dir at the root of a repository.
18
19 To match conditions in rusts CI, also set the environment variable `DEPLOY=1`, e.g.:
20 ```
21 DEPLOY=1 ./src/ci/docker/run.sh x86_64-gnu
22 ```
23
24 **NOTE**: Re-using the same `obj` dir with different docker images with
25 the same target triple (e.g. `dist-x86_64-linux` and `dist-various-1`)
26 may result in strange linker errors, due shared library versions differing between platforms.
27
28 If you encounter any issues when using multiple Docker images, try deleting your `obj` directory
29 before running your command.
30
31 ## Filesystem layout
32
33 - Each host architecture has its own `host-{arch}` directory, and those
34   directories contain a subdirectory for each Docker image (plus the `disabled`
35   subdirectory).
36 - `host-{arch}/disabled` contains images that are not built on CI.
37 - `scripts` contains files shared by multiple Docker images.
38
39 ## Docker Toolbox on Windows
40
41 For Windows before Windows 10, the docker images can be run on Windows via
42 [Docker Toolbox]. There are several preparation needs to be made before running
43 a Docker image.
44
45 1. Stop the virtual machine from the terminal with `docker-machine stop`
46
47 2. If your Rust source is placed outside of `C:\Users\**`, e.g. if you place the
48     repository in the `E:\rust` folder, please add a shared folder from
49     VirtualBox by:
50
51     1. Select the "default" virtual machine inside VirtualBox, then click
52         "Settings"
53     2. Go to "Shared Folders", click "Add shared folder" (the folder icon with
54         a plus sign), fill in the following information, then click "OK":
55
56         * Folder path: `E:\rust`
57         * Folder name: `e/rust`
58         * Read-only: ☐ *unchecked*
59         * Auto-mount: ☑ *checked*
60         * Make Permanent: ☑ *checked*
61
62 3. VirtualBox might not support creating symbolic links inside a shared folder
63     by default. You can enable it manually by running these from `cmd.exe`:
64
65     ```bat
66     cd "C:\Program Files\Oracle\VirtualBox"
67     VBoxManage setextradata default VBoxInternal2/SharedFoldersEnableSymlinksCreate/e/rust 1
68     ::                                                                              ^~~~~~
69     ::                                                                              folder name
70     ```
71
72 4. Restart the virtual machine from terminal with `docker-machine start`.
73
74 To run the image,
75
76 1. Launch the "Docker Quickstart Terminal".
77 2. Execute `./src/ci/docker/run.sh $image_name` as explained at the beginning.
78
79 [Docker Toolbox]: https://www.docker.com/products/docker-toolbox
80
81 ## Cross toolchains
82
83 A number of these images take quite a long time to compile as they're building
84 whole gcc toolchains to do cross builds with. Much of this is relatively
85 self-explanatory but some images use [crosstool-ng] which isn't quite as self
86 explanatory. Below is a description of where these `*.config` files come form,
87 how to generate them, and how the existing ones were generated.
88
89 [crosstool-ng]: https://github.com/crosstool-ng/crosstool-ng
90
91 ### Generating a `.config` file
92
93 **NOTE:** Existing Dockerfiles can also be a good guide for the process and order
94 of script execution.
95
96 If you have a `linux-cross` image lying around you can use that and skip the
97 next two steps.
98
99 - First we spin up a container and copy all scripts into it. All
100   these steps are outside the container:
101
102 ```
103 # Note: We use ubuntu:16.04 because that's the "base" of linux-cross Docker
104 # image, or simply run ./src/ci/docker/run.sh once, which will download the correct
105 # one and you can check it out with `docker images`
106 $ docker run -it ubuntu:16.04 bash
107 # in another terminal:
108 $ docker ps
109 CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
110 cfbec05ed730        ubuntu:16.04        "bash"              16 seconds ago      Up 15 seconds                           drunk_murdock
111 $ docker cp src/ci/docker/scripts drunk_murdock:/tmp/
112 ```
113
114 - Then inside the container we build crosstool-ng by simply calling the bash
115   script we copied in the previous step:
116
117 ```
118 $ cd /tmp/scripts
119 # Download packages necessary for building
120 $ bash ./cross-apt-packages.sh
121 # Download and build crosstool-ng
122 $ bash ./crosstool-ng.sh
123 ```
124
125 - In case you want to adjust or start from an existing config, copy that
126   to the container. `crosstool-ng` will automatically load `./.config` if
127   present. Otherwise one can use the TUI to load any config-file.
128
129 ```
130 $ docker cp arm-linux-gnueabi.config drunk_murdock:/tmp/.config
131 ```
132
133 - Now, inside the container run the following command to configure the
134   toolchain. To get a clue of which options need to be changed check the next
135   section and come back.
136
137 ```
138 $ cd /tmp/
139 $ ct-ng menuconfig
140 ```
141
142 - Finally, we retrieve the `.config` file from the container and give it a
143   meaningful name. This is done outside the container.
144
145 ```
146 $ docker cp drunk_murdock:/tmp/.config arm-linux-gnueabi.config
147 ```
148
149 - Now you can shutdown the container or repeat the two last steps to generate a
150   new `.config` file.
151
152 ### Toolchain configuration
153
154 Changes on top of the default toolchain configuration used to generate the
155 `.config` files in this directory. The changes are formatted as follows:
156
157 ```
158 $category > $option = $value -- $comment
159 ```
160
161 ### `arm-linux-gnueabi.config`
162
163 For targets: `arm-unknown-linux-gnueabi`
164
165 - Path and misc options > Prefix directory = /x-tools/${CT\_TARGET}
166 - Path and misc options > Patches origin = Bundled only
167 - Target options > Target Architecture = arm
168 - Target options > Architecture level = armv6 -- (+)
169 - Target options > Floating point = software (no FPU) -- (\*)
170 - Operating System > Target OS = linux
171 - Operating System > Linux kernel version = 3.2.101
172 - C-library > glibc version = 2.17.0
173 - C compiler > gcc version = 8.3.0
174 - C compiler > C++ = ENABLE -- to cross compile LLVM
175
176 ### `arm-linux-gnueabihf.config`
177
178 For targets: `arm-unknown-linux-gnueabihf`
179
180 - Path and misc options > Prefix directory = /x-tools/${CT\_TARGET}
181 - Path and misc options > Patches origin = Bundled only
182 - Target options > Target Architecture = arm
183 - Target options > Architecture level = armv6 -- (+)
184 - Target options > Use specific FPU = vfp -- (+)
185 - Target options > Floating point = hardware (FPU) -- (\*)
186 - Target options > Default instruction set mode = arm -- (+)
187 - Operating System > Target OS = linux
188 - Operating System > Linux kernel version = 3.2.101
189 - C-library > glibc version = 2.17.0
190 - C compiler > gcc version = 8.3.0
191 - C compiler > C++ = ENABLE -- to cross compile LLVM
192
193 ### `armv7-linux-gnueabihf.config`
194
195 For targets: `armv7-unknown-linux-gnueabihf`
196
197 - Path and misc options > Prefix directory = /x-tools/${CT\_TARGET}
198 - Path and misc options > Patches origin = Bundled only
199 - Target options > Target Architecture = arm
200 - Target options > Suffix to the arch-part = v7
201 - Target options > Architecture level = armv7-a -- (+)
202 - Target options > Use specific FPU = vfpv3-d16 -- (\*)
203 - Target options > Floating point = hardware (FPU) -- (\*)
204 - Target options > Default instruction set mode = thumb -- (\*)
205 - Operating System > Target OS = linux
206 - Operating System > Linux kernel version = 3.2.101
207 - C-library > glibc version = 2.17.0
208 - C compiler > gcc version = 8.3.0
209 - C compiler > C++ = ENABLE -- to cross compile LLVM
210
211 (\*) These options have been selected to match the configuration of the arm
212       toolchains shipped with Ubuntu 15.10
213 (+) These options have been selected to match the gcc flags we use to compile C
214     libraries like jemalloc. See the mk/cfg/arm(v7)-uknown-linux-gnueabi{,hf}.mk
215     file in Rust's source code.
216
217 ### `aarch64-linux-gnu.config`
218
219 For targets: `aarch64-unknown-linux-gnu`
220
221 - Path and misc options > Prefix directory = /x-tools/${CT\_TARGET}
222 - Target options > Target Architecture = arm
223 - Target options > Bitness = 64-bit
224 - Operating System > Target OS = linux
225 - Operating System > Linux kernel version = 4.2.6
226 - C-library > glibc version = 2.17 -- aarch64 support was introduced in this version
227 - C compiler > gcc version = 5.2.0
228 - C compiler > C++ = ENABLE -- to cross compile LLVM
229
230 ### `powerpc-linux-gnu.config`
231
232 For targets: `powerpc-unknown-linux-gnu`
233
234 - Path and misc options > Prefix directory = /x-tools/${CT\_TARGET}
235 - Path and misc options > Patches origin = Bundled, then local
236 - Path and misc options > Local patch directory = /tmp/patches
237 - Target options > Target Architecture = powerpc
238 - Target options > Emit assembly for CPU = powerpc -- pure 32-bit PowerPC
239 - Operating System > Target OS = linux
240 - Operating System > Linux kernel version = 2.6.32.68 -- ~RHEL6 kernel
241 - C-library > glibc version = 2.11.1 -- ~SLE11-SP4 glibc
242 - C compiler > gcc version = 5.2.0
243 - C compiler > C++ = ENABLE -- to cross compile LLVM
244
245 ### `powerpc64-linux-gnu.config`
246
247 For targets: `powerpc64-unknown-linux-gnu`
248
249 - Path and misc options > Prefix directory = /x-tools/${CT\_TARGET}
250 - Path and misc options > Patches origin = Bundled, then local
251 - Path and misc options > Local patch directory = /tmp/patches
252 - Target options > Target Architecture = powerpc
253 - Target options > Bitness = 64-bit
254 - Target options > Emit assembly for CPU = power4 -- (+)
255 - Target options > Tune for CPU = power6 -- (+)
256 - Operating System > Target OS = linux
257 - Operating System > Linux kernel version = 2.6.32.68 -- ~RHEL6 kernel
258 - C-library > glibc version = 2.11.1 -- ~SLE11-SP4 glibc
259 - C compiler > gcc version = 5.2.0
260 - C compiler > C++ = ENABLE -- to cross compile LLVM
261
262 (+) These CPU options match the configuration of the toolchains in RHEL6.
263
264 ### `s390x-linux-gnu.config`
265
266 For targets: `s390x-unknown-linux-gnu`
267
268 - Path and misc options > Prefix directory = /x-tools/${CT\_TARGET}
269 - Path and misc options > Patches origin = Bundled, then local
270 - Path and misc options > Local patch directory = /tmp/patches
271 - Target options > Target Architecture = s390
272 - Target options > Bitness = 64-bit
273 - Operating System > Target OS = linux
274 - Operating System > Linux kernel version = 2.6.32.71 -- ~RHEL6 kernel
275 - C-library > glibc version = 2.12.1 -- ~RHEL6 glibc
276 - C compiler > gcc version = 8.3.0
277 - C compiler > gcc extra config = --with-arch=z10 -- LLVM's minimum support
278 - C compiler > C++ = ENABLE -- to cross compile LLVM