Skip to content

Commit

Permalink
Support Windows targets on Windows host
Browse files Browse the repository at this point in the history
  • Loading branch information
taiki-e committed Jul 28, 2023
1 parent 7e10b58 commit c750034
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 2 deletions.
16 changes: 16 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -175,10 +175,26 @@ jobs:
- target: x86_64h-apple-darwin # tier3
os: macos-latest

# Windows (MSVC)
# rustup target list | grep -e '-pc-windows-msvc'
# rustc --print target-list | grep -e '-pc-windows-msvc'
- { target: aarch64-pc-windows-msvc, os: windows-latest }
- { target: i586-pc-windows-msvc, os: windows-latest }
- { target: i686-pc-windows-msvc, os: windows-latest }
# - { target: thumbv7a-pc-windows-msvc, os: windows-latest } # tier3
- { target: x86_64-pc-windows-msvc, os: windows-latest }

# Windows (GNU)
# rustup target list | grep -e '-pc-windows-gnu'
# rustc --print target-list | grep -e '-pc-windows-gnu'
# Windows host:
# - target: i686-pc-windows-gnu
# os: windows-latest
- target: x86_64-pc-windows-gnu
os: windows-latest
# Linux host:
# - target: i686-pc-windows-gnu
# os: ubuntu-22.04
- target: x86_64-pc-windows-gnu
os: ubuntu-22.04
- target: x86_64-pc-windows-gnu
Expand Down
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,16 @@ Note: In this file, do not use the hard wrap in the middle of a sentence for com

## [Unreleased]

- Support Windows targets on Windows host.

- aarch64-pc-windows-msvc (build-only)
- i586-pc-windows-msvc
- i686-pc-windows-msvc
- x86_64-pc-windows-msvc
- x86_64-pc-windows-gnu

GitHub-provided Windows runners support cross-compile for other architectures or environments, so this action just runs `rustup target add` and/or sets some environment variables.

## [1.13.0] - 2023-07-28

- Support running WASI and Windows binaries directly on Linux host (via binfmt).
Expand Down
25 changes: 24 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ GitHub Action for setup toolchains for cross compilation and cross testing for R
- [NetBSD](#netbsd)
- [WASI](#wasi)
- [Windows (GNU)](#windows-gnu)
- [Windows (MSVC)](#windows-msvc)
- [macOS](#macos)
- [Related Projects](#related-projects)
- [License](#license)
Expand Down Expand Up @@ -392,11 +393,14 @@ clang version and wasi-libc hash can be found here: https://github.com/WebAssemb

| target | host | runner | note |
| ------ | ---- | ------ | ---- |
| `x86_64-pc-windows-gnu` | Ubuntu (<!-- 20.04 [1], -->22.04 [2]) | wine | |
| `x86_64-pc-windows-gnu` | *Windows*, Ubuntu (<!-- 20.04 [1], -->22.04 [2]) | native (Windows host) / wine (Linux host) | |

<!-- [1] [GCC 9](https://packages.ubuntu.com/en/focal/gcc-mingw-w64-base), [MinGW-w64 7](https://packages.ubuntu.com/en/focal/mingw-w64-x86-64-dev)<br> -->
[2] [GCC 10](https://packages.ubuntu.com/en/jammy/gcc-mingw-w64-base), [MinGW-w64 8](https://packages.ubuntu.com/en/jammy/mingw-w64-x86-64-dev)<br>

On Windows host, GitHub-provided Windows runners support cross-compile for other architectures or environments, so this action just runs `rustup target add` and/or sets some environment variables.

On Linux host, this action installs MinGW toolchain and Wine.
The current default version of Wine is 7.13.
You can select/pin the version by using `@` syntax in `runner` input option. For example:

Expand All @@ -407,6 +411,25 @@ You can select/pin the version by using `@` syntax in `runner` input option. For
runner: [email protected]
```

### Windows (MSVC)

| C++ | test |
| --- | ---- |
| ✓ | ✓ [1] |

[1] Only x86/x86_64 targets

**Supported targets**:

| target | host | runner | note |
| ------ | ---- | ------ | ---- |
| `aarch64-pc-windows-msvc` | *Windows* | | |
| `i586-pc-windows-msvc` | *Windows* | native | |
| `i686-pc-windows-msvc` | *Windows* | native | |
| `x86_64-pc-windows-msvc` | *Windows* | native | |

GitHub-provided Windows runners support cross-compile for other architectures or environments, so this action just runs `rustup target add` and/or sets some environment variables.

### macOS

| C++ | test |
Expand Down
12 changes: 11 additions & 1 deletion main.sh
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,7 @@ EOF

case "${host}" in
*-linux-gnu*) setup_linux_host ;;
# GitHub-provided macOS runners support cross-compile for other architectures or environments.
# GitHub-provided macOS/Windows runners support cross-compile for other architectures or environments.
*-darwin*)
case "${target}" in
*-darwin*) ;;
Expand All @@ -612,6 +612,16 @@ case "${host}" in
*) bail "unrecognized runner '${runner}'" ;;
esac
;;
*-windows*)
case "${target}" in
*-windows*) ;;
*) bail "target '${target}' is not supported yet on Windows host" ;;
esac
case "${runner}" in
'' | native) ;;
*) bail "unrecognized runner '${runner}'" ;;
esac
;;
*) bail "unsupported host '${host}'" ;;
esac

Expand Down

0 comments on commit c750034

Please sign in to comment.