Add native windows launcher to replace the current .bat files#24858
Add native windows launcher to replace the current .bat files#24858sbc100 wants to merge 1 commit intoemscripten-core:mainfrom
.bat files#24858Conversation
6c9f005 to
a6f3fc0
Compare
.bat files.bat files
|
I don't know much about windows, but would we need to build this as part of the emsdk, ship it, etc.? How important are the issues solved by this? |
I think since its just a tiny |
Isn't there windows-on-arm, so a single binary wouldn't work? |
True! Although I'm not sure anyone is using that yet. We certainly don't yet provide emsdk binaries for windows/arm64. |
|
I haven't reviewed the code yet but I think this idea is generally good We did something similar for the NaCl compiler (for a different reason, but a similar technique). I think I have a mild preference for building it with emsdk rather than checking it in, but I could be convinced. |
| } | ||
|
|
||
| int main() { | ||
| char exePath[MAX_PATH]; |
There was a problem hiding this comment.
Does this work with non-ascii directory/path names?
There was a problem hiding this comment.
There's a whole world of TCHAR pain and Win32 file API coming someone's way...
There was a problem hiding this comment.
The new versions handles all that I believe.
FWIW PowerShell scripts I added a while back should also already solve this issue, and they're chosen by default on Windows when users type I don't mind the |
Windows have long had system similar to macOS Rosetta, it's just that Windows on ARM has only picked up in popularity recently with new laptops, but essentially any x64 Native ARM might be nice to have for wasm-binaries, but for something as simple as this invocation script perf shouldn't matter as much. |
Having to maintain the Sadly I don't think the |
|
Perhaps worth looking at py2exe than rolling something own? |
I have looked at things like that over the years but the complexity always scared me off. It would also be little sad to loose the "edit-in-place" abilities of the plain-old-python files. |
|
I asked Gemini CLI to help me write a better version. Its seems to have done it! I asked it to find any discrpencies between these two and it came
The C code replaces the batch script by directly launching Python or ccache. It correctly determines the Python executable and the script to run. Key features include:
Potential Issues & Discrepancies:
Conclusion: The primary concern is the missing |
3aabac6 to
10988a1
Compare
.bat files.bat files
06473b9 to
9f6cf43
Compare
In particular, on windows, when looking for llvm / binaryen / emscripten entry points allow them to end with the normal set of executable extensions. This allows folks use, for example, a clang.bat wrapper around clang and also allows us to start using `emcc.exe` over `emcc.bat` at some point. See emscripten-core#24858 The old `exe_suffix` helper still exists but is now moved to the test framework.
Folks who use git need to run `./bootstrap` to have these launchers created. This has been true now since emscripten-core#23761. However, I initially left these commonly used launchers checked in so that folks could run them and they would report the "you need to run `bootstrap` message". Now that its been 6 months we removed the launcher I think existing users should all now be aware of the `./bootstrap` script. I'm also hoping to move to `.exe` files on windows soon, and this change will help smooth the way: emscripten-core#24858
Folks who use git need to run `./bootstrap` to have these launchers created. This has been true now since emscripten-core#23761. However, I initially left these commonly used launchers checked in so that folks could run them and they would report the "you need to run `bootstrap` message". Now that its been 6 months we removed the launcher I think existing users should all now be aware of the `./bootstrap` script. I'm also hoping to move to `.exe` files on windows soon, and this change will help smooth the way: emscripten-core#24858
Folks who use git need to run `./bootstrap` to have these launchers created. This has been true now since emscripten-core#23761. However, I initially left these commonly used launchers checked in so that folks could run them and they would report the "you need to run `bootstrap` message". Now that its been 6 months we removed the launcher I think existing users should all now be aware of the `./bootstrap` script. I'm also hoping to move to `.exe` files on windows soon, and this change will help smooth the way: emscripten-core#24858
Folks who use git need to run `./bootstrap` to have these launchers created. This has been true now since emscripten-core#23761. However, I initially left these commonly used launchers checked in so that folks could run them and they would report the "you need to run `bootstrap` message". Now that its been 6 months we removed the launcher I think existing users should all now be aware of the `./bootstrap` script. I'm also hoping to move to `.exe` files on windows soon, and this change will help smooth the way: emscripten-core#24858
Folks who use git need to run `./bootstrap` to have these launchers created. This has been true now since #23761. However, I initially left these commonly used launchers checked in so that folks could run them and they would report the "you need to run `bootstrap` message". Now that its been 6 months we removed the launcher I think existing users should all now be aware of the `./bootstrap` script. I'm also hoping to move to `.exe` files on windows soon, and this change will help smooth the way: #24858
b1e0833 to
3febb50
Compare
|
@juj, I'd like to try and experiment where we land this and see if you can use it? I've added an escape hatch of |
|
The executable being checked in here was build on the circleci bot and downloaded as an artifact of the new build-windows-launcher job. |
.bat files.bat files
59ff9e4 to
f10b565
Compare
|
Perf number seem fairly negligable: .exe: .bat: |
7ce0669 to
497c2bd
Compare
497c2bd to
d438601
Compare
|
I wonder if we should build the exes with the same compiler we use to build the emsdk binaries, just to minimize the chances of there being any interesting differences. I'm also not super enthusiastic about checking in binaries, but I guess if we want to maintain the invariant that you can just check out emscripten and use it without emsdk or other dependencies, then there aren't too many other options? |
This is still just an experiment but eventually I hope to remove the `.bat` files in favor of this executable. Users who have issues can opt out via `EMCC_USE_BAT_FILES`. There are several reasons to want to do this: 1. Batch files are notoriously painful to work with and mis-understood. 2. Should be faster (no need to launch cmd.exe). 3. Works around several known issues with .bat files including one that is known unsolvable one (see emcc.bat for more details)
d438601 to
866f3d3
Compare
Yes, perhaps we can do that on the emscripten-releases waterfall? I think that can happen later though, if we do run into issue.
Yes, I'm normally completely against that too, but I think this is good example of case where an exception that rule makes sense. Since the binary is so small we can think of it more like a binary shell script :) |
| set(CMAKE_CXX_USE_RESPONSE_FILE_FOR_INCLUDES 1) | ||
| if (DEFINED USE_BAT_FILES) | ||
| # See https://github.com/emscripten-core/emscripten/issues/2386 | ||
| set(CMAKE_C_USE_RESPONSE_FILE_FOR_LIBRARIES 1) |
There was a problem hiding this comment.
.exe also need this, as for .exe, the command line length still limits to
32768 wchar_t, for linux the command line length are about 2MBbyte, so this still needed.
Its not clear if this will lead to issues with virus/security scanners. For this reason, I'm leaving the old
.batfilesaround for now and user can opt out of this by running
tools/maint/create_entry_points.py --bat-files.Assuming we don't run into any issues I hope to eventually completely remove support for the
.batfiles.There are several reasons to want to do this:
Fixes: #26229
Fixes: #19207