rizsotto / Bear

Bear is a tool that generates a compilation database for clang tooling.
GNU General Public License v3.0
4.83k stars 313 forks source link

Empty compilation database when compiling OpenBSD kernel #574

Closed Tachi107 closed 5 months ago

Tachi107 commented 5 months ago

Describe the bug

Bear is unable to generate a compilation database when compiling the OpenBSD kernel. The build is successful, but the resulting compile_commands.json file only includes an empty JSON array ([]).

To Reproduce

  1. Install OpenBSD 7.5

  2. Build gRPC from source

    pkg_add abseil-cpp cmake git libcares protobuf re2

    $ git clone --branch=v1.63.0 https://github.com/grpc/grpc.git $ cd grpc $ cmake -B cmake/build -DgRPC_DOWNLOAD_ARCHIVES:BOOL=OFF -DgRPC_INSTALL:BOOL=ON -DgRPC_BUILD_TESTS:BOOL=OFF -DgRPC_BUILD_GRPCPP_OTEL_PLUGIN:BOOL=OFF -DgRPC_BUILD_GRPC_CSHARP_PLUGIN:BOOL=OFF -DgRPC_BUILD_GRPC_NODE_PLUGIN:BOOL=OFF -DgRPC_BUILD_GRPC_OBJECTIVE_C_PLUGIN:BOOL=OFF -DgRPC_BUILD_GRPC_PHP_PLUGIN:BOOL=OFF -DgRPC_BUILD_GRPC_PYTHON_PLUGIN:BOOL=OFF -DgRPC_BUILD_GRPC_RUBY_PLUGIN:BOOL=OFF -DgRPC_USE_SYSTEMD:STRING=OFF -DgRPC_ZLIB_PROVIDER:STRING=package -DgRPC_CARES_PROVIDER:STRING=package -DgRPC_RE2_PROVIDER:STRING=package -DgRPC_SSL_PROVIDER:STRING=package -DgRPC_PROTOBUF_PROVIDER:STRING=package -DgRPC_BENCHMARK_PROVIDER:STRING=none -DgRPC_ABSL_PROVIDER:STRING=package -DgRPC_OPENTELEMETRY_PROVIDER:STRING=package $ cmake --build cmake/build

    cmake --install cmake/build

  3. Build pkgconf 2.x from source (the default pkg-config can't handle grpc++'s big .pc file)

    $ ftp https://distfiles.ariadne.space/pkgconf/pkgconf-2.2.0.tar.gz $ tar -xvzf pkgconf-2.2.0.tar.gz $ cd pkgconf-2.2.0 $ ./configure --with-pkg-config-dir=/usr/lib/pkgconfig:/usr/local/lib/pkgconfig:/usr/local/share/pkgconfig $ make

    make install

  4. Build Bear from source. Note that simply following the steps below will probably lead to some linking errors. You can solve them by using grpc++_unsecure instead of grpc++, removing the spdlog dependency and promoting Requires.private and Libs.private to their non-.private equivalent in /usr/local/lib/pkgconfig/grpc++_unsecure.pc (I haven't fully understood why these linking errors occur to be honest, but overlinking and removing spdlog code shouldn't cause any issues). You'll also need to explicitly tell protoc where to find the base protobuf headers with -I /usr/local/include.

    pkg_add fmt nlohmann-json spdlog

    $ git clone https://github.com/rizsotto/Bear.git $ cd Bear $ PKG_CONFIG="pkgconf" cmake -B build $ PKG_CONFIG="pkgconf" cmake --build build

    cmake --install build

    Here's my current diff with master:

    diff --git a/CMakeLists.txt b/CMakeLists.txt
    index 7f34bf2..2713baa 100644
    --- a/CMakeLists.txt
    +++ b/CMakeLists.txt
    @@ -52,7 +52,6 @@ ExternalProject_Add(BearSource
            DEPENDS
                nlohmann_json_dependency
                fmt_dependency
    -            spdlog_dependency
                grpc_dependency
                googletest_dependency
            CMAKE_ARGS
    diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt
    index fe6b710..5912c9a 100644
    --- a/source/CMakeLists.txt
    +++ b/source/CMakeLists.txt
    @@ -25,9 +25,9 @@ endif ()
    find_package(Threads REQUIRED)
    find_package(nlohmann_json REQUIRED)
    find_package(fmt REQUIRED)
    -find_package(spdlog REQUIRED)
    +#find_package(spdlog REQUIRED)
    find_package(PkgConfig REQUIRED)
    -pkg_check_modules(gRPC REQUIRED IMPORTED_TARGET protobuf grpc++)
    +pkg_check_modules(gRPC REQUIRED IMPORTED_TARGET protobuf grpc++_unsecure)
    
    if (fmt_VERSION_MAJOR GREATER_EQUAL 9)
        set(FMT_NEEDS_OSTREAM_FORMATTER 1)
    diff --git a/source/bear/CMakeLists.txt b/source/bear/CMakeLists.txt
    index ad0b114..584f4aa 100644
    --- a/source/bear/CMakeLists.txt
    +++ b/source/bear/CMakeLists.txt
    @@ -13,8 +13,7 @@ target_link_libraries(bear_a PUBLIC
            flags_a
            fmt::fmt
            citnames_a
    -        intercept_a
    -        spdlog::spdlog)
    +        intercept_a)
    
    # Create an executable from the sub projects.
    add_executable(bear
    diff --git a/source/bear/source/Application.cc b/source/bear/source/Application.cc
    index 7ef9246..8d8edd9 100644
    --- a/source/bear/source/Application.cc
    +++ b/source/bear/source/Application.cc
    @@ -109,11 +109,9 @@ namespace {
                        return status.code().value_or(EXIT_FAILURE);
                    })
                    .map_err<std::runtime_error>([&name](auto error) {
    -                    spdlog::warn("Running {} failed: {}", name, error.what());
                        return error;
                    })
                    .on_success([&name](auto status) {
    -                    spdlog::debug("Running {} finished. [Exited with {}]", name, status);
                    });
        }
    }
    diff --git a/source/bear/source/Application.h b/source/bear/source/Application.h
    index 07c27b2..57300a6 100644
    --- a/source/bear/source/Application.h
    +++ b/source/bear/source/Application.h
    @@ -27,9 +27,6 @@
    #include "libsys/Signal.h"
    #include "libmain/ApplicationFromArgs.h"
    
    -#include <spdlog/spdlog.h>
    -#include <spdlog/sinks/stdout_sinks.h>
    -
    #include <filesystem>
    #include <optional>
    #include <string_view>
    diff --git a/source/citnames/CMakeLists.txt b/source/citnames/CMakeLists.txt
    index 18c4213..2bf3185 100644
    --- a/source/citnames/CMakeLists.txt
    +++ b/source/citnames/CMakeLists.txt
    @@ -12,7 +12,6 @@ target_link_libraries(citnames_json_a PUBLIC
            shell_a
            sys_a
            fmt::fmt
    -        spdlog::spdlog
            nlohmann_json::nlohmann_json)
    target_compile_options(citnames_json_a PRIVATE -fexceptions)
    
    @@ -43,8 +42,7 @@ target_link_libraries(citnames_a PUBLIC
            flags_a
            sys_a
            exec_a
    -        fmt::fmt
    -        spdlog::spdlog)
    +        fmt::fmt)
    
    include(GNUInstallDirs)
    
    diff --git a/source/citnames/source/Citnames.cc b/source/citnames/source/Citnames.cc
    index 098573d..4e57808 100644
    --- a/source/citnames/source/Citnames.cc
    +++ b/source/citnames/source/Citnames.cc
    @@ -32,7 +32,6 @@
    #include <fmt/std.h>
    #endif
    #include <fmt/ostream.h>
    -#include <spdlog/spdlog.h>
    
    namespace fs = std::filesystem;
    namespace db = ic::collect::db;
    @@ -64,7 +63,6 @@ namespace {
                            to_abspath(content.paths_to_exclude, root)
                    };
                } else {
    -                spdlog::warn("Update configuration failed: {}", cwd.unwrap_err().what());
                }
            }
            return content;
    @@ -171,7 +169,6 @@ namespace {
                        return config;
                    })
                    .on_success([](const auto &config) {
    -                    spdlog::debug("Configuration: {}", config);
                    });
        }
    
    @@ -202,19 +199,16 @@ namespace cs {
                        return transform(build, commands, entries);
                    })
                    .and_then<size_t>([this, &output, &entries](auto new_entries_count) {
    -                    spdlog::debug("compilation entries created. [size: {}]", new_entries_count);
                        // read back the current content and extend with the new elements.
                        return (arguments_.append)
                            ? output.from_json(arguments_.output, entries)
                                    .template map<size_t>([&new_entries_count](auto old_entries_count) {
    -                                    spdlog::debug("compilation entries have read. [size: {}]", old_entries_count);
                                        return new_entries_count + old_entries_count;
                                    })
                            : rust::Result<size_t>(rust::Ok(new_entries_count));
                    })
                    .and_then<size_t>([this, &output, &entries](const size_t & size) {
                        // write the entries into the output file.
    -                    spdlog::debug("compilation entries to output. [size: {}]", size);
    
                        const fs::path temporary_file(arguments_.output.string() + ".tmp");
                        auto result = output.to_json(temporary_file, entries);
    @@ -224,7 +218,6 @@ namespace cs {
                    })
                    .map<int>([](auto size) {
                        // just map to success exit code if it was successful.
    -                    spdlog::debug("compilation entries written. [size: {}]", size);
                        return EXIT_SUCCESS;
                    });
        }
    diff --git a/source/citnames/source/semantic/Build.cc b/source/citnames/source/semantic/Build.cc
    index 1213a8c..ac38e5a 100644
    --- a/source/citnames/source/semantic/Build.cc
    +++ b/source/citnames/source/semantic/Build.cc
    @@ -30,7 +30,6 @@
    #include <utility>
    
    #include <fmt/ostream.h>
    -#include <spdlog/spdlog.h>
    
    #ifdef FMT_NEEDS_OSTREAM_FORMATTER
    template <> struct fmt::formatter<domain::Execution> : ostream_formatter {};
    @@ -67,15 +66,11 @@ namespace cs::semantic {
                auto execution = domain::from(event.started().execution());
                auto pid = event.started().pid();
    
    -            spdlog::debug("[pid: {}] execution: {}", pid, execution);
    
                auto result = tools_->recognize(execution);
                if (Tool::recognized_ok(result)) {
    -                spdlog::debug("[pid: {}] recognized.", pid);
                } else if (Tool::recognized_with_error(result)) {
    -                spdlog::debug("[pid: {}] recognition failed: {}", pid, result.unwrap_err().what());
                } else if (Tool::not_recognized(result)) {
    -                spdlog::debug("[pid: {}] not recognized.", pid);
                }
                return result;
            } else {
    diff --git a/source/intercept/CMakeLists.txt b/source/intercept/CMakeLists.txt
    index 187101a..c16556f 100644
    --- a/source/intercept/CMakeLists.txt
    +++ b/source/intercept/CMakeLists.txt
    @@ -50,8 +50,7 @@ target_link_libraries(intercept_a PUBLIC
            flags_a
            rpc_a
            sys_a
    -        result_a
    -        spdlog::spdlog)
    +        result_a)
    
    # Markdown file is the source to the man file. Please modify that and generate
    # the man file from it with pandoc.
    @@ -81,8 +80,7 @@ target_link_libraries(wrapper_a PUBLIC
            main_a
            result_a
            sys_a
    -        rpc_a
    -        spdlog::spdlog)
    +        rpc_a)
    
    # Intercept report sender executable.
    diff --git a/source/intercept/proto/CMakeLists.txt b/source/intercept/proto/CMakeLists.txt
    index e4fb8c1..b4df33f 100644
    --- a/source/intercept/proto/CMakeLists.txt
    +++ b/source/intercept/proto/CMakeLists.txt
    @@ -11,6 +11,7 @@ add_custom_command(
                ${_PROTOBUF_PROTOC}
            ARGS
                -I "${SUPERVISE_PROTO_PATH}"
    +            -I "/usr/local/include"
                --grpc_out "${CMAKE_CURRENT_BINARY_DIR}"
                --cpp_out "${CMAKE_CURRENT_BINARY_DIR}"
                --plugin=protoc-gen-grpc="${_GRPC_CPP_PLUGIN_EXECUTABLE}"
    @@ -27,13 +28,14 @@ add_custom_command(
    )
    
    get_filename_component(INTERCEPT_PROTO "intercept.proto" ABSOLUTE)
    -get_filename_component(INTERCEPT_PROTO_PATH "${SUPERVISE_PROTO}" PATH)
    +get_filename_component(INTERCEPT_PROTO_PATH "${INTERCEPT_PROTO}" PATH)
    
    add_custom_command(
            COMMAND
                ${_PROTOBUF_PROTOC}
            ARGS
                -I "${SUPERVISE_PROTO_PATH}"
    +            -I "/usr/local/include"
                --grpc_out "${CMAKE_CURRENT_BINARY_DIR}"
                --cpp_out "${CMAKE_CURRENT_BINARY_DIR}"
                --plugin=protoc-gen-grpc="${_GRPC_CPP_PLUGIN_EXECUTABLE}"
    diff --git a/source/intercept/source/collect/Intercept.cc b/source/intercept/source/collect/Intercept.cc
    index fcb941c..e06997d 100644
    --- a/source/intercept/source/collect/Intercept.cc
    +++ b/source/intercept/source/collect/Intercept.cc
    @@ -28,7 +28,6 @@
    
    #include <grpcpp/security/server_credentials.h>
    #include <grpcpp/server_builder.h>
    -#include <spdlog/spdlog.h>
    #include <fmt/format.h>
    
    #include <filesystem>
    @@ -95,11 +94,9 @@ namespace ic {
    
            // Create session_locator URL for the services
            auto session_locator = SessionLocator(fmt::format("dns:///localhost:{}", port));
    -        spdlog::debug("Running gRPC server. {0}", session_locator);
            // Execute the build command
            auto result = session_->run(execution_, session_locator);
            // Stop the gRPC server
    -        spdlog::debug("Stopping gRPC server.");
            server->Shutdown();
            // Exit with the build status
            return result;
    diff --git a/source/intercept/source/collect/Reporter.cc b/source/intercept/source/collect/Reporter.cc
    index 4680738..894f6c6 100644
    --- a/source/intercept/source/collect/Reporter.cc
    +++ b/source/intercept/source/collect/Reporter.cc
    @@ -20,8 +20,6 @@
    #include "config.h"
    #include "collect/Reporter.h"
    
    -#include <spdlog/spdlog.h>
    -
    #include <utility>
    
    namespace ic {
    @@ -47,7 +45,6 @@ namespace ic {
    
            database_->insert_event(event)
                    .on_error([](auto error) {
    -                    spdlog::warn("Writing event into database failed: {} Ignored.", error.what());
                    });
        }
    }
    diff --git a/source/intercept/source/collect/Session.cc b/source/intercept/source/collect/Session.cc
    index dbf4f73..2df4a54 100644
    --- a/source/intercept/source/collect/Session.cc
    +++ b/source/intercept/source/collect/Session.cc
    @@ -28,8 +28,6 @@
    #include "libsys/Path.h"
    #include "libsys/Signal.h"
    
    -#include <spdlog/spdlog.h>
    -
    namespace ic {
    
        rust::Result<Session::Ptr> Session::from(const flags::Arguments& args, const char **envp)
    @@ -90,10 +88,8 @@ namespace ic {
                        return status.code().value_or(EXIT_FAILURE);
                    })
                    .on_error([](auto error) {
    -                    spdlog::warn("Command execution failed: {}", error.what());
                    })
                    .on_success([](auto status) {
    -                    spdlog::debug("Running command. [Exited with {0}]", status);
                    });
        }
    }
    diff --git a/source/intercept/source/collect/SessionLibrary.cc b/source/intercept/source/collect/SessionLibrary.cc
    index cee3405..525be79 100644
    --- a/source/intercept/source/collect/SessionLibrary.cc
    +++ b/source/intercept/source/collect/SessionLibrary.cc
    @@ -24,8 +24,6 @@
    #include "libsys/Path.h"
    #include "libsys/Process.h"
    
    -#include <spdlog/spdlog.h>
    -
    #include <functional>
    
    namespace {
    @@ -73,12 +71,10 @@ namespace ic {
                , library_(library)
                , executor_(executor)
        {
    -        spdlog::debug("Created library preload session. [library={0}, executor={1}]", library_, executor_);
        }
    
        rust::Result<ic::Execution> LibraryPreloadSession::resolve(const ic::Execution &execution) const
        {
    -        spdlog::debug("trying to resolve for library: {}", execution.executable.string());
            return rust::Ok(ic::Execution{
                    execution.executable,
                    execution.arguments,
    diff --git a/source/intercept/source/collect/SessionWrapper.cc b/source/intercept/source/collect/SessionWrapper.cc
    index a4170cd..f9d8ab0 100644
    --- a/source/intercept/source/collect/SessionWrapper.cc
    +++ b/source/intercept/source/collect/SessionWrapper.cc
    @@ -30,7 +30,6 @@
    #endif
    #include <fmt/ostream.h>
    #include <fmt/ranges.h>
    -#include <spdlog/spdlog.h>
    
    #include <algorithm>
    #include <iterator>
    @@ -156,14 +155,10 @@ namespace ic {
                , mapping_(std::move(mapping))
                , override_(std::move(override))
        {
    -        spdlog::debug("session initialized with: wrapper_dir: {}", wrapper_dir_);
    -        spdlog::debug("session initialized with: mapping: {}", mapping_);
    -        spdlog::debug("session initialized with: override: {}", override_);
        }
    
        rust::Result<ic::Execution> WrapperSession::resolve(const ic::Execution &execution) const
        {
    -        spdlog::debug("trying to resolve for wrapper: {}", execution.executable.string());
            return resolve(execution.executable)
                    .map<ic::Execution>([this, &execution](auto executable) {
                        auto arguments = execution.arguments;
    diff --git a/source/intercept/source/report/wrapper/Application.cc b/source/intercept/source/report/wrapper/Application.cc
    index 1650f00..f7f7d17 100644
    --- a/source/intercept/source/report/wrapper/Application.cc
    +++ b/source/intercept/source/report/wrapper/Application.cc
    @@ -28,7 +28,6 @@
    #include "libsys/Signal.h"
    
    #include <fmt/ostream.h>
    -#include <spdlog/spdlog.h>
    
    #include <filesystem>
    #include <memory>
    @@ -50,8 +49,6 @@ namespace {
            { }
    
            void initForVerbose() const override {
    -            spdlog::set_pattern(fmt::format("[%H:%M:%S.%f, wr, {0}, ppid: {1}] %v", getpid(), getppid()));
    -            spdlog::set_level(spdlog::level::debug);
            }
        };
    
    @@ -191,7 +188,6 @@ namespace wr {
                                log_config.initForVerbose();
                            }
                            log_config.record(argv, envp);
    -                        spdlog::debug("arguments parsed: {0}", args);
                        })
                        .and_then<ps::CommandPtr>([&envp](auto args) {
                            // if parsing success, we create the main command and execute it.
    diff --git a/source/intercept/source/report/wrapper/RpcClients.cc b/source/intercept/source/report/wrapper/RpcClients.cc
    index 0f8ca94..d674654 100644
    --- a/source/intercept/source/report/wrapper/RpcClients.cc
    +++ b/source/intercept/source/report/wrapper/RpcClients.cc
    @@ -22,7 +22,6 @@
    
    #include <fmt/format.h>
    #include <grpcpp/create_channel.h>
    -#include <spdlog/spdlog.h>
    
    namespace {
    
    @@ -39,7 +38,6 @@ namespace wr {
        { }
    
        rust::Result<wr::Execution> SupervisorClient::resolve(const wr::Execution &execution) {
    -        spdlog::debug("gRPC call requested: supervise::Supervisor::Resolve");
    
            grpc::ClientContext context;
            rpc::ResolveRequest request;
    @@ -47,7 +45,6 @@ namespace wr {
            request.set_allocated_execution(new rpc::Execution(into(execution)));
            const grpc::Status status = supervisor_->Resolve(&context, request, &response);
    
    -        spdlog::debug("gRPC call [Resolve] finished: {}", status.ok());
            return status.ok()
                   ? rust::Result<wr::Execution>(rust::Ok(from(response.execution())))
                   : rust::Result<wr::Execution>(rust::Err(create_error(status)));
    @@ -59,13 +56,11 @@ namespace wr {
        { }
    
        rust::Result<int> InterceptorClient::report(const rpc::Event &event) {
    -        spdlog::debug("gRPC call requested: supervise::Interceptor::Register");
    
            grpc::ClientContext context;
            google::protobuf::Empty response;
            const grpc::Status status = interceptor_->Register(&context, event, &response);
    
    -        spdlog::debug("gRPC call [Register] finished: {}", status.ok());
            return status.ok()
                    ? rust::Result<int>(rust::Ok(0))
                    : rust::Result<int>(rust::Err(create_error(status)));
    diff --git a/source/libmain/CMakeLists.txt b/source/libmain/CMakeLists.txt
    index 6d9a354..ad4b89f 100644
    --- a/source/libmain/CMakeLists.txt
    +++ b/source/libmain/CMakeLists.txt
    @@ -11,5 +11,4 @@ target_sources(main_a
    target_link_libraries(main_a PUBLIC
            result_a
            flags_a
    -        fmt::fmt
    -        spdlog::spdlog)
    +        fmt::fmt)
    diff --git a/source/libmain/include/libmain/main.h b/source/libmain/include/libmain/main.h
    index 9b50d4e..56b5763 100644
    --- a/source/libmain/include/libmain/main.h
    +++ b/source/libmain/include/libmain/main.h
    @@ -21,8 +21,6 @@
    
    #include "libmain/Application.h"
    
    -#include <spdlog/spdlog.h>
    -
    namespace ps {
    
        template <class App>
    @@ -38,10 +36,8 @@ namespace ps {
                    })
                    // print out the result of the run
                    .on_error([](auto error) {
    -                    spdlog::error("failed with: {}", error.what());
                    })
                    .on_success([](auto status_code) {
    -                    spdlog::debug("succeeded with: {}", status_code);
                    })
                    // set the return code from error
                    .unwrap_or(EXIT_FAILURE);
    diff --git a/source/libmain/source/ApplicationFromArgs.cc b/source/libmain/source/ApplicationFromArgs.cc
    index 44655e6..3d979b8 100644
    --- a/source/libmain/source/ApplicationFromArgs.cc
    +++ b/source/libmain/source/ApplicationFromArgs.cc
    @@ -20,8 +20,6 @@
    #include "libmain/ApplicationFromArgs.h"
    
    #include <fmt/ostream.h>
    -#include <spdlog/spdlog.h>
    -#include <spdlog/sinks/stdout_sinks.h>
    
    #ifdef FMT_NEEDS_OSTREAM_FORMATTER
    template <> struct fmt::formatter<flags::Arguments> : ostream_formatter {};
    @@ -45,7 +43,6 @@ namespace ps {
                    }
                    log_config_.record(argv, envp);
                    log_config_.context();
    -                spdlog::debug("arguments parsed: {0}", args);
                })
                // if parsing success, we create the main command and execute it.
                .and_then<CommandPtr>([this, &envp](auto args) {
    diff --git a/source/libmain/source/ApplicationLogConfig.cc b/source/libmain/source/ApplicationLogConfig.cc
    index a94d707..92614c6 100644
    --- a/source/libmain/source/ApplicationLogConfig.cc
    +++ b/source/libmain/source/ApplicationLogConfig.cc
    @@ -21,8 +21,6 @@
    #include "config.h"
    
    #include <fmt/ranges.h>
    -#include <spdlog/spdlog.h>
    -#include <spdlog/sinks/stdout_sinks.h>
    
    #ifdef HAVE_SYS_UTSNAME_H
    #include <sys/utsname.h>
    @@ -53,36 +51,24 @@ namespace ps {
                : name_(name)
                , id_(id)
        {
    -        spdlog::set_default_logger(spdlog::stderr_logger_mt("stderr"));
        }
    
        void ApplicationLogConfig::initForSilent() const
        {
    -        spdlog::set_pattern(fmt::format("{0}: %v", name_));
    -        spdlog::set_level(spdlog::level::info);
        }
    
        void ApplicationLogConfig::initForVerbose() const
        {
    -        spdlog::set_pattern(fmt::format("[%H:%M:%S.%f, {0}, %P] %v", id_));
    -        spdlog::set_level(spdlog::level::debug);
        }
    
        void ApplicationLogConfig::record(const char** argv, const char** envp) const
        {
    -        spdlog::debug("{0}: {1}", name_, cmd::VERSION);
    -        spdlog::debug("arguments: {0}", Array { argv });
    -        spdlog::debug("environment: {0}", Array { envp });
        }
    
        void ApplicationLogConfig::context() const {
    #ifdef HAVE_UNAME
            auto name = utsname{};
            if (const int status = uname(&name); status >= 0) {
    -            spdlog::debug("sysname: {0}", name.sysname);
    -            spdlog::debug("release: {0}", name.release);
    -            spdlog::debug("version: {0}", name.version);
    -            spdlog::debug("machine: {0}", name.machine);
            }
            errno = 0;
    #endif
    diff --git a/source/libmain/source/SubcommandFromArgs.cc b/source/libmain/source/SubcommandFromArgs.cc
    index 30f4c5f..12b365e 100644
    --- a/source/libmain/source/SubcommandFromArgs.cc
    +++ b/source/libmain/source/SubcommandFromArgs.cc
    @@ -20,8 +20,6 @@
    #include "libmain/SubcommandFromArgs.h"
    
    #include <fmt/ostream.h>
    -#include <spdlog/spdlog.h>
    -#include <spdlog/sinks/stdout_sinks.h>
    
    #include <stdexcept>
    
    diff --git a/source/libsys/CMakeLists.txt b/source/libsys/CMakeLists.txt
    index ca2638f..da3d59a 100644
    --- a/source/libsys/CMakeLists.txt
    +++ b/source/libsys/CMakeLists.txt
    @@ -15,8 +15,7 @@ target_sources(sys_a
    target_link_libraries(sys_a PUBLIC
            ${CMAKE_DL_LIBS}
            result_a
    -        fmt::fmt
    -        spdlog::spdlog)
    +        fmt::fmt)
    
    if (ENABLE_UNIT_TESTS)
        add_executable(sys_unit_test
    diff --git a/source/libsys/source/Process.cc b/source/libsys/source/Process.cc
    index 4629507..06cd02f 100644
    --- a/source/libsys/source/Process.cc
    +++ b/source/libsys/source/Process.cc
    @@ -52,8 +52,6 @@
    #endif
    
    #include <fmt/ranges.h>
    -#include <spdlog/spdlog.h>
    -#include <spdlog/sinks/stdout_sinks.h>
    
    namespace {
    
    @@ -162,17 +160,14 @@ namespace {
                    // The file is accessible, but it is not an executable file.
                    // Invoke the shell to interpret it as a script.
                    .or_else([&](const std::runtime_error&) {
    -                    spdlog::debug("Process spawn failed. [will retry as shell]");
    
                        std::list<std::string> args(parameters);
                        args.insert(args.begin(), std::string(PATH_TO_SH));
                        return spawn_process(fp, PATH_TO_SH, args, environment, redirect_io);
                    })
                    .on_success([&parameters](const auto& pid) {
    -                    spdlog::debug("Process spawned. [pid: {}, command: {}]", pid, parameters);
                    })
                    .on_error([&parameters](const auto& error) {
    -                    spdlog::debug("Process spawn failed. [error: {}, command: {}]", error.what(), parameters);
                    });
        }
    
    @@ -250,25 +245,19 @@ namespace sys {
    
        rust::Result<ExitStatus> Process::wait(const bool request_for_signals)
        {
    -        spdlog::debug("Process wait requested. [pid: {}]", pid_);
            return wait_for(pid_, request_for_signals)
                .on_success([this](const auto&) {
    -                spdlog::debug("Process wait request: done. [pid: {}]", pid_);
                })
                .on_error([this](const auto& error) {
    -                spdlog::debug("Process wait request: failed. [pid: {}] {}", pid_, error.what());
                });
        }
    
        rust::Result<int> Process::kill(int num)
        {
    -        spdlog::debug("Process kill requested. [pid: {}, signum: {}]", pid_, num);
            return send_signal(pid_, num)
                .on_success([this](const auto&) {
    -                spdlog::debug("Process kill request: done. [pid: {}]", pid_);
                })
                .on_error([this](const auto& error) {
    -                spdlog::debug("Process kill request: failed. [pid: {}] {}", pid_, error.what());
                });
        }
    
    diff --git a/third_party/grpc/CMakeLists.txt b/third_party/grpc/CMakeLists.txt
    index 05501c3..607305c 100644
    --- a/third_party/grpc/CMakeLists.txt
    +++ b/third_party/grpc/CMakeLists.txt
    @@ -1,6 +1,6 @@
    message(STATUS "Looking for gRPC::grpc++ dependency")
    find_package(PkgConfig REQUIRED)
    -pkg_check_modules(gRPC protobuf>=3.11 grpc++>=1.26)
    +pkg_check_modules(gRPC protobuf>=3.11 grpc++_unsecure>=1.26)
    if (gRPC_FOUND)
        message(STATUS "Looking for gRPC::grpc++ dependency -- found")
  5. Download the kernel source and place it in /usr/src

    $ usermod -G wsrc $LOGNAME $ ftp https://cdn.openbsd.org/pub/OpenBSD/7.5/sys.tar.gz $ cd /usr/src $ tar -xvzf $OLDPWD/sys.tar.gz

  6. Compile the kernel following the instructions in release(8)

    $ cd /sys/arch/$(machine)/compile/GENERIC.MP

    make obj

    make config

    bear -- make

  7. Print the resuling compile_commands.json

    $ cat compile_commands.json []

Environment:

Tachi107 commented 5 months ago

Here's an example of what Bear was logging to the events JSON file while building:

{"rid":"17527298732620882772","timestamp":"2024-05-04T15:56:43.280418Z","started":{"execution":{"executable":"/bin/sh","arguments":["/bin/sh","-ec","cc -g -Werror -Wall -Wimplicit-function-declaration  -Wno-pointer-sign  -Wframe-larger-than=2047 -Wno-address-of-packed-member -Wno-constant-conversion  -Wno-unused-but-set-variable -Wno-gnu-folding-constant -mcmodel=kernel -mno-red-zone -mno-sse2 -mno-sse -mno-3dnow  -mno-mmx -msoft-float -fno-omit-frame-pointer -ffreestanding -fno-pie -msave-args -mretpoline-external-thunk -fcf-protection=branch -O2  -pipe -nostdinc -I/usr/src/sys -I/usr/src/sys/arch/amd64/compile/GENERIC.MP/obj -I/usr/src/sys/arch  -I/usr/src/sys/dev/pci/drm/include  -I/usr/src/sys/dev/pci/drm/include/uapi  -I/usr/src/sys/dev/pci/drm/amd/include/asic_reg  -I/usr/src/sys/dev/pci/drm/amd/include  -I/usr/src/sys/dev/pci/drm/amd/amdgpu  -I/usr/src/sys/dev/pci/drm/amd/display  -I/usr/src/sys/dev/pci/drm/amd/display/include  -I/usr/src/sys/dev/pci/drm/amd/display/dc  -I/usr/src/sys/dev/pci/drm/amd/display/amdgpu_dm  -I/usr/src/sys/dev/pci/drm/amd/pm/inc  -I/usr/src/sys/dev/pci/drm/amd/pm/legacy-dpm  -I/usr/src/sys/dev/pci/drm/amd/pm/swsmu  -I/usr/src/sys/dev/pci/drm/amd/pm/swsmu/inc  -I/usr/src/sys/dev/pci/drm/amd/pm/swsmu/smu11  -I/usr/src/sys/dev/pci/drm/amd/pm/swsmu/smu12  -I/usr/src/sys/dev/pci/drm/amd/pm/swsmu/smu13  -I/usr/src/sys/dev/pci/drm/amd/pm/powerplay/inc  -I/usr/src/sys/dev/pci/drm/amd/pm/powerplay/hwmgr  -I/usr/src/sys/dev/pci/drm/amd/pm/powerplay/smumgr  -I/usr/src/sys/dev/pci/drm/amd/pm/swsmu/inc  -I/usr/src/sys/dev/pci/drm/amd/pm/swsmu/inc/pmfw_if  -I/usr/src/sys/dev/pci/drm/amd/display/dc/inc  -I/usr/src/sys/dev/pci/drm/amd/display/dc/inc/hw  -I/usr/src/sys/dev/pci/drm/amd/display/dc/clk_mgr  -I/usr/src/sys/dev/pci/drm/amd/display/modules/inc  -I/usr/src/sys/dev/pci/drm/amd/display/modules/hdcp  -I/usr/src/sys/dev/pci/drm/amd/display/dmub/inc  -I/usr/src/sys/dev/pci/drm/i915 -DDDB -DDIAGNOSTIC -DKTRACE -DACCOUNTING -DKMEMSTATS -DPTRACE -DCRYPTO -DSYSVMSG -DSYSVSEM -DSYSVSHM -DUVM_SWAP_ENCRYPT -DFFS -DFFS2 -DFFS_SOFTUPDATES -DUFS_DIRHASH -DQUOTA -DEXT2FS -DMFS -DNFSCLIENT -DNFSSERVER -DCD9660 -DUDF -DMSDOSFS -DFIFO -DFUSE -DSOCKET_SPLICE -DTCP_ECN -DTCP_SIGNATURE -DINET6 -DIPSEC -DPPP_BSDCOMP -DPPP_DEFLATE -DPIPEX -DMROUTING -DMPLS -DBOOT_CONFIG -DUSER_PCICONF -DAPERTURE -DMTRR -DNTFS -DSUSPEND -DHIBERNATE -DPCIVERBOSE -DUSBVERBOSE -DWSDISPLAY_COMPAT_USL -DWSDISPLAY_COMPAT_RAWKBD -DWSDISPLAY_DEFAULTSCREENS=\"6\" -DX86EMU -DONEWIREVERBOSE -DMULTIPROCESSOR -DMAXUSERS=80 -D_KERNEL -MD -MP  -c /usr/src/sys/dev/acpi/aplgpio.c"],"working_dir":"/usr/obj/sys/arch/amd64/compile/GENERIC.MP","environment":{"LD_PRELOAD":"/usr/local/lib/bear/libexec.so","INTERCEPT_REPORT_COMMAND":"/usr/local/lib/bear/wrapper","MAKEBASEDIRECTORY":"/usr/src/sys/arch/amd64/compile/GENERIC.MP","USER":"root","PATH":"/usr/bin:/bin:/usr/sbin:/sbin:/usr/X11R6/bin:/usr/local/bin:/usr/local/sbin","INTERCEPT_REPORT_DESTINATION":"dns:///localhost:20044","HOME":"/root","MAKEFLAGS":" ","PWD":"/usr/src/sys/arch/amd64/compile/GENERIC.MP/obj","LOGNAME":"root","SHELL":"/bin/ksh","DOAS_USER":"tachi","TERM":"xterm"}},"pid":2014,"ppid":57855}}
{"rid":"17527298732620882772","timestamp":"2024-05-04T15:56:43.487492Z","terminated":{"status":"0"}}
Tachi107 commented 5 months ago

Solved the issue by running bear in compiler wrapper mode with --force-wrapper. Thanks for adding this option!