Skip to content

Commit

Permalink
Use MSVC for the Windows toolchain instead of MinGW (#456)
Browse files Browse the repository at this point in the history
* Use MSVC for the Windows toolchain instead of MinGW

Explicitly use MSVC to avoid the runtime dependencies that the default
toolchain CMake is using is bringing in.

Closes #454

* Update .github/workflows/main.yml

Co-authored-by: Andrew Brown <[email protected]>

* Specify MinSizeRel in `build.sh`

Looks like MSVC defaults to "Debug" instead of an empty string to so the
default logic which works for other compilers isn't kicking in here.

* Don't persist ccache stats across runs

* Move zeroing

---------

Co-authored-by: Andrew Brown <[email protected]>
  • Loading branch information
alexcrichton and abrown authored Jul 23, 2024
1 parent fef66e3 commit 6387b4f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
21 changes: 18 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,9 @@ jobs:
run: sudo apt install ccache
if: runner.os == 'Linux'

- name: Clear ccache statistics
run: ccache --zero-stats

- name: Build and test (macOS)
run: ./ci/build.sh
if: runner.os == 'macOS'
Expand All @@ -133,11 +136,23 @@ jobs:
run: ./ci/docker-build.sh ${{ matrix.artifact }}
if: runner.os == 'Linux'

# Use a shorter build directory than the default on Windows to avoid
# hitting path length and command line length limits. See
# WebAssembly/wasi-libc#514
# Setup the VS Developoer Prompt environment variables to explicitly use
# MSVC to compile LLVM as that avoids extra runtime dependencies
# msys/mingw might bring.
#
# As of 2024-07-22 this sha is the "v1.13.0" tag.
- uses: ilammy/msvc-dev-cmd@0b201ec74fa43914dc39ae48a89fd1d8cb592756
if: runner.os == 'Windows'
- name: Build and test (Windows)
run: |
# Delete a troublesome binary as recommended here
# https://github.com/ilammy/msvc-dev-cmd?tab=readme-ov-file#name-conflicts-with-shell-bash
rm /usr/bin/link
# Use a shorter build directory than the default on Windows to avoid
# hitting path length and command line length limits. See
# WebAssembly/wasi-libc#514. Despite using a different build directory
# though still move the `dist` folder to `build/dist` so the upload
# step below doesn't need a windows-specific hook.
./ci/build.sh C:/wasi-sdk
mkdir build
cp -r C:/wasi-sdk/dist build
Expand Down
1 change: 1 addition & 0 deletions ci/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ fi

cmake -G Ninja -B $build_dir/toolchain -S . \
-DWASI_SDK_BUILD_TOOLCHAIN=ON \
-DCMAKE_BUILD_TYPE=MinSizeRel \
"-DCMAKE_INSTALL_PREFIX=$build_dir/install" \
$WASI_SDK_CI_TOOLCHAIN_CMAKE_ARGS \
"-DLLVM_CMAKE_FLAGS=$WASI_SDK_CI_TOOLCHAIN_LLVM_CMAKE_ARGS"
Expand Down

0 comments on commit 6387b4f

Please sign in to comment.