MINGW-packages
MINGW-packages copied to clipboard
Code compiled by ucrt gcc sometimes cannot run on Windows
Recently upgraded to ucrt gcc 12 and I'm getting "This app can't run on your PC" prompts when I attempt to run Java compiled by the ucrt linking gcc (A quick look at dependency walker reveals this is actually the System Error 193 - The executable is not a valid Win 32 application) which suggests a bad PE format, but when I re-run the linker command manually from bash the Java launcher and dlls work properly, strangely enough. A quick discussion in the mailing lists (https://sourceforge.net/p/mingw-w64/mailman/message/37697216/) and a search on google hints it may be due to a new update to the PE format that gcc or ld maybe cannot properly handle (.voltbl sections?) - But it is strange that the faulty binaries are produced when linked through the automated build system, running the exact same link command manually, as mentioned above, produces working code.
Broken binaries:
When the same link command is run manually:
Note: The error shown by the manually linked launcher is unrelated, it is working as intended
Could show a minimal reproducer. If I have understood well, you were linking some java code with ucrt/gcc. Since we don't have Java in MSYS2, I assume you are using the prebuilt official one which was built with MSVC. Linking MSVC built libraries with MINGW is not supported.
I'm not using the official builds, the JDK in question was a development build compiled by gcc and linked to the MinGW libraries as per normal (Part of an ongoing attempt to get the JDK to compile with gcc at https://bugs.openjdk.org/browse/JDK-8288293)
There is probably a dll that maps to some file on the first environment and to another (the correct one) on the second one.
You can try tracing the opening of dlls with full paths as the .exe starts and text-compare the output of each environment.
Hi! Any update on this? @TheShermanTanker were you able to solve the issue?