]> git.lizzy.rs Git - rust.git/blob - src/ci/scripts/install-mingw.sh
Test drop_tracking_mir before querying generator.
[rust.git] / src / ci / scripts / install-mingw.sh
1 #!/bin/bash
2 # If we need to download a custom MinGW, do so here and set the path
3 # appropriately.
4 #
5 # Here we also do a pretty heinous thing which is to mangle the MinGW
6 # installation we just downloaded. Currently, as of this writing, we're using
7 # MinGW-w64 builds of gcc, and that's currently at 6.3.0. We use 6.3.0 as it
8 # appears to be the first version which contains a fix for #40546, builds
9 # randomly failing during LLVM due to ar.exe/ranlib.exe failures.
10 #
11 # Unfortunately, though, 6.3.0 *also* is the first version of MinGW-w64 builds
12 # to contain a regression in gdb (#40184). As a result if we were to use the
13 # gdb provided (7.11.1) then we would fail all debuginfo tests.
14 #
15 # In order to fix spurious failures (pretty high priority) we use 6.3.0. To
16 # avoid disabling gdb tests we download an *old* version of gdb, specifically
17 # that found inside the 6.2.0 distribution. We then overwrite the 6.3.0 gdb
18 # with the 6.2.0 gdb to get tests passing.
19 #
20 # Note that we don't literally overwrite the gdb.exe binary because it appears
21 # to just use gdborig.exe, so that's the binary we deal with instead.
22 #
23 # Otherwise install MinGW through `pacman`
24
25 set -euo pipefail
26 IFS=$'\n\t'
27
28 source "$(cd "$(dirname "$0")" && pwd)/../shared.sh"
29
30 MINGW_ARCHIVE_32="i686-6.3.0-release-posix-dwarf-rt_v5-rev2.7z"
31 MINGW_ARCHIVE_64="x86_64-6.3.0-release-posix-seh-rt_v5-rev2.7z"
32
33 if isWindows; then
34     case "${CI_JOB_NAME}" in
35         *i686*)
36             bits=32
37             arch=i686
38             mingw_archive="${MINGW_ARCHIVE_32}"
39             ;;
40         *x86_64*)
41             bits=64
42             arch=x86_64
43             mingw_archive="${MINGW_ARCHIVE_64}"
44             ;;
45         *aarch64*)
46             # aarch64 is a cross-compiled target. Use the x86_64
47             # mingw, since that's the host architecture.
48             bits=64
49             arch=x86_64
50             mingw_archive="${MINGW_ARCHIVE_64}"
51             ;;
52         *)
53             echo "src/ci/scripts/install-mingw.sh can't detect the builder's architecture"
54             echo "please tweak it to recognize the builder named '${CI_JOB_NAME}'"
55             exit 1
56             ;;
57     esac
58
59     if [[ "${CUSTOM_MINGW-0}" -ne 1 ]]; then
60         pacman -S --noconfirm --needed mingw-w64-$arch-toolchain mingw-w64-$arch-cmake \
61             mingw-w64-$arch-gcc \
62             mingw-w64-$arch-python # the python package is actually for python3
63         ciCommandAddPath "$(ciCheckoutPath)/msys2/mingw${bits}/bin"
64     else
65         mingw_dir="mingw${bits}"
66
67         curl -o mingw.7z "${MIRRORS_BASE}/${mingw_archive}"
68         7z x -y mingw.7z > /dev/null
69         curl -o "${mingw_dir}/bin/gdborig.exe" "${MIRRORS_BASE}/2017-04-20-${bits}bit-gdborig.exe"
70         ciCommandAddPath "$(pwd)/${mingw_dir}/bin"
71     fi
72 fi