fix(toolchain): do not pass the compiler's implicit include dirs
VoidBuildSystem CI / 4A2 · VBS installers (linux target) (push) Successful in 3m58s
VoidBuildSystem CI / 1 · Requirements (push) Successful in 7s
VoidBuildSystem CI / 2A · Linux build (debug) (push) Successful in 3m28s
VoidBuildSystem CI / 2A · Linux build (sanitizers) (push) Successful in 5m13s
VoidBuildSystem CI / 2A · Linux build (relwithdebinfo) (push) Successful in 4m4s
VoidBuildSystem CI / 3A · Linux test (debug) (push) Successful in 6m7s
VoidBuildSystem CI / 3A · Linux test (relwithdebinfo) (push) Successful in 6m2s
VoidBuildSystem CI / 3A · Linux test (sanitizers) (push) Successful in 1m19s
VoidBuildSystem CI / 2B · Windows Wine build (debug) (push) Successful in 1m38s
VoidBuildSystem CI / 2B · Windows Wine build (relwithdebinfo) (push) Successful in 3m11s
VoidBuildSystem CI / 3B · Windows Wine test (debug) (push) Successful in 16s
VoidBuildSystem CI / 3B · Windows Wine test (relwithdebinfo) (push) Successful in 17s
VoidBuildSystem CI / 4A2 · VBS installers (windows target) (push) Failing after 1m33s
VoidBuildSystem CI / 5 · Release (push) Failing after 9s
VoidBuildSystem CI / 4A2 · VBS installers (linux target) (push) Successful in 3m58s
VoidBuildSystem CI / 1 · Requirements (push) Successful in 7s
VoidBuildSystem CI / 2A · Linux build (debug) (push) Successful in 3m28s
VoidBuildSystem CI / 2A · Linux build (sanitizers) (push) Successful in 5m13s
VoidBuildSystem CI / 2A · Linux build (relwithdebinfo) (push) Successful in 4m4s
VoidBuildSystem CI / 3A · Linux test (debug) (push) Successful in 6m7s
VoidBuildSystem CI / 3A · Linux test (relwithdebinfo) (push) Successful in 6m2s
VoidBuildSystem CI / 3A · Linux test (sanitizers) (push) Successful in 1m19s
VoidBuildSystem CI / 2B · Windows Wine build (debug) (push) Successful in 1m38s
VoidBuildSystem CI / 2B · Windows Wine build (relwithdebinfo) (push) Successful in 3m11s
VoidBuildSystem CI / 3B · Windows Wine test (debug) (push) Successful in 16s
VoidBuildSystem CI / 3B · Windows Wine test (relwithdebinfo) (push) Successful in 17s
VoidBuildSystem CI / 4A2 · VBS installers (windows target) (push) Failing after 1m33s
VoidBuildSystem CI / 5 · Release (push) Failing after 9s
VoidLibrary's dependency detection exports /usr/include as a system
include directory; passing it as -isystem makes GCC drop its implicit
entry for that path, so libstdc++'s '#include_next <stdlib.h>' fails
('stdlib.h: No such file or directory'). This broke the self-hosted
install only in environments where the dependency finds Boost/OpenSSL.
Probe the implicit include search list for GCC as well as Clang and
skip those directories when lowering compile commands. Also log the
executed command at debug level.
Verified: 'vbs install' (self-hosted) now succeeds inside an Arch
container matching the CI image.
This commit is contained in:
1 parent
00e14bae98
commit
b2c869961a
3 files changed
+52
-1
No files matched your search
@@ -705,6 +705,14 @@ execute_graph(const Graph::BuildGraph &graph, State::StateStore &state,
|
|||||||
Platform::ProcessRequest preq;
|
Platform::ProcessRequest preq;
|
||||||
preq.executable = act.executable;
|
preq.executable = act.executable;
|
||||||
preq.arguments = act.arguments;
|
preq.arguments = act.arguments;
|
||||||
|
{
|
||||||
|
std::string command_line = act.executable.string();
|
||||||
|
for (const auto &arg : act.arguments) {
|
||||||
|
command_line += ' ';
|
||||||
|
command_line += arg;
|
||||||
|
}
|
||||||
|
Void::Log::debug("Build", "Exec {}", command_line);
|
||||||
|
}
|
||||||
if (!act.working_directory.empty()) {
|
if (!act.working_directory.empty()) {
|
||||||
preq.working_directory = act.working_directory;
|
preq.working_directory = act.working_directory;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1171,6 +1171,28 @@ run_native_provider(const ProviderRequest &request, const std::filesystem::path
|
|||||||
return std::unexpected{exec.error()};
|
return std::unexpected{exec.error()};
|
||||||
}
|
}
|
||||||
if (!exec->succeeded) {
|
if (!exec->succeeded) {
|
||||||
|
// Void::Result::Error bounds its message, and a raw compiler stderr
|
||||||
|
// starts with a long include chain: keep the error lines (or the tail)
|
||||||
|
// so the actual diagnostic survives.
|
||||||
|
const auto compact = [](std::string_view text) {
|
||||||
|
std::string errors;
|
||||||
|
std::size_t pos = 0;
|
||||||
|
while (pos < text.size()) {
|
||||||
|
const auto nl = text.find('\n', pos);
|
||||||
|
const auto end = nl == std::string_view::npos ? text.size() : nl;
|
||||||
|
const auto line = text.substr(pos, end - pos);
|
||||||
|
if (line.find("error") != std::string_view::npos ||
|
||||||
|
line.find("Error") != std::string_view::npos) {
|
||||||
|
errors.append(line).push_back('\n');
|
||||||
|
}
|
||||||
|
pos = end + 1;
|
||||||
|
}
|
||||||
|
if (!errors.empty()) {
|
||||||
|
return errors;
|
||||||
|
}
|
||||||
|
constexpr std::size_t kTail = 900;
|
||||||
|
return std::string{text.size() > kTail ? text.substr(text.size() - kTail) : text};
|
||||||
|
};
|
||||||
std::string detail;
|
std::string detail;
|
||||||
for (const auto &ar : exec->results) {
|
for (const auto &ar : exec->results) {
|
||||||
if (!ar.succeeded) {
|
if (!ar.succeeded) {
|
||||||
@@ -1179,7 +1201,7 @@ run_native_provider(const ProviderRequest &request, const std::filesystem::path
|
|||||||
}
|
}
|
||||||
detail += ar.action_id + ": " + ar.error_message;
|
detail += ar.action_id + ": " + ar.error_message;
|
||||||
if (!ar.stderr_data.empty()) {
|
if (!ar.stderr_data.empty()) {
|
||||||
detail += "\n" + ar.stderr_data;
|
detail += "\n" + compact(ar.stderr_data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -466,7 +466,13 @@ discover_and_probe(const ProfileContext &context,
|
|||||||
if (cap.family == CompilerFamily::Clang) {
|
if (cap.family == CompilerFamily::Clang) {
|
||||||
cap.module_scanner = Platform::resolve_executable("clang-scan-deps");
|
cap.module_scanner = Platform::resolve_executable("clang-scan-deps");
|
||||||
cap.supports_p1689_scan = cap.module_scanner.has_value();
|
cap.supports_p1689_scan = cap.module_scanner.has_value();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Record the compiler's implicit include search list (GCC and Clang both
|
||||||
|
// print it for `-E -v`): explicitly passing those directories, e.g. as
|
||||||
|
// `-isystem /usr/include`, makes GCC drop its implicit entry and breaks the
|
||||||
|
// `#include_next` chain in libstdc++.
|
||||||
|
{
|
||||||
Platform::ProcessRequest ireq;
|
Platform::ProcessRequest ireq;
|
||||||
ireq.executable = cap.cxx_compiler;
|
ireq.executable = cap.cxx_compiler;
|
||||||
ireq.arguments = {"-x", "c++", "-E", "-v"};
|
ireq.arguments = {"-x", "c++", "-E", "-v"};
|
||||||
@@ -757,7 +763,22 @@ lower_compile_command(const ToolchainCapabilities &toolchain, const CompileReque
|
|||||||
if (toolchain.family == CompilerFamily::Gcc && !request.nondeterministic) {
|
if (toolchain.family == CompilerFamily::Gcc && !request.nondeterministic) {
|
||||||
args.push_back("-frandom-seed=" + request.output_object.filename().string());
|
args.push_back("-frandom-seed=" + request.output_object.filename().string());
|
||||||
}
|
}
|
||||||
|
// Directories the compiler already searches implicitly are skipped: passing
|
||||||
|
// them explicitly (especially as -isystem) makes GCC drop its own entry and
|
||||||
|
// breaks #include_next in the standard library headers.
|
||||||
|
const auto is_implicit_include = [&](const std::filesystem::path &dir) {
|
||||||
|
const auto normalized = dir.lexically_normal();
|
||||||
|
for (const auto &implicit : toolchain.default_include_dirs) {
|
||||||
|
if (std::filesystem::path{implicit}.lexically_normal() == normalized) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
};
|
||||||
for (const auto &[inc, is_system] : request.include_dirs) {
|
for (const auto &[inc, is_system] : request.include_dirs) {
|
||||||
|
if (is_implicit_include(inc)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
args.push_back(is_system ? "-isystem" : "-I");
|
args.push_back(is_system ? "-isystem" : "-I");
|
||||||
args.push_back(inc.string());
|
args.push_back(inc.string());
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user