Skip to contentSkip to conversation

.gitignore: ignore compile_commands.json globally

PATCH Superseded Andrii Nakryiko 4 participants 4 messages Jun 5, 2025 – Jun 6, 2025 BPF

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Andrii Nakryiko

author maintainer
#0 lore raw

PATCH 1/1 .gitignore: ignore compile_commands.json globally

compile_commands.json can be used with clangd to enable language server protocol-based assistance. For kernel itself this can be built with scripts/gen_compile_commands.py, but other projects (e.g., libbpf, or BPF selftests) can benefit from their own compilation database file, which can be generated successfully using external tools, like bear [0].

So, instead of adding compile_commands.json to .gitignore in respective individual projects, let's just ignore it globally anywhere in Linux repo.

[0] https://github.com/rizsotto/Bear

---
 .gitignore | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
.gitignore +1 -1
index bf5ee6e01cd4..451dff66275d 100644
@@ -175,7 +175,7 @@ x509.genkey
 *.kdev4
 
 # Clang's compilation database file
-/compile_commands.json
+compile_commands.json
 
 # Documentation toolchain
 sphinx_*/
Signature · 1 line
2.47.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines · Andrii Nakryiko

compile_commands.json can be used with clangd to enable language server protocol-based assistance. For kernel itself this can be built with scripts/gen_compile_commands.py, but other projects (e.g., libbpf, or BPF selftests) can benefit from their own compilation database file, which can be generated successfully using external tools, like bear [0].

Quoted 7 lines

So, instead of adding compile_commands.json to .gitignore in respective individual projects, let's just ignore it globally anywhere in Linux repo.

[0] https://github.com/rizsotto/Bear

Sure, I cannot imagine anyone actually wanting to check these in, regardless of where they exists.

Quoted 20 lines
---
 .gitignore | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
.gitignore +1 -1
index bf5ee6e01cd4..451dff66275d 100644
@@ -175,7 +175,7 @@ x509.genkey
 *.kdev4
 
 # Clang's compilation database file
-/compile_commands.json
+compile_commands.json
 
 # Documentation toolchain
 sphinx_*/
Signature · 1 line
2.47.1
#2 lore raw
In reply to Andrii Nakryiko

.gitignore x509.genkey · line 178

Quoted 4 lines · Andrii Nakryiko

# Clang's compilation database file

.gitignore +1 -1
-/compile_commands.json
+compile_commands.json

Should it be removed from tools/power/cpupower/.gitignore then?

Thanks!

Cheers,
Miguel

#3 lore raw
Quoted 8 lines · Miguel Ojeda

.gitignore x509.genkey · line 178

Quoted 4 lines · Andrii Nakryiko

# Clang's compilation database file

.gitignore +1 -1
-/compile_commands.json
+compile_commands.json

Should it be removed from tools/power/cpupower/.gitignore then?

yep, can do that in the same patch

Quoted 5 lines

Thanks!

Cheers,
Miguel