Skip to content

Commit fa898cf

Browse files
committed
fix(cli): detect broken build tool runtime libraries
2 parents 33cbce4 + 02e2f1e commit fa898cf

1 file changed

Lines changed: 53 additions & 2 deletions

File tree

src/errors/build/CMakeBuildErrors.cpp

Lines changed: 53 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1218,6 +1218,52 @@ namespace vix::cli::errors::build
12181218
// Link-stage handlers
12191219
// -------------------------------------------------------------------------
12201220

1221+
// [NEW] Build tool shared library missing
1222+
//
1223+
// Example:
1224+
// /usr/bin/llvm-ar: error while loading shared libraries:
1225+
// libLLVM-18.so.18.1: cannot open shared object file: No such file or directory
1226+
//
1227+
// This is not a C++ compile error and not a missing user-linked library.
1228+
// The build tool itself cannot start because its runtime dependency is broken.
1229+
bool handleBuildToolSharedLibraryMissing(std::string_view log)
1230+
{
1231+
const bool hasSharedLibraryFailure =
1232+
contains(log, "error while loading shared libraries") &&
1233+
contains(log, "cannot open shared object file");
1234+
1235+
if (!hasSharedLibraryFailure)
1236+
return false;
1237+
1238+
std::string tool = extract(
1239+
log,
1240+
std::regex(R"re((/[^\s:]+):\s*error while loading shared libraries)re"));
1241+
1242+
std::string library = extract(
1243+
log,
1244+
std::regex(R"re(error while loading shared libraries:\s*([^:\s]+))re"));
1245+
1246+
if (tool.empty())
1247+
{
1248+
tool = extract(
1249+
log,
1250+
std::regex(R"re((\S+):\s*error while loading shared libraries)re"));
1251+
}
1252+
1253+
print_error_title("build tool cannot start");
1254+
1255+
if (!tool.empty())
1256+
print_colored_field("tool: ", RED, tool);
1257+
1258+
if (!library.empty())
1259+
print_colored_field("missing library: ", RED, library);
1260+
1261+
print_hint("the selected build tool is installed but one of its runtime libraries is missing");
1262+
print_hint("reinstall the toolchain package or use another archiver/ranlib pair");
1263+
1264+
return true;
1265+
}
1266+
12211267
// [NEW 6] Missing library during link
12221268
//
12231269
// Must run BEFORE handleUndefinedSymbol — a missing -lfoo causes
@@ -1586,14 +1632,19 @@ namespace vix::cli::errors::build
15861632
if (handleCppCompileError(log))
15871633
return true; // NEW 5
15881634

1589-
// --- Link-stage errors (missing lib & duplicate sym & arch before
1590-
// the generic undefined-symbol catch) ---------------------------
1635+
// --- Link-stage errors (build tool/runtime before normal linker issues) ----
1636+
if (handleBuildToolSharedLibraryMissing(log))
1637+
return true; // NEW
1638+
15911639
if (handleMissingLinkedLibrary(log))
15921640
return true; // NEW 6
1641+
15931642
if (handleMultipleDefinition(log))
15941643
return true; // NEW 7
1644+
15951645
if (handleArchitectureMismatch(log))
15961646
return true; // NEW 8
1647+
15971648
if (handleUndefinedSymbol(log))
15981649
return true;
15991650

0 commit comments

Comments
 (0)