-
Notifications
You must be signed in to change notification settings - Fork 171
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
Windows build - info/discussion #324
Comments
Thanks a lot for this! Some comments inline.
Certainly. Currently there is a Windows section on the README, maybe you could improve that?
I think that's the txiki.js/.github/workflows/ci.yml Line 117 in 8a521df
[snip on cross-compiling] While useful, GH actions can also do MSYS2 so I guess this would be useful for those who want to cross-compile it themselves? At any rate, another nice addition to the README! |
Sure, anything specific you had in mind? I think maybe just adding this shell snippet to package the files and the certs in MSYS2?
Well, my hope was to be able to create a statically linked The msys2 build has quite a lot of dll deps, and the cert bundle file seem to be expected at an awkward place relative to the binary. Also, the MSYS2 mingw packages are quite bleedng edge, and one might wish to depend on maybe more stable packages (like the official curl-for-windows). This (debian mingw) build procedure can generate So it's just another method to build. Not better or worse, just another option. |
This was my goal too. I might have missed something in your previous (and detailed!) post. Are you able to get a statically linked libcurl so the end result if a fully static binary?
Not with the
Got it now. So I'd suggest just adding these options to the README around the windows section. |
I am, but so far only using the MXE method. Also, I think the MXE [lib]curl recipe uses schannel - because https in With the debian mingw build it's close, but not quite there yet. The official curl-for-windows zip does include So for now the debian mingw script links with
Right, I'll admit I didn't actually follow the instructions at the README, and didn't install
I don't know enough to have a strong opinion here. IIRC curl recommends using OpenSSL instead of schannel, and I think this is the reason the official binary defaults to OpenSSL. It shoud be possible to switch the runtime backend to schannel, but I didn't try it yet. Personally I think it would be nice if it defaults to schannel, unless it finds a certs bundle and then use it instead. This way one can both let windows handle it, or override it with custom certificates. EDIT - Im attaching the MXE statically linked (stripped) tjs.exe with my build notes: |
Thank you! This is very helpful. I'll certainly take a look at MXE for distributing binary build for people to try. |
any news on this? it would be awesome to just download from Github releases and run everything in a single binary. |
No news, sorry. Happy to take patches if anyone can submit them. |
The msys2 environment can compile txiki correctly, but you may need to install some dependent packages |
Is it possible to use CI build to publish commonly used binary files to GitHub release |
Yes, I'm planning on doing that for the next release |
I tried to add a ci, you can directly download the windows file |
Great start! If you want to push it over the finish line there are a few things that need to be taken care of:
If you want to go for it, I'd take a PR! |
Hi,
I've built txiki.js for windows, here are some thoughts and data points which others might find useful. This could also be a basis for a readme file or wiki page, or some patches.
curl
On windows, the TLS backend in curl can be either schannel (windows store) where Windows manages the certificates, or a third party TLS lib, like OpenSSL. The latter requires certificates in files/bundles.
A single [lib]curl binary may support more than one backend.
using mingw in MSYS2
The MSYS2 mingw libcurl is configured to use a certificate bundle in a dir relative to the curl dll (DLL-DIR/../ssl/certs/), and so if one builds tjs.exe using the MSYS2 mingw packages then a sequence similar to this could make the bundle portable:
It's possible that the curl dll also support schannel and/or configurable certs path (maybe using env vars), but I've not looked into it.
cross compiling using MXE
I've managed to build
tjs.exe
using MXE - https://github.com/mxe/mxe on debian. MXE builds a mingw toolchain from source and has recipes for many third party packages (e.g. including curl and libffi). It can also be configured to default to static libs and linkage, which helps with creating a singletjs.exe
without dependencies. It also helps that the curl recipe in MXE doesn't seem to need a certs bundle file for https to work out of the box withtjs.exe
(defaults to schannel?).However, using MXE, especially for a one-off build, can be a long process, as building the mingw toolchain and then curl (and its many dependencies) can take quite a while. However, it one already has an MXE setup then it's a viable option.
I did have to work around two issues though: capital includes names in wasm3 (see below), and the curl dependencies were not picked automatically by cmake, so I added them manually at CMakeLists.txt.
cross compiling using debian mingw
Another approach is to use mingw from the distro. I've used debian 11.5 live DVD with the script below to build a 32/64 portable txiki.js package.
This does not build curl because it can be complex, and instead downloads the official reproducible curl-for-windows binary - https://github.com/curl/curl-for-win . All the other deps (quickjs, libuv, wasm3, libffi) are built from the txiki.js git repo and linked statically.
Some data points:
Attached are the build script, and the resulting 64 bits package from current git master, built on debian 11.5 live DVD in a VM (the package inclues the script too at
info/
).To use the script on a freshly booted Debian 11 live DVD: save it e.g.
build-tjs.sh
andchmod +x build-tjs.sh
, then./build-tjs.sh
to build the 64 bits package, orBITS=32 ./build-tjs.sh
for 32 bits (it first installs the required packages). zipped package path is reported at the end of the build.txiki.debian-mingw-build-script.zip
txiki.js.x86_64-w64-mingw32.zip
The text was updated successfully, but these errors were encountered: