Skip to content

[pylauncher] Use standard main() entry point with hybrid CRT linking - #27618

Merged
sbc100 merged 1 commit into
emscripten-core:mainfrom
sbc100:pylauncher-main
Aug 28, 2026
Merged

[pylauncher] Use standard main() entry point with hybrid CRT linking#27618
sbc100 merged 1 commit into
emscripten-core:mainfrom
sbc100:pylauncher-main

Conversation

@sbc100

@sbc100 sbc100 commented Aug 28, 2026

Copy link
Copy Markdown
Collaborator

Switch to standard int main() entry point in pylauncher.c and use
/MT with /NODEFAULTLIB:libucrt.lib ucrt.lib in build.bat.

The goal of this change is to make the binaries less likely to trigger
false positive detections from malware scanners and antivirus tools,
which often flag tiny executables compiled with custom entry points
and without buffer security checks (/GS-).

This links CRT startup code and compiler runtime support statically
(so buffer security checks /GS and cookie initialization are handled
automatically by mainCRTStartup without custom entrypoint stubs or
vcruntime140.dll dependencies) while dynamically linking against the
OS-provided ucrtbase.dll.

This increases binary size by ~16-17 KB (total size ~23 KB) compared
to the previous /NODEFAULTLIB /GS- setup, while avoiding the
~100-300 KB overhead of statically linking the full Universal CRT.

@sbc100
sbc100 requested review from RReverser and dschuff and removed request for dschuff August 28, 2026 21:40
Switch to standard `int main()` entry point in `pylauncher.c` and use
`/MT` with `/NODEFAULTLIB:libucrt.lib ucrt.lib` in `build.bat`.

The goal of this change is to make the binaries less likely to trigger
false positive detections from malware scanners and antivirus tools,
which often flag tiny executables compiled with custom entry points
and without buffer security checks (`/GS-`).

This links CRT startup code and compiler runtime support statically
(so buffer security checks `/GS` and cookie initialization are handled
automatically by `mainCRTStartup` without custom entrypoint stubs or
`vcruntime140.dll` dependencies) while dynamically linking against the
OS-provided `ucrtbase.dll`.

This increases binary size by ~16-17 KB (total size ~23 KB) compared
to the previous `/NODEFAULTLIB /GS-` setup, while avoiding the
~100-300 KB overhead of statically linking the full Universal CRT.
@sbc100
sbc100 merged commit 704da90 into emscripten-core:main Aug 28, 2026
42 checks passed
@sbc100
sbc100 deleted the pylauncher-main branch August 28, 2026 23:58
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.

2 participants