Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bootstrap issue with git on MSYS + Experimental CI testing #117833

Closed
wants to merge 171 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
171 commits
Select commit Hold shift + click to select a range
e06c3aa
Fix bootstrap issue with git on MSYS
majaha Nov 12, 2023
b0dacf9
TEMP CI TEST COMMIT
majaha Nov 12, 2023
5a1a8e7
TEMP CI 2
majaha Nov 12, 2023
1207054
TEMP CI 3
majaha Nov 12, 2023
36cb910
TEMP CI 4
majaha Nov 12, 2023
6995865
TEMP CI 5
majaha Nov 12, 2023
61547cb
TEMP CI 6
majaha Nov 12, 2023
7d8df36
TEMP CI 7
majaha Nov 12, 2023
bdef4f9
TEMP CI 8
majaha Nov 12, 2023
acab766
TEMP CI 9
majaha Nov 12, 2023
016e385
TEMP CI 10
majaha Nov 12, 2023
0c223af
TEMP CI 11
majaha Nov 12, 2023
71ae01b
TEMP CI 12
majaha Nov 12, 2023
f58e4cb
TEMP CI 13
majaha Nov 12, 2023
fc38306
TEMP CI 14
majaha Nov 12, 2023
41c72e8
TEMP CI 15
majaha Nov 12, 2023
124e9fe
TEMP CI 16
majaha Nov 12, 2023
dbaa0ea
TEMP CI 17
majaha Nov 12, 2023
e930638
TEMP CI 18
majaha Nov 12, 2023
ec4210f
TEMP CI 19
majaha Nov 12, 2023
65895c4
TEMP CI 20
majaha Nov 12, 2023
00a411b
TEMP CI 21
majaha Nov 12, 2023
8dba931
TEMP CI 22
majaha Nov 12, 2023
2d2448a
TEMP CI 23
majaha Nov 12, 2023
ec4683f
TEMP CI 24
majaha Nov 12, 2023
8b851b8
TEMP CI 25
majaha Nov 12, 2023
893d58b
TEMP CI 26
majaha Nov 12, 2023
c294454
TEMP CI 27
majaha Nov 12, 2023
105f6d0
TEMP CI 28
majaha Nov 15, 2023
d8dd377
TEMP CI 29
majaha Nov 15, 2023
b2b322f
TEMP CI 30
majaha Nov 15, 2023
2fb85f7
TEMP CI 31
majaha Nov 17, 2023
4cd175c
TEMP CI 32
majaha Nov 17, 2023
dfdcb5c
TEMP CI 32
majaha Nov 17, 2023
0ae0b41
TEMP CI 33
majaha Nov 17, 2023
31bd8d6
TEMP CI 34
majaha Nov 17, 2023
f6749f8
TEMP CI 35
majaha Nov 17, 2023
2b360df
TEMP CI 36
majaha Nov 17, 2023
6495ab4
TEMP CI 37
majaha Nov 17, 2023
63f54e7
TEMP CI 38
majaha Nov 17, 2023
aa1bc92
TEMP CI 38
majaha Nov 17, 2023
47482d1
TEMP CI 39
majaha Nov 18, 2023
f1e6d3c
TEMP CI 40
majaha Nov 18, 2023
073a35b
TEMP CI 41
majaha Nov 18, 2023
0736e7f
TEMP CI 42
majaha Nov 18, 2023
eba4342
TEMP CI 43
majaha Nov 18, 2023
416c98b
TEMP CI 44
majaha Nov 18, 2023
7b85c78
TEMP CI 45
majaha Nov 18, 2023
edb37d9
TEMP CI 46
majaha Nov 19, 2023
e04fdb5
TEMP CI 47
majaha Dec 27, 2023
1b580ff
Merge branch 'master' of https://github.com/rust-lang/rust into mingw_ci
majaha Dec 27, 2023
47a65aa
TEMP CI 48
majaha Dec 27, 2023
bcdabaf
TEMP CI 49
majaha Dec 27, 2023
f62a921
TEMP CI 50
majaha Dec 27, 2023
21b1750
TEMP CI 51
majaha Dec 27, 2023
317ed3a
TEMP CI 52
majaha Dec 27, 2023
b09440f
TEMP CI 53
majaha Dec 27, 2023
0a7bf09
TEMP CI 54
majaha Dec 27, 2023
f02dc71
TEMP CI 55
majaha Dec 27, 2023
5f74bb6
TEMP CI 56
majaha Dec 27, 2023
ad1fb61
TEMP CI 57
majaha Dec 27, 2023
89997a9
TEMP CI 58
majaha Dec 27, 2023
0cc9246
TEMP CI 59
majaha Dec 27, 2023
b3c7016
TEMP CI 60
majaha Dec 27, 2023
371a185
TEMP CI 61
majaha Dec 27, 2023
427c5c1
Revert "Fix bootstrap issue with git on MSYS"
majaha Dec 29, 2023
c910014
TEMP CI 62
majaha Dec 27, 2023
7d7f16d
Reapply "Fix bootstrap issue with git on MSYS"
majaha Dec 29, 2023
31d778d
TEMP CI 63
majaha Dec 27, 2023
807f678
TEMP CI 64
majaha Dec 29, 2023
b464ef1
TEMP CI 65
majaha Dec 29, 2023
73aa765
Add some explaination
majaha Jan 1, 2024
357213f
remove make
majaha Jan 2, 2024
87e2260
Revert "remove make"
majaha Jan 2, 2024
537bf4b
.
majaha Jan 3, 2024
b5695fc
.
majaha Jan 3, 2024
5a1eb2b
.
majaha Jan 3, 2024
3bb8a28
.
majaha Jan 3, 2024
c41156d
.
majaha Jan 3, 2024
33ec1b5
.
majaha Jan 3, 2024
4a1fac9
.
majaha Jan 3, 2024
db4fbd5
.
majaha Jan 3, 2024
db7a077
.
majaha Jan 4, 2024
f2f97e8
.
majaha Jan 4, 2024
fa00bec
.
majaha Jan 4, 2024
6a8a0ff
Merge remote-tracking branch 'upstream/master' into mingw_ci
majaha Jan 4, 2024
2253f98
.
majaha Jan 4, 2024
1653872
.
majaha Jan 4, 2024
9e7c048
.
majaha Jan 4, 2024
bb0e91f
.
majaha Jan 5, 2024
bed311b
.
majaha Jan 5, 2024
3b0f94b
.
majaha Jan 6, 2024
e37d549
.
majaha Jan 6, 2024
7c95ab5
.
majaha Jan 6, 2024
9d14543
.
majaha Jan 6, 2024
d539efc
.
majaha Jan 6, 2024
ada5063
.
majaha Jan 6, 2024
fd31da5
.
majaha Jan 6, 2024
74f5141
.
majaha Jan 6, 2024
83a4c13
.
majaha Jan 7, 2024
b43efd9
.
majaha Jan 11, 2024
134f31c
.
majaha Jan 12, 2024
d601af5
.
majaha Jan 12, 2024
00fe609
.
majaha Jan 12, 2024
d0cdd74
.
majaha Jan 12, 2024
bbc7d47
.
majaha Jan 13, 2024
0a6da3c
.
majaha Jan 13, 2024
ac7c3ed
.
majaha Jan 13, 2024
667c525
.
majaha Jan 13, 2024
7256992
.
majaha Jan 13, 2024
3d8d5ad
.
majaha Jan 13, 2024
89a0fa3
.
majaha Jan 13, 2024
95ea8e8
.
majaha Jan 14, 2024
6152f2a
.
majaha Jan 14, 2024
57f01ff
.
majaha Jan 14, 2024
be14d4a
.
majaha Jan 14, 2024
24c826d
.
majaha Jan 14, 2024
559c57b
.
majaha Jan 15, 2024
3ad796a
.
majaha Jan 15, 2024
5dfd344
.
majaha Jan 15, 2024
40b328e
.
majaha Jan 15, 2024
bce495f
.
majaha Jan 15, 2024
7d5f459
.
majaha Jan 15, 2024
be435b5
.
majaha Jan 15, 2024
82815dd
.
majaha Jan 16, 2024
ea7aad9
.
majaha Jan 16, 2024
2e4d471
.
majaha Jan 16, 2024
4fc0e0f
.
majaha Jan 16, 2024
6f089be
.
majaha Jan 16, 2024
c2c5e15
.
majaha Jan 16, 2024
83fdeab
.
majaha Jan 16, 2024
a5f68f8
.
majaha Jan 16, 2024
9a8b3b7
.
majaha Jan 16, 2024
2e60349
.
majaha Jan 16, 2024
89f0c06
.
majaha Jan 16, 2024
267b45a
.
majaha Jan 17, 2024
3f8df37
.
majaha Jan 17, 2024
d81a888
.
majaha Jan 18, 2024
d7975ee
.
majaha Jan 18, 2024
8168418
.
majaha Jan 18, 2024
9e23f5b
.
majaha Jan 18, 2024
600f148
.
majaha Jan 19, 2024
c6d26cd
.
majaha Jan 19, 2024
7ca5928
.
majaha Jan 19, 2024
16245b0
.
majaha Jan 19, 2024
dbc0b94
.
majaha Jan 19, 2024
71342db
.
majaha Jan 20, 2024
f579a65
.
majaha Jan 20, 2024
9dca703
.
majaha Jan 21, 2024
a9f8db9
.
majaha Jan 22, 2024
273ab0c
.
majaha Jan 22, 2024
6e5bc07
.
majaha Jan 22, 2024
db9a3bb
.
majaha Jan 22, 2024
584bfa7
.
majaha Jan 23, 2024
2b983b9
.
majaha Jan 23, 2024
61d3cf2
.
majaha Jan 23, 2024
0ec3664
.
majaha Jan 23, 2024
a7d8d0b
.
majaha Jan 23, 2024
1e1f5f4
.
majaha Jan 24, 2024
81693d9
.
majaha Feb 7, 2024
18c0a92
Merge branch 'master' of https://github.com/rust-lang/rust into mingw_ci
majaha Feb 7, 2024
aa519a7
TEMP STUFF
majaha Feb 9, 2024
3d239cb
.
majaha Feb 11, 2024
2801a43
.
majaha Feb 12, 2024
d128930
.
majaha Feb 13, 2024
1686c35
Revert "."
majaha Feb 13, 2024
52e9dc3
.
majaha Feb 13, 2024
c8155ee
.
majaha Feb 13, 2024
11887c3
Revert "."
majaha Feb 16, 2024
b7531a9
Revert "."
majaha Feb 16, 2024
b592418
Use windows git for MSVC
majaha Feb 16, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
79 changes: 69 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,24 +50,61 @@ jobs:
if: "github.event_name == 'pull_request'"
continue-on-error: "${{ matrix.name == 'mingw-check-tidy' }}"
strategy:
fail-fast: false
matrix:
include:
- name: mingw-check
os: ubuntu-20.04-4core-16gb
env: {}
- name: mingw-check-tidy
- name: i686-mingw
env:
RUST_CONFIGURE_ARGS: "--build=i686-pc-windows-gnu"
SCRIPT: make ci-mingw
NO_DOWNLOAD_CI_LLVM: 1
CUSTOM_MINGW: 1
os: windows-2019-8core-32gb
- name: x86_64-mingw
env:
SCRIPT: make ci-mingw
RUST_CONFIGURE_ARGS: "--build=x86_64-pc-windows-gnu --enable-profiler"
NO_DOWNLOAD_CI_LLVM: 1
CUSTOM_MINGW: 1
os: windows-2019-8core-32gb
- name: dist-i686-mingw
env:
RUST_CONFIGURE_ARGS: "--build=i686-pc-windows-gnu --enable-full-tools --enable-profiler"
NO_DOWNLOAD_CI_LLVM: 1
SCRIPT: python x.py dist bootstrap --include-default-paths
CUSTOM_MINGW: 1
DIST_REQUIRE_ALL_TOOLS: 1
os: windows-2019-8core-32gb
- name: dist-x86_64-mingw
env:
SCRIPT: python x.py dist bootstrap --include-default-paths
RUST_CONFIGURE_ARGS: "--build=x86_64-pc-windows-gnu --enable-full-tools --enable-profiler"
NO_DOWNLOAD_CI_LLVM: 1
CUSTOM_MINGW: 1
DIST_REQUIRE_ALL_TOOLS: 1
os: windows-2019-8core-32gb
- name: x86_64-gnu
os: ubuntu-20.04-4core-16gb
env: {}
- name: x86_64-gnu-llvm-16
- name: x86_64-msvc
env:
ENABLE_GCC_CODEGEN: "1"
os: ubuntu-20.04-16core-64gb
- name: x86_64-gnu-tools
os: ubuntu-20.04-16core-64gb
env: {}
RUST_CONFIGURE_ARGS: "--build=x86_64-pc-windows-msvc --enable-profiler"
SCRIPT: make ci-msvc
os: windows-2019-8core-32gb
defaults:
run:
shell: "${{ contains(matrix.os, 'windows') && 'msys2 {0}' || 'bash' }}"
timeout-minutes: 600
runs-on: "${{ matrix.os }}"
steps:
- if: "contains(matrix.os, 'windows')"
uses: msys2/setup-msys2@v2.22.0
with:
msystem: "${{ contains(matrix.name, 'i686') && 'mingw32' || 'mingw64' }}"
update: false
release: true
path-type: inherit
install: "make dos2unix diffutils\n"
- name: disable git crlf conversion
run: git config --global core.autocrlf false
- name: checkout the source code
Expand Down Expand Up @@ -459,9 +496,20 @@ jobs:
RUST_CONFIGURE_ARGS: "--build=x86_64-pc-windows-msvc --enable-extended --enable-profiler"
SCRIPT: python x.py dist bootstrap --include-default-paths
os: windows-2019-8core-32gb
defaults:
run:
shell: "${{ contains(matrix.os, 'windows') && 'msys2 {0}' || 'bash' }}"
timeout-minutes: 600
runs-on: "${{ matrix.os }}"
steps:
- if: "contains(matrix.os, 'windows')"
uses: msys2/setup-msys2@v2.22.0
with:
msystem: "${{ contains(matrix.name, 'i686') && 'mingw32' || 'mingw64' }}"
update: false
release: true
path-type: inherit
install: "make dos2unix diffutils\n"
- name: disable git crlf conversion
run: git config --global core.autocrlf false
- name: checkout the source code
Expand Down Expand Up @@ -587,9 +635,20 @@ jobs:
env:
CODEGEN_BACKENDS: "llvm,cranelift"
os: ubuntu-20.04-16core-64gb
defaults:
run:
shell: "${{ contains(matrix.os, 'windows') && 'msys2 {0}' || 'bash' }}"
timeout-minutes: 600
runs-on: "${{ matrix.os }}"
steps:
- if: "contains(matrix.os, 'windows')"
uses: msys2/setup-msys2@v2.22.0
with:
msystem: "${{ contains(matrix.name, 'i686') && 'mingw32' || 'mingw64' }}"
update: false
release: true
path-type: inherit
install: "make dos2unix diffutils\n"
- name: disable git crlf conversion
run: git config --global core.autocrlf false
- name: checkout the source code
Expand Down
7 changes: 3 additions & 4 deletions INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,9 @@ toolchain.

