Subject: [PATCH] scripts/Makefile.build: fix ext mod subdirs build with separate src,build dirs

The change allow to build external modules with nested makefiles.
Current unofficial way(using "src" variable) allow to build
external(out of tree) kernel module with separating source and build
artifacts dirs but with nested makefiles it doesn't work properly.
Build system trap to recursion inside makefiles, articafts output dir
path grow with each iteration until exceed max path len and build failed
This fix update "src" var during processing subdirs and resolve
recursion issue
Usage example:
make -C KERNEL_SOURCE_TREE M=BUILD_OUT_DIR src=EXT_MOD_SRC_DIR modules

Cc: Valerii Chernous <[email protected]>
Cc: [email protected]
Signed-off-by: Valerii Chernous <[email protected]>
---
scripts/Makefile.build | 1 +
1 file changed, 1 insertion(+)

diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index a293950e2e07..75ea9052ea4a 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -490,6 +490,7 @@ $(single-subdir-goals): $(single-subdirs)
PHONY += $(subdir-ym)
$(subdir-ym):
$(Q)$(MAKE) $(build)=$@ \
+ $(if $(findstring command line,$(origin src)),src=$(patsubst $(obj)/%,$(src)/%,$@)) \
need-builtin=$(if $(filter $@/built-in.a, $(subdir-builtin)),1) \
need-modorder=$(if $(filter $@/modules.order, $(subdir-modorder)),1) \
$(filter $@/%, $(single-subdir-goals))
--
2.35.6



2024-04-15 10:33:38

by Masahiro Yamada

[permalink] [raw]
Subject: Re: [PATCH] scripts/Makefile.build: fix ext mod subdirs build with separate src,build dirs

On Mon, Apr 15, 2024 at 7:14 PM Valerii Chernous <[email protected]> wrote:
>
> The change allow to build external modules with nested makefiles.
> Current unofficial way(using "src" variable) allow to build
> external(out of tree) kernel module with separating source and build
> artifacts dirs but with nested makefiles it doesn't work properly.
> Build system trap to recursion inside makefiles, articafts output dir
> path grow with each iteration until exceed max path len and build failed
> This fix update "src" var during processing subdirs and resolve
> recursion issue
> Usage example:
> make -C KERNEL_SOURCE_TREE M=BUILD_OUT_DIR src=EXT_MOD_SRC_DIR modules
>
> Cc: Valerii Chernous <[email protected]>
> Cc: [email protected]
> Signed-off-by: Valerii Chernous <[email protected]>


NACK.

Please do not send hacks over again.










> ---
> scripts/Makefile.build | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/scripts/Makefile.build b/scripts/Makefile.build
> index a293950e2e07..75ea9052ea4a 100644
> --- a/scripts/Makefile.build
> +++ b/scripts/Makefile.build
> @@ -490,6 +490,7 @@ $(single-subdir-goals): $(single-subdirs)
> PHONY += $(subdir-ym)
> $(subdir-ym):
> $(Q)$(MAKE) $(build)=$@ \
> + $(if $(findstring command line,$(origin src)),src=$(patsubst $(obj)/%,$(src)/%,$@)) \
> need-builtin=$(if $(filter $@/built-in.a, $(subdir-builtin)),1) \
> need-modorder=$(if $(filter $@/modules.order, $(subdir-modorder)),1) \
> $(filter $@/%, $(single-subdir-goals))
> --
> 2.35.6
>


--
Best Regards
Masahiro Yamada

Subject: Re: [PATCH] scripts/Makefile.build: fix ext mod subdirs build with separate src,build dirs

Hi Masahiro,

As I understand second patch is even worse compare to first one, correct?

> On Mon, Apr 15, 2024 at 7:14 PM Valerii Chernous <[email protected]> wrote:
> >
> > The change allow to build external modules with nested makefiles.
> > Current unofficial way(using "src" variable) allow to build
> > external(out of tree) kernel module with separating source and build
> > artifacts dirs but with nested makefiles it doesn't work properly.
> > Build system trap to recursion inside makefiles, articafts output dir
> > path grow with each iteration until exceed max path len and build failed
> > This fix update "src" var during processing subdirs and resolve
> > recursion issue
> > Usage example:
> > make -C KERNEL_SOURCE_TREE M=BUILD_OUT_DIR src=EXT_MOD_SRC_DIR modules
> >
> > Cc: Valerii Chernous <[email protected]>
> > Cc: [email protected]
> > Signed-off-by: Valerii Chernous <[email protected]>

> NACK.

> Please do not send hacks over again.

Maybe, you can share some idea how to implement required for me functionality
into proper way?
Maybe you can point me to some part of code where you expected to see changes to
provide functionality that required for me?

Best regards,
Valerii

________________________________________
From: Masahiro Yamada <[email protected]>
Sent: Monday, April 15, 2024 12:32 PM
To: Valerii Chernous -X (vchernou - GLOBALLOGIC INC at Cisco)
Cc: Nathan Chancellor; Nicolas Schier; xe-linux-external(mailer list); [email protected]; [email protected]
Subject: Re: [PATCH] scripts/Makefile.build: fix ext mod subdirs build with separate src,build dirs

On Mon, Apr 15, 2024 at 7:14 PM Valerii Chernous <[email protected]> wrote:
>
> The change allow to build external modules with nested makefiles.
> Current unofficial way(using "src" variable) allow to build
> external(out of tree) kernel module with separating source and build
> artifacts dirs but with nested makefiles it doesn't work properly.
> Build system trap to recursion inside makefiles, articafts output dir
> path grow with each iteration until exceed max path len and build failed
> This fix update "src" var during processing subdirs and resolve
> recursion issue
> Usage example:
> make -C KERNEL_SOURCE_TREE M=BUILD_OUT_DIR src=EXT_MOD_SRC_DIR modules
>
> Cc: Valerii Chernous <[email protected]>
> Cc: [email protected]
> Signed-off-by: Valerii Chernous <[email protected]>


NACK.

Please do not send hacks over again.










> ---
> scripts/Makefile.build | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/scripts/Makefile.build b/scripts/Makefile.build
> index a293950e2e07..75ea9052ea4a 100644
> --- a/scripts/Makefile.build
> +++ b/scripts/Makefile.build
> @@ -490,6 +490,7 @@ $(single-subdir-goals): $(single-subdirs)
> PHONY += $(subdir-ym)
> $(subdir-ym):
> $(Q)$(MAKE) $(build)=$@ \
> + $(if $(findstring command line,$(origin src)),src=$(patsubst $(obj)/%,$(src)/%,$@)) \
> need-builtin=$(if $(filter $@/built-in.a, $(subdir-builtin)),1) \
> need-modorder=$(if $(filter $@/modules.order, $(subdir-modorder)),1) \
> $(filter $@/%, $(single-subdir-goals))
> --
> 2.35.6
>


--
Best Regards
Masahiro Yamada