Fails to create compile_commands for out of tree module
jrpear opened this issue · comments
Jack Pearson commented
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
- 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)
- Check out the tag I'm using with
git checkout v5.11.13-arch1
- Use default config
make O=$BUILDDIR defconfig
(I'm on x86_64) - Add local version if you'd like (I did this)
- Build kernel
cd $BUILDDIR && make -j8
- Clone hello world kernel module (from LDD3) somewhere else
git clone https://github.com/jpear1/hello-module.git
- Observe this module builds normally with
make -C $BUILDDIR M=$PWD modules
. Optionallymake clean
after. - Clone vscode-linux-kernel per README:
git clone git@github.com:amezin/vscode-linux-kernel.git .vscode
- Attempt to generate compile_commands per README:
python .vscode/generate_compdb.py -O $BUILDDIR $PWD
- 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
Aleksandr Mezin commented
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
.
Jack Pearson commented
Yep, this was the problem. Thanks!