Skip to content

Commit e7ae19e

Browse files
committed
fix(flags): force winpthread static on MinGW links
winlibs POSIX-threads libstdc++ otherwise leaves produced exes depending on libwinpthread-1.dll — the standalone-exe e2e caught it (empty output, missing-DLL abort). -Wl,-Bstatic -lwinpthread -Wl,-Bdynamic is the standard recipe; libwinpthread.a ships in the payload.
1 parent 1a9efbf commit e7ae19e

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

‎src/build/flags.cppm‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -350,8 +350,11 @@ CompileFlags compute_flags(const BuildPlan& plan) {
350350
if (f.linkage == "static") mingw_static = " -static";
351351
// std::print's terminal probe (__open_terminal /
352352
// __write_to_terminal, bits/print.h) lives in libstdc++exp.a on
353-
// Windows targets — plain -lstdc++ leaves them undefined.
354-
mingw_stdexp = " -lstdc++exp";
353+
// Windows targets — plain -lstdc++ leaves them undefined. And
354+
// POSIX-threads libstdc++ (winlibs) pulls libwinpthread-1.dll
355+
// unless winpthread is forced static — the classic third DLL
356+
// that -static-libstdc++/-static-libgcc do NOT cover.
357+
mingw_stdexp = " -lstdc++exp -Wl,-Bstatic -lwinpthread -Wl,-Bdynamic";
355358
}
356359
f.ld = std::format("{}{}{}{}{}{}", mingw_static, static_stdlib, b_flag,
357360
user_ldflags, mingw_stdexp, link_extra);

0 commit comments

Comments
 (0)