Skip to content

Commit d3c5fe6

Browse files
committed
Bake dependency runtime library_dirs into binary RUNPATH; default Linux toolchain to glibc
R2: flags.cppm emitted -Wl,-rpath only from toolchain.linkRuntimeDirs, dropping dependency packages' [runtime] library_dirs (already collected into plan.runtimeLibraryDirs by plan.cppm). So host-GL passthrough dirs (e.g. compat.glx-runtime) never reached the binary RUNPATH and dlopen()'d libGL/libGLX failed at run time (GLX: Failed to load GLX). Iterate plan.runtimeLibraryDirs (superset) instead. R1: cli.cppm first-run default on Linux was gcc-musl-static, which cannot link the glibc world (X11/GL/system libs). Default to platform-native glibc gcc; musl-static stays opt-in via --target x86_64-linux-musl (Cargo-style).
1 parent 93398f4 commit d3c5fe6

2 files changed

Lines changed: 14 additions & 4 deletions

File tree

src/build/flags.cppm

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,13 @@ CompileFlags compute_flags(const BuildPlan& plan) {
256256
std::string static_stdlib = (f.staticStdlib && !isClang && !mcpp::platform::is_windows) ? " -static-libstdc++" : "";
257257
std::string runtime_dirs;
258258
if constexpr (mcpp::platform::supports_rpath) {
259-
for (auto& dir : plan.toolchain.linkRuntimeDirs) {
259+
// Bake ALL resolved runtime library dirs into the binary's RUNPATH —
260+
// not just the toolchain's. plan.runtimeLibraryDirs is the union of
261+
// dependency packages' [runtime] library_dirs (e.g. compat.glx-runtime's
262+
// host-GL passthrough dir) plus the toolchain/payload dirs. Using only
263+
// toolchain.linkRuntimeDirs here dropped dependency runtime dirs, so
264+
// dlopen()'d host libs (libGL/libGLX) were unreachable at run time.
265+
for (auto& dir : plan.runtimeLibraryDirs) {
260266
runtime_dirs += " -L" + escape_path(dir);
261267
runtime_dirs += " -Wl,-rpath," + escape_path(dir);
262268
}

src/cli.cppm

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1386,9 +1386,13 @@ prepare_build(bool print_fingerprint,
13861386
//
13871387
// macOS: LLVM/Clang — Apple doesn't ship GCC; upstream LLVM with
13881388
// bundled libc++ is the self-contained choice.
1389-
// Linux: musl-gcc — produces portable static binaries.
1389+
// Linux: glibc gcc — the platform-native ABI. A musl-static default
1390+
// cannot link the glibc world (X11/GL/system libs), so it
1391+
// breaks GUI/native packages out of the box. musl-static stays
1392+
// opt-in via `mcpp build --target x86_64-linux-musl` for users
1393+
// who explicitly want portable static binaries.
13901394
std::string defaultSpec = (mcpp::platform::is_macos || mcpp::platform::is_windows)
1391-
? "llvm@20.1.7" : "gcc@15.1.0-musl";
1395+
? "llvm@20.1.7" : "gcc@16.1.0";
13921396
auto defaultParsed = mcpp::toolchain::parse_toolchain_spec(defaultSpec);
13931397
auto defaultPkg = mcpp::toolchain::to_xim_package(*defaultParsed);
13941398

@@ -1398,7 +1402,7 @@ prepare_build(bool print_fingerprint,
13981402
defaultSpec));
13991403
} else {
14001404
mcpp::ui::info("First run",
1401-
std::format("no toolchain configured — installing {} (musl, static) as default",
1405+
std::format("no toolchain configured — installing {} (glibc, native ABI) as default",
14021406
defaultSpec));
14031407
}
14041408

0 commit comments

Comments
 (0)