jart / cosmopolitan

build-once run-anywhere c library
ISC License
18.41k stars 635 forks source link

Binaries built with GCC13 crash on Windows #824

Open TakuikaNinja opened 1 year ago

TakuikaNinja commented 1 year ago

First of all, thank you for the excellent library. I've been making a Hangman variant for a game jam this weekend and it feels so nice to have the program run on anything.

Here's the issue I've been facing at the moment: I am able to run the compiled binaries on Linux (EndeavourOS, Ubuntu VM) but they crash (tiny mode is silent) on the Windows 10 machine and Windows 11 VM I have access to. The crash messages always seem to show crash 0xc0000005 rip <value depends on libc type>. Building on Windows 11 using the cross9 binaries provided in the tutorial works fine, so I assume GCC changed just enough to mess things up? I am currently compiling GCC9 myself to test my theory but it'll take a while (assuming it works).

Host OS: EndeavourOS (basically Arch) GCC Info:

aarch64-linux-gnu-gcc 13.1.0-1
gcc 13.1.1-1
gcc-libs 13.1.1-1
lib32-gcc-libs 13.1.1-1

The issue can be replicated by compiling any source file with the latest amalgamations, transferring the binary to a Windows machine, and then attempting to run it.

TakuikaNinja commented 1 year ago

GCC9 finally compiled, and I can confirm that binaries compiled with it work on Windows. I will use this as a workaround for now since it doesn't cause any other issues.

TakuikaNinja commented 1 year ago

For reference, this still occurs with Cosmopolitan 3.0 when using the amalgamation.