1. Download the latest [MSYS2 installer][msys2] and go through the installer.

2. Run `mingw32_shell.bat` or `mingw64_shell.bat` from the MSYS2 installation
directory (e.g. `C:\msys64`), depending on whether you want 32-bit or 64-bit
Rust. (As of the latest version of MSYS2 you have to run `msys2_shell.cmd
-mingw32` or `msys2_shell.cmd -mingw64` from the command line instead.)
2. Start a MINGW64 or MINGW32 shell (depending on whether you want 32-bit
or 64-bit Rust) either from your start menu, or by running `mingw64.exe`
or `mingw32.exe` from your MSYS2 installation directory (e.g. `C:\msys64`).

3. From this terminal, install the required tools:

Expand Down
23 changes: 16 additions & 7 deletions src/bootstrap/src/core/config/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1227,22 +1227,31 @@ impl Config {
// Infer the rest of the configuration.

// Infer the source directory. This is non-trivial because we want to support a downloaded bootstrap binary,
// running on a completely machine from where it was compiled.
// running on a completely different machine from where it was compiled.
let mut cmd = Command::new("git");
// NOTE: we cannot support running from outside the repository because the only path we have available
// is set at compile time, which can be wrong if bootstrap was downloaded from source.
// NOTE: we cannot support running from outside the repository because the only other path we have available
// is set at compile time, which can be wrong if bootstrap was downloaded rather than compiled locally.
// We still support running outside the repository if we find we aren't in a git directory.
cmd.arg("rev-parse").arg("--show-toplevel");

// NOTE: We get a relative path from git to work around an issue on MSYS/mingw. If we used an absolute path,
// and end up using MSYS's git rather than git-for-windows, we would get a unix-y MSYS path. But as bootstrap
// has already been (kinda-cross-)compiled to Windows land, we require a normal Windows path.
cmd.arg("rev-parse").arg("--show-cdup");
// Discard stderr because we expect this to fail when building from a tarball.
let output = cmd
.stderr(std::process::Stdio::null())
.output()
.ok()
.and_then(|output| if output.status.success() { Some(output) } else { None });
if let Some(output) = output {
let git_root = String::from_utf8(output.stdout).unwrap();
// We need to canonicalize this path to make sure it uses backslashes instead of forward slashes.
let git_root = PathBuf::from(git_root.trim()).canonicalize().unwrap();
let git_root_relative = String::from_utf8(output.stdout).unwrap();
// We need to canonicalize this path to make sure it uses backslashes instead of forward slashes,
// and to resolve any relative components.
let git_root = env::current_dir()
.unwrap()
.join(PathBuf::from(git_root_relative.trim()))
.canonicalize()
.unwrap();
let s = git_root.to_str().unwrap();

// Bootstrap is quite bad at handling /? in front of paths
Expand Down
88 changes: 78 additions & 10 deletions src/ci/github-actions/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,32 @@ x--expand-yaml-anchors--remove:
if: success() && !env.SKIP_JOB

- &base-ci-job
defaults:
run:
shell: ${{ contains(matrix.os, 'windows') && 'msys2 {0}' || 'bash' }}
timeout-minutes: 600
runs-on: "${{ matrix.os }}"
env: *shared-ci-variables
env:
<<: *shared-ci-variables
steps:
- if: contains(matrix.os, 'windows')
uses: msys2/setup-msys2@v2.22.0
with:
# i686 jobs use mingw32. x86_64 and cross-compile jobs use mingw64.
msystem: ${{ contains(matrix.name, 'i686') && 'mingw32' || 'mingw64' }}
# don't try to download updates for already installed packages
update: false
# don't try to use the msys that comes built-in to the github runner,
# so we can control what is installed (i.e. not python)
release: true
# Inherit the full path from the Windows environment, with MSYS2's */bin/
# dirs placed in front. This lets us run Windows-native Python etc.
path-type: inherit
install: >
make
dos2unix
diffutils

- name: disable git crlf conversion
run: git config --global core.autocrlf false

Expand Down Expand Up @@ -328,21 +350,67 @@ jobs:
if: github.event_name == 'pull_request'
continue-on-error: ${{ matrix.name == 'mingw-check-tidy' }}
strategy:
fail-fast: false
matrix:
include:
- name: mingw-check
<<: *job-linux-4c
- name: i686-mingw
env:
RUST_CONFIGURE_ARGS: --build=i686-pc-windows-gnu
SCRIPT: make ci-mingw
# We are intentionally allowing an old toolchain on this builder (and that's
# incompatible with LLVM downloads today).
NO_DOWNLOAD_CI_LLVM: 1
CUSTOM_MINGW: 1
<<: *job-windows-8c

- name: mingw-check-tidy
<<: *job-linux-4c
- name: x86_64-mingw
env:
SCRIPT: make ci-mingw
RUST_CONFIGURE_ARGS: >-
--build=x86_64-pc-windows-gnu
--enable-profiler
# We are intentionally allowing an old toolchain on this builder (and that's
# incompatible with LLVM downloads today).
NO_DOWNLOAD_CI_LLVM: 1
CUSTOM_MINGW: 1
<<: *job-windows-8c

- name: dist-i686-mingw
env:
RUST_CONFIGURE_ARGS: >-
--build=i686-pc-windows-gnu
--enable-full-tools
--enable-profiler
# We are intentionally allowing an old toolchain on this builder (and that's
# incompatible with LLVM downloads today).
NO_DOWNLOAD_CI_LLVM: 1
SCRIPT: python x.py dist bootstrap --include-default-paths
CUSTOM_MINGW: 1
DIST_REQUIRE_ALL_TOOLS: 1
<<: *job-windows-8c

- name: x86_64-gnu-llvm-16
- name: dist-x86_64-mingw
env:
ENABLE_GCC_CODEGEN: "1"
<<: *job-linux-16c
SCRIPT: python x.py dist bootstrap --include-default-paths
RUST_CONFIGURE_ARGS: >-
--build=x86_64-pc-windows-gnu
--enable-full-tools
--enable-profiler
# We are intentionally allowing an old toolchain on this builder (and that's
# incompatible with LLVM downloads today).
NO_DOWNLOAD_CI_LLVM: 1
CUSTOM_MINGW: 1
DIST_REQUIRE_ALL_TOOLS: 1
<<: *job-windows-8c

- name: x86_64-gnu-tools
<<: *job-linux-16c
- name: x86_64-gnu
<<: *job-linux-4c

- name: x86_64-msvc
env:
RUST_CONFIGURE_ARGS: --build=x86_64-pc-windows-msvc --enable-profiler
SCRIPT: make ci-msvc
<<: *job-windows-8c

auto:
<<: *base-ci-job
Expand Down
2 changes: 1 addition & 1 deletion src/ci/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --set dist.compression-profile=balance
# the LLVM build, as not to run out of memory.
# This is an attempt to fix the spurious build error tracked by
# https://github.com/rust-lang/rust/issues/108227.
if isWindows && [[ ${CUSTOM_MINGW-0} -eq 1 ]]; then
if isKnownToBeMingwBuild; then
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --set llvm.link-jobs=1"
fi

Expand Down
3 changes: 1 addition & 2 deletions src/ci/scripts/install-clang.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ if isMacOS; then
# Configure `AR` specifically so rustbuild doesn't try to infer it as
# `clang-ar` by accident.
ciCommandSetEnv AR "ar"
elif isWindows && [[ ${CUSTOM_MINGW-0} -ne 1 ]]; then

elif isWindows && ! isKnownToBeMingwBuild; then
# If we're compiling for MSVC then we, like most other distribution builders,
# switch to clang as the compiler. This'll allow us eventually to enable LTO
# amongst LLVM and rustc. Note that we only do this on MSVC as I don't think
Expand Down
11 changes: 6 additions & 5 deletions src/ci/scripts/install-mingw.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,12 @@ if isWindows; then
;;
esac

if [[ "${CUSTOM_MINGW-0}" -ne 1 ]]; then
pacman -S --noconfirm --needed mingw-w64-$arch-toolchain mingw-w64-$arch-cmake \
mingw-w64-$arch-gcc \
mingw-w64-$arch-python # the python package is actually for python3
ciCommandAddPath "$(ciCheckoutPath)/msys2/mingw${bits}/bin"
if [[ "${CUSTOM_MINGW-0}" -eq 0 ]]; then
pacboy -S --noconfirm toolchain:p
# Maybe even:
# pacboy -S --noconfirm clang:p ...
# It kinda works, for the opposite CI jobs that gcc works for.
# The windows part of install-clang.sh has comments pertaining to this.
else
mingw_dir="mingw${bits}"

Expand Down
38 changes: 31 additions & 7 deletions src/ci/scripts/install-msys2.sh
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
#!/bin/bash
# Download and install MSYS2, needed primarily for the test suite (run-make) but
# also used by the MinGW toolchain for assembling things.
# Clean up and prepare the MSYS2 installation. MSYS2 is needed primarily for
# the test suite (run-make), but is also used by the MinGW toolchain for assembling things.

set -euo pipefail
IFS=$'\n\t'

source "$(cd "$(dirname "$0")" && pwd)/../shared.sh"

if isWindows; then
msys2Path="c:/msys64"
mkdir -p "${msys2Path}/home/${USERNAME}"
ciCommandAddPath "${msys2Path}/usr/bin"

# Detect the native Python version installed on the agent. On GitHub
# Actions, the C:\hostedtoolcache\windows\Python directory contains a
# subdirectory for each installed Python version.
Expand All @@ -29,4 +24,33 @@ if isWindows; then
fi
ciCommandAddPath "C:\\hostedtoolcache\\windows\\Python\\${native_python_version}\\x64"
ciCommandAddPath "C:\\hostedtoolcache\\windows\\Python\\${native_python_version}\\x64\\Scripts"

# Install pacboy for easily installing packages
pacman -S --noconfirm pactoys

# Delete these pre-installed tools so we can't accidentally use them, because we are using the
# MSYS2 setup action versions instead.
# Delete pre-installed version of MSYS2
rm -r "/c/msys64/"
# Delete Strawberry Perl, which contains a version of mingw
rm -r "/c/Strawberry/"
# Delete these other copies of mingw, I don't even know where they come from.
rm -r "/c/mingw64/"
rm -r "/c/mingw32/"

if isKnownToBeMingwBuild; then
# Use the mingw version of CMake for mingw builds.
# However, the MSVC build needs native CMake, as it fails with the mingw one.
# Delete native CMake
rm -r "/c/Program Files/CMake/"
# Install mingw-w64-$arch-cmake
pacboy -S --noconfirm cmake:p

# We use Git-for-Windows for MSVC builds, and MSYS2 Git for mingw builds,
# so that both are tested.
# Delete Windows-Git
rm -r "/c/Program Files/Git/"
# Install MSYS2 git
pacman -S --noconfirm git
fi
fi
4 changes: 4 additions & 0 deletions src/ci/shared.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ function isLinux {
[[ "${OSTYPE}" = "linux-gnu" ]]
}

function isKnownToBeMingwBuild {
isGitHubActions && [[ "${CI_JOB_NAME}" == *mingw ]]
}

function isCiBranch {
if [[ $# -ne 1 ]]; then
echo "usage: $0 <branch-name>"
Expand Down