-
Notifications
You must be signed in to change notification settings - Fork 76
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Compilation Database: Support for entries with multiple .c
files in one command
#624
Comments
Is this the last command in the database or something? It looks like some kind of linking command to produce the final The compilation database format doesn't allow multiple files per entry, so I'm not sure if there's anything to really do about it. Other than maybe ignore the command failing. It's not like we can do anything about preprocessing object files anyway, those should already be contained in previously listed entries. I don't think we want to reimplement GCC command line parsing to do something more clever here. Maybe this is a bear/compiledb/whatever bug that such linking command is in the database to begin with. |
No it just generates this
I don't really think so, the compilation database is supposed to record the commands used for building. If one of these commands involves invoking the compiler with multiple input files, then this should also be recorded in the compilation database.
In this case this may work (i.e. it is not obviously not working). However a make file could simply be something like:
In this case we would completely ignore these two files. I don't think it is realistic to assume such things do not happen in larger projects. What about extracting all the |
The arguments above say
The strict assumption made by the compilation database format is that a single entry corresponds to a single This is why the problematic entry from above confuses me: it involves a lot of linker arguments (
Right, but it seems to me that in order to produce a valid compilation database where commands correspond to single files the database generators are supposed to handle the split themselves. Or if they cannot, then at least exit with an error instead of picking an arbitrary I'm guessing you've been using the direct Makefile build of
I do agree that it's quite bad if some files are ignored. I guess at least for the time being, this is never silent but fails preprocessing with the initially reported error. I'm not sure how far back we need to go with zstd, but maybe there's enough history afterwards where such mixed commands aren't used. I suppose something like that might work, although it would also significantly complicate the compilation database code even further, especially since the same logic should really be implemented both for |
I just tried with a manually written Makefile: all: main.c lib/lib.h lib/lib.c
gcc -DANSWER=42 -Ilib/ main.c lib/lib.c bear[
{
"arguments": [
"/usr/bin/x86_64-linux-gnu-gcc-11",
"-c",
"-DANSWER=42",
"-Ilib/",
"main.c"
],
"directory": "/home/simmo/Desktop/goblint-action-test/makefile-project",
"file": "/home/simmo/Desktop/goblint-action-test/makefile-project/main.c",
"output": "/home/simmo/Desktop/goblint-action-test/makefile-project/main.o"
},
{
"arguments": [
"/usr/bin/x86_64-linux-gnu-gcc-11",
"-c",
"-DANSWER=42",
"-Ilib/",
"lib/lib.c"
],
"directory": "/home/simmo/Desktop/goblint-action-test/makefile-project",
"file": "/home/simmo/Desktop/goblint-action-test/makefile-project/lib/lib.c",
"output": "/home/simmo/Desktop/goblint-action-test/makefile-project/lib/lib.o"
}
] So it does exactly what I expected above: the compilation of every file is properly decomposed into entries. Goblint analyzes this perfectly. compiledb[
{
"arguments": [
"/usr/bin/x86_64-linux-gnu-gcc-11",
"-c",
"-DANSWER=42",
"-Ilib/",
"main.c"
],
"directory": "/home/simmo/Desktop/goblint-action-test/makefile-project",
"file": "/home/simmo/Desktop/goblint-action-test/makefile-project/main.c",
"output": "/home/simmo/Desktop/goblint-action-test/makefile-project/main.o"
},
{
"directory": "/home/simmo/Desktop/goblint-action-test/makefile-project",
"arguments": [
"gcc",
"-DANSWER=42",
"-Ilib/",
"main.c",
"lib/lib.c"
],
"file": "lib/lib.c"
}
] It appears that it manages to decompose |
I just tried that zstd commit myself. Both CMake and bear seem to generate a compilation database that doesn't have such mixed entries. I've forgotten by now what your reason for preferring compiledb was, but if they all seem to have issues in certain cases, we should maybe have an issue to document the problems with all the generators in a single place. EDIT: Done here: #628. |
That sounded like a good idea, and I wanted to try this for the zstd benchmarking to avoid some of the problems. However, I think the problem with generating the compilation database through CMake is, that one cannot specify the target and instead it is generated for all. It seems that with with the target property |
That's a good point, although couldn't you just reconfigure the zstd CMake build to disable |
@stilscher discovered this issue with older versions of
zstd
(e.g.5c5c47633826426a3fcc717000a352d52bd0ac22
).The complication database in this case contains entries where the command specifies several
.c
files at the same time.Goblint in this case adds an
-E
flag and-o
to get preprocessor output. The preprocessor does not like this, and fails withThe text was updated successfully, but these errors were encountered: