diff --git a/src/Execution/Scheduler.cpp b/src/Execution/Scheduler.cpp index 607d88f..5d99371 100644 --- a/src/Execution/Scheduler.cpp +++ b/src/Execution/Scheduler.cpp @@ -705,6 +705,14 @@ execute_graph(const Graph::BuildGraph &graph, State::StateStore &state, Platform::ProcessRequest preq; preq.executable = act.executable; 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()) { preq.working_directory = act.working_directory; } diff --git a/src/Provider/Provider.cpp b/src/Provider/Provider.cpp index baa07f2..19cdfb6 100644 --- a/src/Provider/Provider.cpp +++ b/src/Provider/Provider.cpp @@ -1171,6 +1171,28 @@ run_native_provider(const ProviderRequest &request, const std::filesystem::path return std::unexpected{exec.error()}; } 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; for (const auto &ar : exec->results) { if (!ar.succeeded) { @@ -1179,7 +1201,7 @@ run_native_provider(const ProviderRequest &request, const std::filesystem::path } detail += ar.action_id + ": " + ar.error_message; if (!ar.stderr_data.empty()) { - detail += "\n" + ar.stderr_data; + detail += "\n" + compact(ar.stderr_data); } } } diff --git a/src/Toolchain/Driver.cpp b/src/Toolchain/Driver.cpp index 133d212..555e714 100644 --- a/src/Toolchain/Driver.cpp +++ b/src/Toolchain/Driver.cpp @@ -466,7 +466,13 @@ discover_and_probe(const ProfileContext &context, if (cap.family == CompilerFamily::Clang) { cap.module_scanner = Platform::resolve_executable("clang-scan-deps"); 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; ireq.executable = cap.cxx_compiler; 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) { 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) { + if (is_implicit_include(inc)) { + continue; + } args.push_back(is_system ? "-isystem" : "-I"); args.push_back(inc.string()); }