Skip to content

Commit fdcb3c5

Browse files
committed
fix(flags): MinGW links libstdc++exp for std::print terminal symbols
std::vprint_unicode's __open_terminal/__write_to_terminal live in libstdc++exp.a on Windows-GCC targets — first real MinGW link on CI failed with undefined references from bits/print.h.
1 parent b5c340d commit fdcb3c5

1 file changed

Lines changed: 11 additions & 5 deletions

File tree

src/build/flags.cppm

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -344,11 +344,17 @@ CompileFlags compute_flags(const BuildPlan& plan) {
344344
// libstdc++/libgcc pair (static_stdlib above) and -B so its own
345345
// binutils resolve, plus `-static` for full static when requested
346346
// (MinGW supports it, unlike MSVC-ABI links).
347-
std::string mingw_static =
348-
(caps.stdlib_id == "libstdc++" && f.linkage == "static")
349-
? " -static" : "";
350-
f.ld = std::format("{}{}{}{}{}", mingw_static, static_stdlib, b_flag,
351-
user_ldflags, link_extra);
347+
std::string mingw_static;
348+
std::string mingw_stdexp;
349+
if (caps.stdlib_id == "libstdc++") {
350+
if (f.linkage == "static") mingw_static = " -static";
351+
// std::print's terminal probe (__open_terminal /
352+
// __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";
355+
}
356+
f.ld = std::format("{}{}{}{}{}{}", mingw_static, static_stdlib, b_flag,
357+
user_ldflags, mingw_stdexp, link_extra);
352358
} else if constexpr (mcpp::platform::needs_explicit_libcxx) {
353359
// macOS. Two min-version concerns (see xlings
354360
// .agents/docs/2026-06-05-macos-min-version-support.md):

0 commit comments

Comments
 (0)