rizsotto / Bear

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

Doesn't grab compilation command of a precompiled header #601

Open laralex opened 3 days ago

laralex commented 3 days ago

Describe the bug Can't make Bear to append the compilation command of a precompiled header into compile_commands.json

To Reproduce Make a header file test.hpp

#include <iostream>

inline void test(int a, int b) {
    std::cout << a + b;
}

Run Bear to generated the precompiled header

bear clang++ -std=c++20 -g -c -o test.hpp.pch -xc++-header test.hpp

Expected behavior compile_commands.json should contain the compilation command, clangd is perfectly capable of interacting with it for code completion

[
   {
       "arguments": [
            "clang++",
            "-std=c++20",
            "-g",
            "-c",
            "-o",
            "test.hpp.pch",
            "-xc++-header",
            "test.hpp"
        ],
        "directory": "/home/user/test",
        "file": "test.hpp.pch"
    }
]

Instead compile_commands.json is just

[]

Environment:

Additional context

rizsotto commented 2 days ago

Hey @laralex , thanks for the report.

Yes, Bear does not put precompiled header into the output. This was a kind of design decision, because I have not seen use of it. Give me some time to implement it. Will keep the ticket open.

laralex commented 2 days ago

@rizsotto I tried to build v3.1.5 from source, it seems to work already. Though I wonder why Ubuntu 20.04 is packaged with such an old version 2.4.3