Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Add CI test for Windows with GitHub actions #48
base: winport
Are you sure you want to change the base?
Add CI test for Windows with GitHub actions #48
Changes from 2 commits
57531d6
3ac85e4
ecbb347
f6c0551
de964e2
c9f2bdf
5cd98d8
95fe0bc
a415140
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bash
exists on Windows only when WSL is installed. It may take 10 seconds to boot the lightweight WSL VM, and file access is fairly slow from inside of the VM to files outside of its VHD. I'd usecmd
if I were you. The default on Windows ispwsh
. Verify that the VS command line environment is set up in the worker:I'm getting
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is quite fast in GitHub actions and you won't feel any latency between
cmd
andbash
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still strongly suggest switching to the native shell. I know what is going on in the guts of the OS when you use WSL Bash this way, and that's a lot, and I do mean a lot. A hypervisor partition is created, then a network switch, a Linux OS is booted into this partition from a .vhd virtual disk, then it mounts Windows volumes using the
9p
filesystem over a virtual network, and it maps Linuxrwxrwxrwx
attributes to Windows' ACLs in a tricky way, also depending on whether and how WSL is configured in its/etc/wsl.conf
... An upgrade to WSL may easily break it in a spectacular way. If Microsoft says don't do it, I better don't.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please see the following error after switching to
cmd
andNinja
:https://github.com/csukuangfj/openfst/actions/runs/8794917596/job/24135134756#step:4:4
I want to point out that the main purpose of GitHub actions is to check that the code compiles and runs.
It does not matter whether
cmd
orbash
, orNinja
is used. The time for building in GitHub actions can be ignored, though I have never noticed usingcmd
orNinja
in GitHub actions brings speedup in building.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the default generator on Windows? My CMake thinks it's VS2022 MSBuild files. I'm always using Ninja with CMake, even on Windows. Ninja is incomparably faster than an .sln and a heap of
.*proj
files!You can do
-G Ninja
. I think CMake files only generate x64 arch. @jtrmal?Ninja comes with VS2022, CMake payload (
Microsoft.VisualStudio.Component.VC.CMake.Project
). So if you have CMake, you have Ninja too.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please see
https://github.com/csukuangfj/openfst/actions/runs/8780936061/job/24091877962#step:3:121
Actually, no.
Please refer to
https://k2-fsa.github.io/sherpa/onnx/install/windows.html#bit-windows-x86
for how we build sherpa-onnx for 32-bit windows on 64-bit windows using CMake.
I will switch to
Ninja
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ninja does not support specifying the arch to build.
I am going to extend the build script to windows 32 so I will not switch to Ninja to keep the code consistent both for
windows64 and windows32.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That was what I meant: The concept of a Platform exists in a VS project file, so that
-A
is specific to this generator. This doesn't mean that Ninja doesn't support 32-bit builds (you can build 32-bit executables for 64-bit Linux, too), it just means Ninja isn't built with that platform concept in mind. In cross-compilation (and compiling a 32-bit binary on a 64-bit platform is a kind of cross-compilation), Linux-style equivalent of the MS-specific "Platform" is the architecture triple. And while CMake indeed supports cross-compilation, it requires programming it into CMakeFiles. We better avoid that.The simpler approach is to set up the environment following the VS command-line toolset setup routine. VS installs shortcuts that run
cmd
and make it source an environment setup script.All these use the same script, only its argument is different. The issue (or non-issue) is locating this environment setup script robustly is tricky:
cmd
is a weird language,pwsh
is easier, but still takes some contortions. But there is an easy hack to change the environment from one type to another, since the path to the script is already in an environment variable. I'm assuming you are usingcmd
as the shell; it simply won't work in WSL bash.echo %VSCMD_ARG_HOST_ARCH%
in the runner to see if it'sx64
(64-bit) orx86
(32-bit). This is to preserve the host arch at step 3. I can't imagine that this value could ever change in the runner image, so we can simply hard-code it.a. If the host arch is
x64
, the argument isx64
to build 64-bit binaries, andx64_x86
to cross-build 32-bit binaries.b. If the host arch is
x86
, the argument isx86_x64
to cross-build 64-bit binaries, andx86
to build 32-bit binaries.call
to cmd is what'ssource
to Bash):This is all to it. Further, you can even skip steps 1 and 3, and simply use
x64
orx86
for the<arg>
at step 4. This is the same as opening the shell set up with the "native" environment using the shortcuts in the picture for both 32 and 64 bit builds. The whole kaboodle is only to modify the environment as little as possible. Personally, I wouldn't care about preserving the host arch, and would do this, the simpler way.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For Ninja, the verbose switch after
--
is-v
.