rizsotto / scan-build

Clang's scan-build re-implementation in python

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

intercept-build produces empty compilation database file on macOS

stanislaw opened this issue · comments

I apologize if the following issue that I am reporting is caused by my misunderstanding of how I should use the intercept-build tool.

I am on macOS 10.14.6 (18G1012).

Input main.c file:

int main() {
  return 0;
}

Command:

$ intercept-build clang -g -O2 main.c

Output:

$ cat compile_commands.json
[]Stanislaw@home:tmp $

Info about scan-build:

$ pip show intercept-build
WARNING: Package(s) not found: intercept-build
Stanislaw@home:tmp $ pip show scan-build
Name: scan-build
Version: 2.0.18
Summary: static code analyzer wrapper for Clang.
Home-page: https://github.com/rizsotto/scan-build
Author: László Nagy
Author-email: rizsotto@gmail.com
License: LICENSE.txt
Location: /Users/Stanislaw/.pyenv/versions/3.5.4/lib/python3.5/site-packages
Requires: typing
Required-by:

I think I have found something that almost works:

intercept-build --use-cc /opt/llvm-3.9.0/bin/clang intercept-cc -g -O0 main.c
cat compile_commands.json
[
    {
        "arguments": [
            "cc",
            "-c",
            "-g",
            "-O0",
            "main.c"
        ],
        "directory": "/sandbox/scan-build-sandbox",
        "file": "main.c"
    }
]Stanislaw@home:scan-build-sandbox (master)*$

I can confirm that the file gets compiled with Clang 3.9. But I am wondering why the compilation database still shows cc as the first argument. I have tried all possible combinations and available arguments and the cc is always there.

Any advice?

Hey @stanislaw , the direct compiler call is not a supported use case unfortunately.

Your workarounds could be:

  • ask Clang to emit the entry for you.
  • execute from shell CC=/opt/llvm-3.9.0/bin/clang sh -c "$CC -g -O0 main.c"