* [PATCH] kbuild: warn a relative path used for M= in out-of-tree builds
@ 2021-01-20 19:31 Masahiro Yamada
2021-01-20 19:46 ` Will McVicker
0 siblings, 1 reply; 2+ messages in thread
From: Masahiro Yamada @ 2021-01-20 19:31 UTC (permalink / raw)
To: linux-kbuild; +Cc: Will McVicker, Masahiro Yamada, Michal Marek, linux-kernel
Surprising to me, Kbuild can handle a relative M= path while having
in-kernel objects in a separate directory. In this case, the M= option
actually defines:
- the path to external module sources relative to $(srctree)
- the path to external module objects relative to $(objtree)
For example,
make O=foo/bar M=baz
... will find the source files in baz, and create objects in foo/bar/baz.
Currently, it works like that because of the presence of VPATH and
--include-dir=$(abs_srctree), but this behavior is subtle and cannot
be guaranteed in the future. I do not know if it was even officially
supported ever.
I do not recommend this usage.
Reported-by: Will McVicker <willmcvicker@google.com>
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
---
Makefile | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/Makefile b/Makefile
index b0e4767735dc..e42a27447eae 100644
--- a/Makefile
+++ b/Makefile
@@ -1699,6 +1699,13 @@ else # KBUILD_EXTMOD
# Install the modules built in the module directory
# Assumes install directory is already created
+ifdef building_out_of_srctree
+ifneq ($(filter-out /%, $(KBUILD_EXTMOD)),)
+$(warning The combination of out-of-tree build and relative M= path is not well supported.)
+$(warning Please do not complain about any trouble happening under this circumstance.)
+endif
+endif
+
# We are always building only modules.
KBUILD_BUILTIN :=
KBUILD_MODULES := 1
--
2.27.0
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] kbuild: warn a relative path used for M= in out-of-tree builds
2021-01-20 19:31 [PATCH] kbuild: warn a relative path used for M= in out-of-tree builds Masahiro Yamada
@ 2021-01-20 19:46 ` Will McVicker
0 siblings, 0 replies; 2+ messages in thread
From: Will McVicker @ 2021-01-20 19:46 UTC (permalink / raw)
To: Masahiro Yamada
Cc: Linux Kbuild mailing list, Michal Marek,
Linux Kernel Mailing List, Cc: Android Kernel
CC: kernel-team@android.com
Thanks Masahiro!
I'd like to also note that the Android kernel build system is
leveraging this behaviour as sort of an "O=" for external modules [1].
This way the external module's build artifacts are contained separate
from the kernel build artifacts and the module's source code.
--Will
[1] https://android.googlesource.com/kernel/build/+/refs/heads/master/build.sh#748
On Wed, Jan 20, 2021 at 11:31 AM Masahiro Yamada <masahiroy@kernel.org> wrote:
>
> Surprising to me, Kbuild can handle a relative M= path while having
> in-kernel objects in a separate directory. In this case, the M= option
> actually defines:
>
> - the path to external module sources relative to $(srctree)
> - the path to external module objects relative to $(objtree)
>
> For example,
>
> make O=foo/bar M=baz
>
> ... will find the source files in baz, and create objects in foo/bar/baz.
>
> Currently, it works like that because of the presence of VPATH and
> --include-dir=$(abs_srctree), but this behavior is subtle and cannot
> be guaranteed in the future. I do not know if it was even officially
> supported ever.
>
> I do not recommend this usage.
>
> Reported-by: Will McVicker <willmcvicker@google.com>
> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
> ---
>
> Makefile | 7 +++++++
> 1 file changed, 7 insertions(+)
>
> diff --git a/Makefile b/Makefile
> index b0e4767735dc..e42a27447eae 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -1699,6 +1699,13 @@ else # KBUILD_EXTMOD
> # Install the modules built in the module directory
> # Assumes install directory is already created
>
> +ifdef building_out_of_srctree
> +ifneq ($(filter-out /%, $(KBUILD_EXTMOD)),)
> +$(warning The combination of out-of-tree build and relative M= path is not well supported.)
> +$(warning Please do not complain about any trouble happening under this circumstance.)
> +endif
> +endif
> +
> # We are always building only modules.
> KBUILD_BUILTIN :=
> KBUILD_MODULES := 1
> --
> 2.27.0
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-01-20 19:50 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-20 19:31 [PATCH] kbuild: warn a relative path used for M= in out-of-tree builds Masahiro Yamada
2021-01-20 19:46 ` Will McVicker
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®