amezin / vscode-linux-kernel

Visual Studio Code project/compile_commands.json generator for Linux kernel sources and out-of-tree modules

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Fails to create compile_commands for out of tree module

jrpear opened this issue · comments

Summary

Generating a compile_commands.json file for kernel module development per the README throws an error ValueError: Chunksize must be 1+, not 0.

Steps to reproduce

  1. Clone the kernel I'm using from https://git.archlinux.org/linux.git (you can probably just use whichever you want but I'm trying to be exhaustive here)
  2. Check out the tag I'm using with git checkout v5.11.13-arch1
  3. Use default config make O=$BUILDDIR defconfig (I'm on x86_64)
  4. Add local version if you'd like (I did this)
  5. Build kernel cd $BUILDDIR && make -j8
  6. Clone hello world kernel module (from LDD3) somewhere else git clone https://github.com/jpear1/hello-module.git
  7. Observe this module builds normally with make -C $BUILDDIR M=$PWD modules. Optionally make clean after.
  8. Clone vscode-linux-kernel per README: git clone git@github.com:amezin/vscode-linux-kernel.git .vscode
  9. Attempt to generate compile_commands per README: python .vscode/generate_compdb.py -O $BUILDDIR $PWD
  10. Observe error:
Building *.o.cmd file list...
Parsing *.o.cmd files...
Traceback (most recent call last):------------------] 0.0%
  File "/home/jack/scratch/hello/.vscode/generate_compdb.py", line 88, in <module>
    main()
  File "/home/jack/scratch/hello/.vscode/generate_compdb.py", line 84, in main
    gen_compile_commands(**vars(cmd_parser.parse_args()))
  File "/home/jack/scratch/hello/.vscode/generate_compdb.py", line 64, in gen_compile_commands
    for compdb_chunk in pool.imap_unordered(functools.partial(parse_cmd_file, out_dir), cmd_files, chunksize=int(math.sqrt(len(cmd_files)))):
  File "/usr/lib/python3.9/multiprocessing/pool.py", line 437, in imap_unordered
    raise ValueError(
ValueError: Chunksize must be 1+, not 0

Other info

Python version: 3.9.3
GNU Make version: 4.3
GCC version: 10.2.0

ValueError: Chunksize must be 1+, not 0

It's probably because there are no *.o.cmd files in $PWD. You should not run make clean before generate_compdb.py - make clean removes *.o.cmd files that generate_compdb.py reads. When I repeat the same steps without make clean, I get non-empty compile_commands.json.

Yep, this was the problem. Thanks!