When I pass a compilation database to c2rust (running LLVM 22.1.5 on Linux), the following message is repeated for every input file:
Error while trying to load a compilation database:
Could not auto-detect compilation database from directory "/projectdir/compile_commands.json"
No compilation database found in /projectdir/compile_commands.json or any parent directory
json-compilation-database: Error while opening JSON database: Not a directory
fixed-compilation-database: Error while opening fixed database: Not a directory
Running without flags.
And indeed, none of the flags in the compilation database are used, causing errors.
Debugging a bit, it seems the way c2rust passes the build file to libtooling (-p <path-to-json-file>) is incorrect, at least for LLVM 22. It expects the build path passed in with -p to be a directory containing compile_commands.json.
CompilationDatabase::autoDetectFromDirectory seems to be the relevant function here.
When I pass a compilation database to c2rust (running LLVM 22.1.5 on Linux), the following message is repeated for every input file:
And indeed, none of the flags in the compilation database are used, causing errors.
Debugging a bit, it seems the way c2rust passes the build file to libtooling (
-p <path-to-json-file>) is incorrect, at least for LLVM 22. It expects the build path passed in with -p to be a directory containing compile_commands.json.CompilationDatabase::autoDetectFromDirectoryseems to be the relevant function here.