Sourcetrail
Sourcetrail copied to clipboard
"unable to handle compilation, expected exactly one compiler job in '''' " for all files
Platform: Linux 5.4.0-73-generic #82~18.04.1-Ubuntu SMP
Sourcetrail version: 2021.1.30 64 Bit, database version 25
Each file fails with two errors:
-
no input files
-
unable to handle compilation, expected exactly one compiler job in ''''
This happens on all files when I try to import the project.
Here's an excerpt from my compile_commands.json
for one of the files:
{
"directory": "/home/user/projects/the_project",
"arguments": [
"/usr/bin/gcc",
"-D_DEBUG",
"-DINT_178B_FULL",
"-Dgcc",
"-Doffsetof=__builtin_offsetof",
"-DASSERT_STATIC(x)=_Static_assert(x,#x)",
"-D__LANGUAGE_C__",
"-D__ARMv8__",
"-D__CHAR_BIT=8",
"-D__SHRT_BIT=16",
"-D__INT_BIT=32",
"-D__LONG_BIT=64",
"-D__LLONG_BIT=64",
"-D__REG_BIT=64",
"-I/home/user/projects/ghs/integrity178_rtos/int178/middleware/msp_posix_cxx/INTEGRITY-include-full",
"-Isrc/uart/INTEGRITY178",
"-Isrc/i2c/zynqmp",
"-Isrc/i2c/INTEGRITY178",
"-Isrc/i2c",
"-I/home/user/projects/the_project/dist/arm64///include",
"-I/home/user/projects/the_project/dist/arm64//include",
"-I/home/user/projects/the_project/inc/",
"-I/home/user/projects/the_project/src/",
"-I/home/user/projects/ghs/integrity178_rtos/int178/rtos/rtos-i40-178B-zynq-ultrascale-04152020/rtos/zynq-ultrascale",
"-I/home/user/projects/ghs/integrity178_rtos/int178/rtos/rtos-i40-178B-zynq-ultrascale-04152020/rtos/bsp",
"-I/home/user/projects/ghs/integrity178_rtos/int178/rtos/rtos-i40-178B-zynq-ultrascale-04152020/rtos/ansi",
"-I/home/user/projects/ghs/integrity178_rtos/int178/rtos/rtos-i40-178B-zynq-ultrascale-04152020/rtos/asp",
"-I/home/user/projects/ghs/integrity178_rtos/int178/rtos/rtos-i40-178B-zynq-ultrascale-04152020/rtos/INTEGRITY-include-full",
"-I/home/user/projects/ghs/integrity178_rtos/int178/rtos/rtos-i40-178B-zynq-ultrascale-04152020/rtos/INTEGRITY-include",
"-isystem/home/user/projects/the_project/INCLUDES_FROM_DOCKER/opt/ghs/comp/ansi",
"-std=gnu99",
"-o",
"/home/user/projects/the_project/obj/arm64/uart/uartCommon.o"
],
"file": "/home/user/projects/the_project/src/uart/uartCommon.c"
},
I know that the compile_commands.json
file is correct, since it works with my IDE clion perfectly (it indexes just fine, references work, macros expand, etc).
Does it work if you remove the "/usr/bin/gcc"
argument?
No, it's the same error still :frowning_face:
@mlangkabel Is there any way for me to debug this further? I looked into the log file but there wasn't anything useful in there.
It is a Clang issue. If I google for it, I get lots of results. Maybe there is something in there that helps you. My next guess is that it doesn't like the "-o"
and "/home/user/projects/the_project/obj/arm64/uart/uartCommon.o"
arguments to be split. To be sure, you could remove them entirely, because Sourcetrail would skip generating that output file anyways. It could also be that Sourcetrail doesn't like the compile command format. How did you generate your compile_commands.json
file? There is also this format:
[
{ "directory": "/home/user/llvm/build",
"command": "/usr/bin/clang++ -Irelative -DSOMEDEF=\"With spaces, quotes and \\-es.\" -c -o file.o file.cc",
"file": "file.cc" },
...
]
Here the path to the compiled file is included in the "command".
It is a Clang issue. If I google for it, I get lots of results. Maybe there is something in there that helps you.
Yeah I did google for it, but I didn't see anything pertaining to Sourcetrail or compiledb...
My next guess is that it doesn't like the "-o"
Removing the split, or removing it entirely doesn't affect the error either :frowning:
How did you generate your compile_commands.json file?
I'm creating it myself based on another compiler (GreenHill's ARM C compiler) because other applications don't seem to like it. Basically converting their CLI parameters into what gcc
does.
There is also this format:
I also tried that format, same result
Is there more verbose debugging I can enable? In the logs there is
14:26:03 | 140477201748736 | InterprocessIndexer.cpp:61 work() | INFO: 1 fetched indexer command for "/home/user/projects/ghs/the_project/src/uart/uartCommon.c"
14:26:03 | 140477201748736 | InterprocessIndexer.cpp:64 work() | INFO: 1 indexer commands left: 0
14:26:03 | 140477201748736 | InterprocessIndexer.cpp:85 work() | INFO: 1 updating indexer status with currently indexed filepath
14:26:03 | 140477201748736 | InterprocessIndexer.cpp:89 work() | INFO: 1 starting to index current file
14:26:03 | 140477201748736 | CxxParser.cpp:193 runTool() | INFO: Clang Invocation:
14:26:03 | 140477201748736 | CxxParser.cpp:197 runTool() | INFO: Clang Invocation errors: error: no input files
but that doesn't really help much when trying to figure out what's breaking
It is a Clang issue.
I also just tried using the clang interface for python (https://pypi.org/project/libclang/) and it parses things just fine, so I feel like the issue is on the sourcetrail side? I'm not fully exercising the clang interface though
>>> from clang import cindex
>>> compdb = cindex.CompilationDatabase.fromDirectory('.')
>>> print([i.filename for i in compdb.getAllCompileCommands()])
['/home/user/projects/ghs/the_project/src/uart/uartCommon.c', etc...]
>>>
Hello, I encountered the same issue right now. Solution for me was simply removing the "-o" argument from the compiler flags.
Update: This issue seems to come if the compiler used by sourcetrail does not know a specific compiler flag.
That's strange, I get the exact same errors even when using the simplest compile_commands file:
[
{
"directory": "/home/user/projects/the_project",
"file": "./src/uart/uartCommon.c",
"arguments": [
"/usr/bin/gcc",
"-o",
"obj/arm64/uart/uartCommon.o"
]
}
]
Removing the -o
and obj/arm64/uart/uartCommon.o
args also gives the exact same errors.
You could try to setup the sourcetrail project manually:
then simply select all needed sources and paste the compiler flags from your json file like this:
(note here I had to remove the -o and path to object file)
last step is searching and adding all include paths.