* [PATCH] samples: run headers_install for host arch instead of target arch
@ 2018-09-28 6:49 Masahiro Yamada
2018-09-28 19:36 ` Arnd Bergmann
0 siblings, 1 reply; 3+ messages in thread
From: Masahiro Yamada @ 2018-09-28 6:49 UTC (permalink / raw)
To: linux-kbuild
Cc: David Howells, Kees Cook, Richard Weinberger, Jeff Dike,
Masahiro Yamada, Bjorn Andersson, Arnd Bergmann, linux-kernel,
Michal Marek, Andy Gross, Alex Williamson, Gerd Hoffmann
Some samples search headers in $(objtree)/usr/include, which is made
available by "make headers_install". It is not kernel-space code but
host programs that need this header search path.
Commit 3fca1700c4c3 ("kbuild: make samples really depend on
headers_install") is wrong because it installs headers of the target
architecture. Besides, UML fails to build with CONFIG_SAMPLES=y
because UML does not support headers_install.
Invoke "make headers_install" for the _host_ architecture in the
prepare stage. Introduce CONFIG_HOST_HEADERS_INSTALL so that this
happens only for samples that need it.
I also removed 'Documentation/: headers_install', which I guess is
stale code.
Fixes: 3fca1700c4c3 ("kbuild: make samples really depend on headers_install")
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Cc: David Howells <dhowells@redhat.com>
---
Makefile | 8 ++++----
samples/Kconfig | 6 ++++++
2 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/Makefile b/Makefile
index 0c90c43..f04564c 100644
--- a/Makefile
+++ b/Makefile
@@ -1029,10 +1029,9 @@ ifdef CONFIG_GDB_SCRIPTS
endif
+$(call if_changed,link-vmlinux)
-# Build samples along the rest of the kernel. This needs headers_install.
+# Build samples along the rest of the kernel.
ifdef CONFIG_SAMPLES
vmlinux-dirs += samples
-samples: headers_install
endif
# The actual objects are generated when descending,
@@ -1098,6 +1097,9 @@ archprepare: archheaders archscripts prepare1 scripts_basic
prepare0: archprepare gcc-plugins
$(Q)$(MAKE) $(build)=.
+ifdef CONFIG_HOST_HEADERS_INSTALL
+ $(Q)$(MAKE) -f $(srctree)/Makefile ARCH=$(SUBARCH) headers_install
+endif
# All the preparing..
prepare: prepare0 prepare-objtool
@@ -1682,8 +1684,6 @@ endif
$(cmd_crmodverdir)
$(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
$(build)=$(build-dir)
-# Make sure the latest headers are built for Documentation
-Documentation/ samples/: headers_install
%/: prepare scripts FORCE
$(cmd_crmodverdir)
$(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
diff --git a/samples/Kconfig b/samples/Kconfig
index bd133ef..fcd6b7c 100644
--- a/samples/Kconfig
+++ b/samples/Kconfig
@@ -1,3 +1,6 @@
+config HOST_HEADERS_INSTALL
+ bool
+
menuconfig SAMPLES
bool "Sample kernel code"
help
@@ -95,6 +98,7 @@ config SAMPLE_CONFIGFS
config SAMPLE_CONNECTOR
tristate "Build connector sample -- loadable modules only"
depends on CONNECTOR && m
+ select HOST_HEADERS_INSTALL
help
When enabled, this builds both a sample kernel module for
the connector interface and a user space tool to communicate
@@ -104,6 +108,7 @@ config SAMPLE_CONNECTOR
config SAMPLE_SECCOMP
tristate "Build seccomp sample code -- loadable modules only"
depends on SECCOMP_FILTER && m
+ select HOST_HEADERS_INSTALL
help
Build samples of seccomp filters using various methods of
BPF filter construction.
@@ -149,6 +154,7 @@ config SAMPLE_VFIO_MDEV_MBOCHS
config SAMPLE_STATX
bool "Build example extended-stat using code"
depends on BROKEN
+ select HOST_HEADERS_INSTALL
help
Build example userspace program to use the new extended-stat syscall.
--
2.7.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] samples: run headers_install for host arch instead of target arch
2018-09-28 6:49 [PATCH] samples: run headers_install for host arch instead of target arch Masahiro Yamada
@ 2018-09-28 19:36 ` Arnd Bergmann
2018-09-29 16:52 ` Masahiro Yamada
0 siblings, 1 reply; 3+ messages in thread
From: Arnd Bergmann @ 2018-09-28 19:36 UTC (permalink / raw)
To: Masahiro Yamada
Cc: Linux Kbuild mailing list, David Howells, Kees Cook,
Richard Weinberger, Jeff Dike, Bjorn Andersson,
Linux Kernel Mailing List, Michal Marek, Andy Gross,
Alex Williamson, Gerd Hoffmann
On Fri, Sep 28, 2018 at 8:51 AM Masahiro Yamada
<yamada.masahiro@socionext.com> wrote:
>
> Some samples search headers in $(objtree)/usr/include, which is made
> available by "make headers_install". It is not kernel-space code but
> host programs that need this header search path.
>
> Commit 3fca1700c4c3 ("kbuild: make samples really depend on
> headers_install") is wrong because it installs headers of the target
> architecture. Besides, UML fails to build with CONFIG_SAMPLES=y
> because UML does not support headers_install.
>
> Invoke "make headers_install" for the _host_ architecture in the
> prepare stage. Introduce CONFIG_HOST_HEADERS_INSTALL so that this
> happens only for samples that need it.
>
> I also removed 'Documentation/: headers_install', which I guess is
> stale code.
>
> Fixes: 3fca1700c4c3 ("kbuild: make samples really depend on headers_install")
> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
> Cc: David Howells <dhowells@redhat.com>
I don't understand this one. Why would we want to build the samples for
the host architecture rather than the target architecture?
I would think that the bug is that we try to build them using
HOSTCC, and they end up being unusable on the target as
a consequence.
Arnd
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] samples: run headers_install for host arch instead of target arch
2018-09-28 19:36 ` Arnd Bergmann
@ 2018-09-29 16:52 ` Masahiro Yamada
0 siblings, 0 replies; 3+ messages in thread
From: Masahiro Yamada @ 2018-09-29 16:52 UTC (permalink / raw)
To: Arnd Bergmann
Cc: Linux Kbuild mailing list, David Howells, Kees Cook,
Richard Weinberger, Jeff Dike, Bjorn Andersson,
Linux Kernel Mailing List, Michal Marek, Andy Gross,
Alex Williamson, Gerd Hoffmann
2018年9月29日(土) 4:38 Arnd Bergmann <arnd@arndb.de>:
>
> On Fri, Sep 28, 2018 at 8:51 AM Masahiro Yamada
> <yamada.masahiro@socionext.com> wrote:
> >
> > Some samples search headers in $(objtree)/usr/include, which is made
> > available by "make headers_install". It is not kernel-space code but
> > host programs that need this header search path.
> >
> > Commit 3fca1700c4c3 ("kbuild: make samples really depend on
> > headers_install") is wrong because it installs headers of the target
> > architecture. Besides, UML fails to build with CONFIG_SAMPLES=y
> > because UML does not support headers_install.
> >
> > Invoke "make headers_install" for the _host_ architecture in the
> > prepare stage. Introduce CONFIG_HOST_HEADERS_INSTALL so that this
> > happens only for samples that need it.
> >
> > I also removed 'Documentation/: headers_install', which I guess is
> > stale code.
> >
> > Fixes: 3fca1700c4c3 ("kbuild: make samples really depend on headers_install")
> > Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
> > Cc: David Howells <dhowells@redhat.com>
>
> I don't understand this one. Why would we want to build the samples for
> the host architecture rather than the target architecture?
>
> I would think that the bug is that we try to build them using
> HOSTCC, and they end up being unusable on the target as
> a consequence.
I just read Makefiles under samples/, and
all that require -I$(objtree)/usr/include
are listed in hostprogs-y,
so they are built for host architectures.
If this is different from our intent,
we need to fix this first.
--
Best Regards
Masahiro Yamada
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-09-29 16:53 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-28 6:49 [PATCH] samples: run headers_install for host arch instead of target arch Masahiro Yamada
2018-09-28 19:36 ` Arnd Bergmann
2018-09-29 16:52 ` Masahiro Yamada
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).