Closed grezp closed 2 years ago
Thanks for the report @grezp . Will try to look at it later this week.
What is the project you trying to build? Is that accessible on github?
@rizsotto, unfortunately the project is not available on github.
Please let me know if there any other information I can provide. I've been scratching my head on this for a while now.
I was running through a similar problem.
bear -- make
returned a nice compile_commands.json
file.[]
.I noticed that if make
has nothing to do because no prerequisites have changed, then it won't be able to intercept any build process. So I removed my target directory with all my binaries and ran bear -- make
again, that worked just fine!
Thanks for the feedback @fnune. I think this is not the case for @grezp, he runs make clean
before running Bear.
@grezp I found out why the result is empty for your case... It's not a bug, it's a feature! :smile:
Your build contains 4 /usr/bin/g++
executions:
src/RfApps.cpp
and creates RfApps.cpp.pre
, RfApps.cpp.Td
files. This usage is not considered as compilation, since it is just calling the preprocessor.RfApps.cpp.ii.cpp
to RfApps.cpp.ii.o
. This is a compilation, should go to the final output.RfApps.cpp.mid.cpp
to RfApps.cpp.mid.o
. This is a compilation too, should go to the final output.This is reported in the final lines as compilation entries created. [size: 2]
and compilation entries to output. [size: 2]
. But there are commands which are removing the source files of the compilation rm .../RfApps.cpp.ii.cpp
and rm .../RfApps.cpp.mid.cpp
. Bear is filtering out these because the source file is not exists for those compilations. (And the usability of the compilation database would be zero. You can't run any tooling against the source files, because they are not exists.)
You can enable to include non-existing files in the output. See man citnames
how to do that.
@rizsotto, I created a citnames config file and changed include_only_existing_source to false.
{
"compilation": {
"compilers_to_recognize": [
{
"executable": "/usr/bin/mpicc",
"flags_to_add": ["-I/opt/MPI/include"],
"flags_to_remove": ["-Wall"]
}
],
"compilers_to_exclude": []
},
"output": {
"content": {
"include_only_existing_source": false, <------
"paths_to_include": [],
"paths_to_exclude": []
},
"format": {
"command_as_array": true,
"drop_output_field": false
}
}
}
Unfortunately, now I don't get a compile_commands.json using the following command:
bear --citnames --config=./cit-config -- make all
man citnames
doesn't tell me to use an =
sign. If I don't include the =
sign, I will get the following error:
Unrecognized parameter: "./cit-config"
Usage: bear [--output <arg>] [--verbose] -- ...
Am I executing this correctly?
@grezp the Bear call is not correct. (bear --help
or man bear
can always help.)
bear --config ./cit-config -- make all
would be the correct call. If you specify --citnames
then you need to give a file path to it. You gave --config=./cit-config
as the file path, which is incorrect.
bear
and citnames
takes the same config file, and in both cases you just need to specify it as --config config.json
.
@rizsotto, Sorry to keep bugging you but this still gives me an empty compile_commands.json. I've tried using the --force-wrapper and --force-preload options, but that doesn't seem to help.
Any other suggestions I can try?
Could you send me the event file? Run make clean && intercept -- make all
. That will create a big JSON file, which I can try to feed to citnames
on my machine.
@rizsotto, here's a link to the file: events.json
Thanks @grezp !!!
I've just executed citnames --input events.json
and got this output.
[
{
"arguments": [
"/usr/bin/g++",
"-c",
"-fpreprocessed",
"-m64",
"-std=c++1y",
"-I/u/USERNAME/projects/PROJ_NAME/RfAppsLib/inc",
"-I/u/USERNAME/projects/upg/tmp/tmp37/Libraries/CoreLib",
"-I/u/USERNAME/projects/upg/tmp/tmp37/Libraries/CoreLib/src",
"-I/u/USERNAME/projects/upg/tmp/tmp37/Libraries/CoreLib/inc",
"-I/u/USERNAME/projects/upg/tmp/tmp37/Libraries/CoreLib/IQModulatorCal",
"-I/ltx/customer/unison/ltx/methods",
"-I/ltx/customer/unison/ltx/methods/LTXCCoreMethods",
"-I/ltx/customer/unison/ltx/methods/LTXCDatalogMethods",
"-I/ltx/customer/unison/ltx/methods/LTXCSystemEnums",
"-I/ltx/customer/unison/ltx/methods/LTXCBIFGroups",
"-I/opt/ltx/releases/U1909.WW20220119/updates/185300/x86_64_linux_3.10.0/unison/ltx/include",
"-I/opt/ltx/releases/U1909.WW20220119/updates/185300/x86_64_linux_3.10.0/plugins/generic/required/pdadd/1.22.19/include",
"-I/opt/ltx/releases/U1909.WW20220119/updates/185300/x86_64_linux_3.10.0/plugins/generic/required/psm/1.22.19/include",
"-I/opt/ltx/releases/U1909.WW20220119/updates/185300/x86_64_linux_3.10.0/plugins/generic/required/rf_apps_support/1.22.19/include",
"-I/opt/ltx/releases/U1909.WW20220119/updates/185300/x86_64_linux_3.10.0/plugins/generic/required/thor/1.22.19/include",
"-I/opt/ltx/releases/U1909.WW20220119/updates/185300/x86_64_linux_3.10.0/plugins/generic/required/ucst/1.22.19/include",
"-I/opt/ltx/releases/U1909.WW20220119/updates/185300/x86_64_linux_3.10.0/plugins/generic/required/unison_mod_demod/1.22.19/include",
"-fPIC",
"-Wwrite-strings",
"-fnon-call-exceptions",
"-fcheck-new",
"-Werror",
"-Wreturn-type",
"-g",
"-DDEBUG",
"-o",
"build/build/RfAppsLib/x86_64_linux_3.10.0/RfApps.cpp.ii.o",
"build/build/RfAppsLib/x86_64_linux_3.10.0/RfApps.cpp.ii.cpp"
],
"directory": "/u/USERNAME/projects/PROJ_NAME/RfAppsLib",
"file": "/u/USERNAME/projects/PROJ_NAME/RfAppsLib/build/build/RfAppsLib/x86_64_linux_3.10.0/RfApps.cpp.ii.cpp",
"output": "/u/USERNAME/projects/PROJ_NAME/RfAppsLib/build/build/RfAppsLib/x86_64_linux_3.10.0/RfApps.cpp.ii.o"
},
{
"arguments": [
"/usr/bin/g++",
"-c",
"-m64",
"-std=c++1y",
"-I/u/USERNAME/projects/PROJ_NAME/RfAppsLib/inc",
"-I/u/USERNAME/projects/upg/tmp/tmp37/Libraries/CoreLib",
"-I/u/USERNAME/projects/upg/tmp/tmp37/Libraries/CoreLib/src",
"-I/u/USERNAME/projects/upg/tmp/tmp37/Libraries/CoreLib/inc",
"-I/u/USERNAME/projects/upg/tmp/tmp37/Libraries/CoreLib/IQModulatorCal",
"-I/ltx/customer/unison/ltx/methods",
"-I/ltx/customer/unison/ltx/methods/LTXCCoreMethods",
"-I/ltx/customer/unison/ltx/methods/LTXCDatalogMethods",
"-I/ltx/customer/unison/ltx/methods/LTXCSystemEnums",
"-I/ltx/customer/unison/ltx/methods/LTXCBIFGroups",
"-I/opt/ltx/releases/U1909.WW20220119/updates/185300/x86_64_linux_3.10.0/unison/ltx/include",
"-I/opt/ltx/releases/U1909.WW20220119/updates/185300/x86_64_linux_3.10.0/plugins/generic/required/pdadd/1.22.19/include",
"-I/opt/ltx/releases/U1909.WW20220119/updates/185300/x86_64_linux_3.10.0/plugins/generic/required/psm/1.22.19/include",
"-I/opt/ltx/releases/U1909.WW20220119/updates/185300/x86_64_linux_3.10.0/plugins/generic/required/rf_apps_support/1.22.19/include",
"-I/opt/ltx/releases/U1909.WW20220119/updates/185300/x86_64_linux_3.10.0/plugins/generic/required/thor/1.22.19/include",
"-I/opt/ltx/releases/U1909.WW20220119/updates/185300/x86_64_linux_3.10.0/plugins/generic/required/ucst/1.22.19/include",
"-I/opt/ltx/releases/U1909.WW20220119/updates/185300/x86_64_linux_3.10.0/plugins/generic/required/unison_mod_demod/1.22.19/include",
"-fPIC",
"-Wwrite-strings",
"-fnon-call-exceptions",
"-fcheck-new",
"-Werror",
"-Wreturn-type",
"-O2",
"-DNDEBUG",
"-o",
"build/build/RfAppsLib/x86_64_linux_3.10.0/RfApps.cpp.mid.o",
"build/build/RfAppsLib/x86_64_linux_3.10.0/RfApps.cpp.mid.cpp"
],
"directory": "/u/USERNAME/projects/PROJ_NAME/RfAppsLib",
"file": "/u/USERNAME/projects/PROJ_NAME/RfAppsLib/build/build/RfAppsLib/x86_64_linux_3.10.0/RfApps.cpp.mid.cpp",
"output": "/u/USERNAME/projects/PROJ_NAME/RfAppsLib/build/build/RfAppsLib/x86_64_linux_3.10.0/RfApps.cpp.mid.o"
}
]
@rizsotto that works!!!
Thank you so much for all your time and effort. I really appreciate it.
Describe the bug As the tittle suggest, when I compile my code using
make all
bear creates an empty compile_commands.json file with only[]
. However, when I introduce an error (e.g. remove a semicolon) then I will get a partial compile_commands.json file.To Reproduce
Environment:
bear —verbose -- make all
output: