Skip to content

Commit 80459c1

Browse files
committed
Changes to CI related to mingw and MSYS
1 parent e3450ad commit 80459c1

File tree

7 files changed

+96
-15
lines changed

7 files changed

+96
-15
lines changed

.github/workflows/ci.yml

+33
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,20 @@ jobs:
6565
- name: x86_64-gnu-tools
6666
os: ubuntu-20.04-16core-64gb
6767
env: {}
68+
defaults:
69+
run:
70+
shell: "${{ contains(matrix.os, 'windows') && 'msys2 {0}' || 'bash' }}"
6871
timeout-minutes: 600
6972
runs-on: "${{ matrix.os }}"
7073
steps:
74+
- if: "contains(matrix.os, 'windows')"
75+
uses: msys2/setup-msys2@v2.22.0
76+
with:
77+
msystem: "${{ contains(matrix.name, 'i686') && 'mingw32' || 'mingw64' }}"
78+
update: false
79+
release: true
80+
path-type: inherit
81+
install: "make dos2unix diffutils\n"
7182
- name: disable git crlf conversion
7283
run: git config --global core.autocrlf false
7384
- name: checkout the source code
@@ -459,9 +470,20 @@ jobs:
459470
RUST_CONFIGURE_ARGS: "--build=x86_64-pc-windows-msvc --enable-extended --enable-profiler"
460471
SCRIPT: python x.py dist bootstrap --include-default-paths
461472
os: windows-2019-8core-32gb
473+
defaults:
474+
run:
475+
shell: "${{ contains(matrix.os, 'windows') && 'msys2 {0}' || 'bash' }}"
462476
timeout-minutes: 600
463477
runs-on: "${{ matrix.os }}"
464478
steps:
479+
- if: "contains(matrix.os, 'windows')"
480+
uses: msys2/setup-msys2@v2.22.0
481+
with:
482+
msystem: "${{ contains(matrix.name, 'i686') && 'mingw32' || 'mingw64' }}"
483+
update: false
484+
release: true
485+
path-type: inherit
486+
install: "make dos2unix diffutils\n"
465487
- name: disable git crlf conversion
466488
run: git config --global core.autocrlf false
467489
- name: checkout the source code
@@ -587,9 +609,20 @@ jobs:
587609
env:
588610
CODEGEN_BACKENDS: "llvm,cranelift"
589611
os: ubuntu-20.04-16core-64gb
612+
defaults:
613+
run:
614+
shell: "${{ contains(matrix.os, 'windows') && 'msys2 {0}' || 'bash' }}"
590615
timeout-minutes: 600
591616
runs-on: "${{ matrix.os }}"
592617
steps:
618+
- if: "contains(matrix.os, 'windows')"
619+
uses: msys2/setup-msys2@v2.22.0
620+
with:
621+
msystem: "${{ contains(matrix.name, 'i686') && 'mingw32' || 'mingw64' }}"
622+
update: false
623+
release: true
624+
path-type: inherit
625+
install: "make dos2unix diffutils\n"
593626
- name: disable git crlf conversion
594627
run: git config --global core.autocrlf false
595628
- name: checkout the source code

src/ci/github-actions/ci.yml

+21
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,31 @@ x--expand-yaml-anchors--remove:
111111
if: success() && !env.SKIP_JOB
112112

113113
- &base-ci-job
114+
defaults:
115+
run:
116+
shell: ${{ contains(matrix.os, 'windows') && 'msys2 {0}' || 'bash' }}
114117
timeout-minutes: 600
115118
runs-on: "${{ matrix.os }}"
116119
env: *shared-ci-variables
117120
steps:
121+
- if: contains(matrix.os, 'windows')
122+
uses: msys2/setup-msys2@v2.22.0
123+
with:
124+
# i686 jobs use mingw32. x86_64 and cross-compile jobs use mingw64.
125+
msystem: ${{ contains(matrix.name, 'i686') && 'mingw32' || 'mingw64' }}
126+
# don't try to download updates for already installed packages
127+
update: false
128+
# don't try to use the msys that comes built-in to the github runner,
129+
# so we can control what is installed (i.e. not python)
130+
release: true
131+
# Inherit the full path from the Windows environment, with MSYS2's */bin/
132+
# dirs placed in front. This lets us run Windows-native Python etc.
133+
path-type: inherit
134+
install: >
135+
make
136+
dos2unix
137+
diffutils
138+
118139
- name: disable git crlf conversion
119140
run: git config --global core.autocrlf false
120141

src/ci/run.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --set dist.compression-profile=balance
7676
# the LLVM build, as not to run out of memory.
7777
# This is an attempt to fix the spurious build error tracked by
7878
# https://github.com/rust-lang/rust/issues/108227.
79-
if isWindows && [[ ${CUSTOM_MINGW-0} -eq 1 ]]; then
79+
if isKnownToBeMingwBuild; then
8080
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --set llvm.link-jobs=1"
8181
fi
8282

src/ci/scripts/install-clang.sh

+1-2
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@ if isMacOS; then
3737
# Configure `AR` specifically so rustbuild doesn't try to infer it as
3838
# `clang-ar` by accident.
3939
ciCommandSetEnv AR "ar"
40-
elif isWindows && [[ ${CUSTOM_MINGW-0} -ne 1 ]]; then
41-
40+
elif isWindows && ! isKnownToBeMingwBuild; then
4241
# If we're compiling for MSVC then we, like most other distribution builders,
4342
# switch to clang as the compiler. This'll allow us eventually to enable LTO
4443
# amongst LLVM and rustc. Note that we only do this on MSVC as I don't think

src/ci/scripts/install-mingw.sh

+5-5
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,11 @@ if isWindows; then
3838
;;
3939
esac
4040

41-
if [[ "${CUSTOM_MINGW-0}" -ne 1 ]]; then
42-
pacman -S --noconfirm --needed mingw-w64-$arch-toolchain mingw-w64-$arch-cmake \
43-
mingw-w64-$arch-gcc \
44-
mingw-w64-$arch-python # the python package is actually for python3
45-
ciCommandAddPath "$(ciCheckoutPath)/msys2/mingw${bits}/bin"
41+
if [[ "${CUSTOM_MINGW:-0}" == 0 ]]; then
42+
pacboy -S --noconfirm toolchain:p
43+
# According to the comment in the Windows part of install-clang.sh, in the future we might
44+
# want to do this instead:
45+
# pacboy -S --noconfirm clang:p ...
4646
else
4747
mingw_dir="mingw${bits}"
4848

src/ci/scripts/install-msys2.sh

+31-7
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,12 @@
11
#!/bin/bash
2-
# Download and install MSYS2, needed primarily for the test suite (run-make) but
3-
# also used by the MinGW toolchain for assembling things.
2+
# Clean up and prepare the MSYS2 installation. MSYS2 is needed primarily for
3+
# the test suite (run-make), but is also used by the MinGW toolchain for assembling things.
44

55
set -euo pipefail
66
IFS=$'\n\t'
77

88
source "$(cd "$(dirname "$0")" && pwd)/../shared.sh"
9-
109
if isWindows; then
11-
msys2Path="c:/msys64"
12-
mkdir -p "${msys2Path}/home/${USERNAME}"
13-
ciCommandAddPath "${msys2Path}/usr/bin"
14-
1510
# Detect the native Python version installed on the agent. On GitHub
1611
# Actions, the C:\hostedtoolcache\windows\Python directory contains a
1712
# subdirectory for each installed Python version.
@@ -29,4 +24,33 @@ if isWindows; then
2924
fi
3025
ciCommandAddPath "C:\\hostedtoolcache\\windows\\Python\\${native_python_version}\\x64"
3126
ciCommandAddPath "C:\\hostedtoolcache\\windows\\Python\\${native_python_version}\\x64\\Scripts"
27+
28+
# Install pacboy for easily installing packages
29+
pacman -S --noconfirm pactoys
30+
31+
# Delete these pre-installed tools so we can't accidentally use them, because we are using the
32+
# MSYS2 setup action versions instead.
33+
# Delete pre-installed version of MSYS2
34+
rm -r "/c/msys64/"
35+
# Delete Strawberry Perl, which contains a version of mingw
36+
rm -r "/c/Strawberry/"
37+
# Delete these other copies of mingw, I don't even know where they come from.
38+
rm -r "/c/mingw64/"
39+
rm -r "/c/mingw32/"
40+
41+
if isKnownToBeMingwBuild; then
42+
# Use the mingw version of CMake for mingw builds.
43+
# However, the MSVC build needs native CMake, as it fails with the mingw one.
44+
# Delete native CMake
45+
rm -r "/c/Program Files/CMake/"
46+
# Install mingw-w64-$arch-cmake
47+
pacboy -S --noconfirm cmake:p
48+
49+
# We use Git-for-Windows for MSVC builds, and MSYS2 Git for mingw builds,
50+
# so that both are tested.
51+
# Delete Windows-Git
52+
rm -r "/c/Program Files/Git/"
53+
# Install MSYS2 git
54+
pacman -S --noconfirm git
55+
fi
3256
fi

src/ci/shared.sh

+4
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ function isLinux {
5252
[[ "${OSTYPE}" = "linux-gnu" ]]
5353
}
5454

55+
function isKnownToBeMingwBuild {
56+
isGitHubActions && [[ "${CI_JOB_NAME}" == *mingw ]]
57+
}
58+
5559
function isCiBranch {
5660
if [[ $# -ne 1 ]]; then
5761
echo "usage: $0 <branch-name>"

0 commit comments

Comments
 (0)