Skip to content

Commit 26b3a81

Browse files
bnjbvrabrown
andauthored
ci: add MinGW build for Rust crate (#61)
In bytecodealliance/wasmtime#4003 we discovered that the `ittapi` C code uses the uncommon `strnlen_s` function. On older versions of MinGW (GitHub runners currently come with v8.1.0 pre-installed), this function was not available. Since v8.1.0, other versions have been published; this change re-installs MinGW with a recent version which includes `strnlen_s`. This commit has no code changes, just CI configuration to prove that the crate builds with the right MinGW version. As a result of this, we opened actions/runner-images#5530 to upgrade MinGW on all Windows GitHub runners. That upgrade may take some time so in the meantime the workaround is to use a new-ish version of MinGW. Note that this build issue is likely rare: it only really applies if someone builds the `ittapi` crate with `--target x86_64-pc-windows-gnu` AND with an old version of MinGW installed. Co-authored-by: Andrew Brown <[email protected]>
1 parent 5b8a7d7 commit 26b3a81

File tree

3 files changed

+30
-5
lines changed

3 files changed

+30
-5
lines changed

.github/workflows/main.yml

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,17 +51,40 @@ jobs:
5151
strategy:
5252
fail-fast: false
5353
matrix:
54-
os: [ubuntu-latest, macos-latest, windows-latest]
54+
include:
55+
- os: ubuntu-latest
56+
- os: macos-latest
57+
- os: windows-latest
58+
- os: windows-latest
59+
target: x86_64-pc-windows-gnu
5560
defaults:
5661
run:
5762
working-directory: rust
63+
shell: bash
5864
steps:
5965
- uses: actions/checkout@v2
6066
with:
6167
submodules: recursive
68+
- run: rustup target add ${{ matrix.target }}
69+
if: matrix.target != ''
70+
- run: echo CARGO_BUILD_TARGET=${{ matrix.target }} >> $GITHUB_ENV
71+
if: matrix.target != ''
72+
- name: Upgrade MinGW package
73+
# In https://github.com/bytecodealliance/wasmtime/pull/4003 we discovered that the ittapi C
74+
# code uses the uncommon `strnlen_s` function. On older versions of MinGW (GitHub runners
75+
# currently come with v8.1.0 pre-installed), this function was not available. Since v8.1.0,
76+
# other versions have been published; this re-installs MinGW with a recent version which
77+
# includes `strnlen_s`. This block can be removed if/when MinGW is upgraded in all Windows
78+
# GitHub runners: https://github.com/actions/virtual-environments/issues/5530.
79+
if: matrix.target == 'x86_64-pc-windows-gnu'
80+
run: |
81+
choco uninstall mingw
82+
choco install mingw --version 11.2.0 --force
6283
- name: Build Rust crate
6384
run: cargo build
6485
- name: Test Rust crate
6586
run: cargo test
6687
- name: Check crates are publishable
67-
run: scripts/verify-publish.sh
88+
# The Windows CI transforms the `c-library` symlink into a real directory, modifying the Git
89+
# state, so we ignore these changes with `--allow-dirty` here.
90+
run: scripts/verify-publish.sh --allow-dirty

rust/ittapi-sys/build.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//! Build the `ittapi` C library in the parent directory. The `cc` configuration here should match
2-
//! that of the parent directories `CMakeLists.txt` (TODO: keep these in sync, see [#36]).
2+
//! that of the parent directory's `CMakeLists.txt` (TODO: keep these in sync, see [#36]).
33
//!
44
//! [#36]: https://github.com/intel/ittapi/issues/36
55

rust/scripts/verify-publish.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
# Check that the Rust crates can all be packaged up for publication. This cannot use use `cargo
33
# publish --dry-run` because of the dependency between ittapi and ittapi-sys.
44
set -e
5+
6+
SCRIPT_ARGS=${@:1}
57
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
68
pushd $SCRIPT_DIR
79

@@ -19,13 +21,13 @@ directory = "vendor"
1921
EOT
2022

2123
# Package up ittapi-sys and place it in the vendor directory.
22-
cargo package --manifest-path ../ittapi-sys/Cargo.toml
24+
cargo package --manifest-path ../ittapi-sys/Cargo.toml $SCRIPT_ARGS
2325
pushd vendor
2426
tar xf ../../target/package/ittapi-sys-0.*.crate
2527
ITTAPI_SYS_DIR=$(echo ittapi-sys-0.*)
2628
echo '{"files":{}}' > $ITTAPI_SYS_DIR/.cargo-checksum.json
2729
popd
2830

2931
# Package up ittapi.
30-
cargo package --manifest-path ../ittapi/Cargo.toml
32+
cargo package --manifest-path ../ittapi/Cargo.toml $SCRIPT_ARGS
3133
popd

0 commit comments

Comments
 (0)