nickdiego / compiledb

Tool for generating Clang's JSON Compilation Database files for make-based build systems.
GNU General Public License v3.0
1.38k stars 123 forks source link

Parallel make (when combined with recursive?) results in broken compilation db #56

Closed vlovich closed 5 years ago

vlovich commented 6 years ago

Recursive make with parallel build (on project with lots of things being compiled?) is broken. It causes a bunch of errors because the command lines are interleaved with each other. Unclear if the problem reproduces without recursive make but my guess is recursive make + parallel build is the only corner case here.

Seems like --output-sync would be the fix but then I see a bunch of fcntl(): Bad file descriptor lines & at the end I get 0 entries written (& there's no actual compile_commands.json file). It doesn't matter which --output-sync value is used as long as it's not none (e.g. line & recurse have the same issue to varying degrees)

It seems like the correct fix is that compiledb should be overriding MAKE so that recursive make invokes compiledb which puts that compilation DB somewhere else & then at the end all the compilation DBs get merged into 1 file.

nickdiego commented 6 years ago

Could you please provide the exact command line you're using to reproduce this? Any specific project? A possible workaround would be to make it in two separate steps, for example:

make -Bnkw > build.log && compiledb < build.log

I've been using this for automake-generare makefiles (recursive ones), and it seems to work..

Anyway, thanks for reporting this.

nickdiego commented 5 years ago

Was that enough for your to work around the issue?