Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
When trying to build the compile_commands.json target from an external
module's directory, the following error is displayed:
make[1]: *** No rule to make target 'scripts/clang-tools/gen_compile_commands.py',
needed by 'compile_commands.json'. Stop.
This appears to be because gen_compile_commands.py is looked up using
relative path, which doesn't exist from the module's source tree.
Prefixing the dependency with $(srctree) fixes the problem.
Signed-off-by: Alexandre Courbot <gnurou@gmail.com>
---
Makefile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Makefile b/Makefile
index 8ad55d6e7b60..52d7dfe4212a 100644
--- a/Makefile
+++ b/Makefile
@@ -1980,7 +1980,7 @@ nsdeps: modules
quiet_cmd_gen_compile_commands = GEN $@
cmd_gen_compile_commands = $(PYTHON3) $< -a $(AR) -o $@ $(filter-out $<, $(real-prereqs))
-$(extmod_prefix)compile_commands.json: scripts/clang-tools/gen_compile_commands.py \
+$(extmod_prefix)compile_commands.json: $(srctree)/scripts/clang-tools/gen_compile_commands.py \
$(if $(KBUILD_EXTMOD),, vmlinux.a $(KBUILD_VMLINUX_LIBS)) \
$(if $(CONFIG_MODULES), $(MODORDER)) FORCE
$(call if_changed,gen_compile_commands)
--
2.46.0
On Sat, Aug 3, 2024 at 9:52 PM Alexandre Courbot <gnurou@gmail.com> wrote:
>
> When trying to build the compile_commands.json target from an external
> module's directory, the following error is displayed:
>
> make[1]: *** No rule to make target 'scripts/clang-tools/gen_compile_commands.py',
> needed by 'compile_commands.json'. Stop.
Good catch.
But, to reproduce this, O= option is also needed, right?
e.g.
$ make O=path/to/build/dir M=path/to/external/module/dir
> This appears to be because gen_compile_commands.py is looked up using
> relative path, which doesn't exist from the module's source tree.
The phrase "appears to be ..." is somewhat modest.
You can reword this to pin-point the first bad commit.
For example:
gen_compile_commands.py was previously looked up using a relative path
to $(srctree), but commit b1992c3772e6 ("kbuild: use $(src) instead of
$(srctree)/$(src) for source directory") stopped defining VPATH for
external module builds.
> Prefixing the dependency with $(srctree) fixes the problem.
This needs back-porting.
Please add this:
Fixes: b1992c3772e6 ("kbuild: use $(src) instead of $(srctree)/$(src)
for source directory")
Thanks.
> Signed-off-by: Alexandre Courbot <gnurou@gmail.com>
> ---
> Makefile | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/Makefile b/Makefile
> index 8ad55d6e7b60..52d7dfe4212a 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -1980,7 +1980,7 @@ nsdeps: modules
> quiet_cmd_gen_compile_commands = GEN $@
> cmd_gen_compile_commands = $(PYTHON3) $< -a $(AR) -o $@ $(filter-out $<, $(real-prereqs))
>
> -$(extmod_prefix)compile_commands.json: scripts/clang-tools/gen_compile_commands.py \
> +$(extmod_prefix)compile_commands.json: $(srctree)/scripts/clang-tools/gen_compile_commands.py \
> $(if $(KBUILD_EXTMOD),, vmlinux.a $(KBUILD_VMLINUX_LIBS)) \
> $(if $(CONFIG_MODULES), $(MODORDER)) FORCE
> $(call if_changed,gen_compile_commands)
> --
> 2.46.0
>
--
Best Regards
Masahiro Yamada
On Sat, Aug 3, 2024 at 10:47 PM Masahiro Yamada <masahiroy@kernel.org> wrote:
>
> On Sat, Aug 3, 2024 at 9:52 PM Alexandre Courbot <gnurou@gmail.com> wrote:
> >
> > When trying to build the compile_commands.json target from an external
> > module's directory, the following error is displayed:
> >
> > make[1]: *** No rule to make target 'scripts/clang-tools/gen_compile_commands.py',
> > needed by 'compile_commands.json'. Stop.
>
>
> Good catch.
>
> But, to reproduce this, O= option is also needed, right?
>
> e.g.
>
> $ make O=path/to/build/dir M=path/to/external/module/dir
I am building the module as follows:
$ make -C ../linux/build M=$PWD modules compile_commands.json
The kernel itself was built with O=build though.
> > This appears to be because gen_compile_commands.py is looked up using
> > relative path, which doesn't exist from the module's source tree.
>
>
> The phrase "appears to be ..." is somewhat modest.
>
>
> You can reword this to pin-point the first bad commit.
>
>
> For example:
>
> gen_compile_commands.py was previously looked up using a relative path
> to $(srctree), but commit b1992c3772e6 ("kbuild: use $(src) instead of
> $(srctree)/$(src) for source directory") stopped defining VPATH for
> external module builds.
Thanks, that's much better. I should indeed have bisected to find the
source of the regression.
>
>
>
> > Prefixing the dependency with $(srctree) fixes the problem.
>
>
>
> This needs back-porting.
>
>
> Please add this:
>
> Fixes: b1992c3772e6 ("kbuild: use $(src) instead of $(srctree)/$(src)
> for source directory")
Done, and sent v2 as well.
Thank you!
Alex.
On Sun, Aug 4, 2024 at 2:51 PM Alexandre Courbot <gnurou@gmail.com> wrote: > > On Sat, Aug 3, 2024 at 10:47 PM Masahiro Yamada <masahiroy@kernel.org> wrote: > > > > On Sat, Aug 3, 2024 at 9:52 PM Alexandre Courbot <gnurou@gmail.com> wrote: > > > > > > When trying to build the compile_commands.json target from an external > > > module's directory, the following error is displayed: > > > > > > make[1]: *** No rule to make target 'scripts/clang-tools/gen_compile_commands.py', > > > needed by 'compile_commands.json'. Stop. > > > > > > Good catch. > > > > But, to reproduce this, O= option is also needed, right? > > > > e.g. > > > > $ make O=path/to/build/dir M=path/to/external/module/dir > > I am building the module as follows: > > $ make -C ../linux/build M=$PWD modules compile_commands.json OK, this is equivalent to the command I gave. You are building your external module against the kernel built in a separate output directory. -- Best Regards Masahiro Yamada
© 2016 - 2025 Red Hat, Inc.