Skip to content

[WIP] Add a windows launcher program to replace the current .bat files #24858

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

sbc100
Copy link
Collaborator

@sbc100 sbc100 commented Aug 4, 2025

This is still just an experiment but eventually I hope to remove the .bat files in favor of this executable.

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)

@sbc100 sbc100 force-pushed the win32_launcher branch 11 times, most recently from 8974850 to 6c9f005 Compare August 4, 2025 23:21
This is still just an experiment but eventually I hope to remove
the `.bat` files in favor of this executable.

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)
@sbc100 sbc100 changed the title Add a windows launcher program to replace the current .bat files [WIP] Add a windows launcher program to replace the current .bat files Aug 6, 2025
@sbc100
Copy link
Collaborator Author

sbc100 commented Aug 6, 2025

@dschuff @kripken WDYT?

@kripken
Copy link
Member

kripken commented Aug 6, 2025

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?

@sbc100
Copy link
Collaborator Author

sbc100 commented Aug 7, 2025

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 .exe we could just check it into git once.. then the create_entry_points.py script would make N copies of it, one for each script.

@kripken
Copy link
Member

kripken commented Aug 7, 2025

I think since its just a tiny .exe we could just check it into git once..

Isn't there windows-on-arm, so a single binary wouldn't work?

@sbc100
Copy link
Collaborator Author

sbc100 commented Aug 7, 2025

I think since its just a tiny .exe we could just check it into git once..

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.

@dschuff
Copy link
Member

dschuff commented Aug 7, 2025

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];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this work with non-ascii directory/path names?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a whole world of TCHAR pain and Win32 file API coming someone's way...

@RReverser
Copy link
Collaborator

3. Works around several known issues with .bat files including one that is known unsolvable one (see emcc.bat for more details)

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 emcc ... in PowerShell.

I don't mind the .exe approach, it might make it easier to solve the long-standing issue with Ctrl+C as well - that one is somewhat difficult to solve with either of scripting systems - just want to make sure it's not a burden to maintain.

@RReverser
Copy link
Collaborator

We certainly don't yet provide emsdk binaries for windows/arm64.

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 .exe is automatically supported on ARM via translation layer.

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.

@sbc100
Copy link
Collaborator Author

sbc100 commented Aug 9, 2025

  1. Works around several known issues with .bat files including one that is known unsolvable one (see emcc.bat for more details)

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 emcc ... in PowerShell.

I don't mind the .exe approach, it might make it easier to solve the long-standing issue with Ctrl+C as well - that one is somewhat difficult to solve with either of scripting systems - just want to make sure it's not a burden to maintain.

Having to maintain the .ps1 and .bat files in parallel is another reason to make this switch.

Sadly I don't think the .ps1 files can actually replace the .bat files because IIRC powershell is somehow optional in windows so its not guaranteed to always be there.

@RReverser
Copy link
Collaborator

Perhaps worth looking at py2exe than rolling something own?

@sbc100
Copy link
Collaborator Author

sbc100 commented Aug 9, 2025

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants