Skip to content

Commit a4ab14e

Browse files
johnhubbardmasahir0y
authored andcommitted
gen_compile_commands: handle multiple lines per .mod file
scripts/clang-tools/gen_compile_commands.py incorrectly assumes that each .mod file only contains one line. That assumption was correct when the script was originally created, but commit 9413e76 ("kbuild: split the second line of *.mod into *.usyms") changed the .mod file format so that there is one entry per line, and potentially many lines. The problem can be reproduced by using Kbuild to generate compile_commands.json, like this: make CC=clang compile_commands.json In many cases, the problem might be overlooked because many subsystems only have one line anyway. However, in some subsystems (Nouveau, with 762 entries, is a notable example) it results in skipping most of the subsystem. Fix this by fully processing each .mod file. Fixes: 9413e76 ("kbuild: split the second line of *.mod into *.usyms") Signed-off-by: John Hubbard <jhubbard@nvidia.com> Reviewed-by: Nick Desaulniers <ndesaulniers@google.com> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
1 parent 03c765b commit a4ab14e

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

scripts/clang-tools/gen_compile_commands.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,10 +157,10 @@ def cmdfiles_for_modorder(modorder):
157157
if ext != '.ko':
158158
sys.exit('{}: module path must end with .ko'.format(ko))
159159
mod = base + '.mod'
160-
# The first line of *.mod lists the objects that compose the module.
160+
# Read from *.mod, to get a list of objects that compose the module.
161161
with open(mod) as m:
162-
for obj in m.readline().split():
163-
yield to_cmdfile(obj)
162+
for mod_line in m:
163+
yield to_cmdfile(mod_line.rstrip())
164164

165165

166166
def process_line(root_directory, command_prefix, file_path):

0 commit comments

Comments
 (0)