nickdiego / compiledb

Tool for generating Clang's JSON Compilation Database files for make-based build systems.
GNU General Public License v3.0
1.38k stars 123 forks source link

compiledb not working with linux kernel #85

Open seujza opened 5 years ago

seujza commented 5 years ago

Hi, when I exec compiledb -n make in Linux kernel source code,It's not working there is the log Thanks!

/usr1/jza/linux-5.2.15$ compiledb -n make
Traceback (most recent call last):
  File "/home/jza/.local/bin/compiledb", line 11, in <module>
    sys.exit(cli())
  File "/home/jza/.local/lib/python3.5/site-packages/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/home/jza/.local/lib/python3.5/site-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/home/jza/.local/lib/python3.5/site-packages/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/jza/.local/lib/python3.5/site-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/jza/.local/lib/python3.5/site-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/home/jza/.local/lib/python3.5/site-packages/click/decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/home/jza/.local/lib/python3.5/site-packages/compiledb/commands/make.py", line 98, in command
    done = generate(**args)
  File "/home/jza/.local/lib/python3.5/site-packages/compiledb/__init__.py", line 106, in generate
    command_style=command_style)
  File "/home/jza/.local/lib/python3.5/site-packages/compiledb/__init__.py", line 54, in generate_json_compdb
    use_full_path=use_full_path, command_style=command_style)
  File "/home/jza/.local/lib/python3.5/site-packages/compiledb/parser.py", line 89, in parse_build_log
    while (line.endswith('\\\n')):
TypeError: endswith first arg must be bytes or a tuple of bytes, not str
jza@dyjza00001:/usr1/jza/linux-5.2.15$ ***
*** Configuration file ".config" not found!
***
*** Please run some configurator (e.g. "make oldconfig" or
*** "make menuconfig" or "make xconfig").
***
Petross404 commented 4 years ago

What happens if you run make menuconfig first?

kloenk commented 4 years ago

Also fails with compiledb -n make O=build after running `make O=build defconfig

artisdom commented 3 years ago

Linux kernel comes with "scripts/clang-tools/gen_compile_commands.py" that can generate "compile_commands.json" by parsing ".cmd" files.

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=b30204640192234d18f9168f19f9cd693485b86d

rcorre commented 7 months ago

I've had success with gen_compile_commands.py. However, it requires you to run a full build first, which takes a while. I was hoping compiledb -n could make this faster, but I get this, even though I have generated a config and running make LLVM=1 -k itself works fine:

$ compiledb -n make LLVM=1
***
*** Configuration file ".config" not found!
***
*** Please run some configurator (e.g. "make oldconfig" or
*** "make menuconfig" or "make xconfig").
***
make[1]: *** [/home/rrc/src/linux/Makefile:776: .config] Error 1
make[1]: Failed to remake makefile 'include/config/auto.conf.cmd'.
make[1]: Failed to remake makefile 'include/config/auto.conf'.
make: *** [Makefile:240: __sub-make] Error 2
rcorre commented 7 months ago

The issue seems to be the -B flag. It seems like compiledb tries to work around this, but the workaround isn't working for the linux kernel: https://github.com/nickdiego/compiledb/blob/master/compiledb/commands/make.py#L13

CS-liujf commented 6 months ago

I've had success with gen_compile_commands.py. However, it requires you to run a full build first, which takes a while. I was hoping compiledb -n could make this faster, but I get this, even though I have generated a config and running make LLVM=1 -k itself works fine:

$ compiledb -n make LLVM=1
***
*** Configuration file ".config" not found!
***
*** Please run some configurator (e.g. "make oldconfig" or
*** "make menuconfig" or "make xconfig").
***
make[1]: *** [/home/rrc/src/linux/Makefile:776: .config] Error 1
make[1]: Failed to remake makefile 'include/config/auto.conf.cmd'.
make[1]: Failed to remake makefile 'include/config/auto.conf'.
make: *** [Makefile:240: __sub-make] Error 2

I encounter the same problem with compiledb -n make bzImage