Skip to content

json-compilation-database: Error while opening JSON database: Not a directory #1809

@max-kamps

Description

@max-kamps

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions