linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Can we fix samples/ dependency on headers please?
@ 2018-08-01 13:58 David Howells
  2018-08-01 14:45 ` Al Viro
  2018-08-02 15:11 ` Masahiro Yamada
  0 siblings, 2 replies; 3+ messages in thread
From: David Howells @ 2018-08-01 13:58 UTC (permalink / raw)
  To: Masahiro Yamada, Michal Marek, linux-kbuild
  Cc: dhowells, viro, arnd, sfr, nico, linux-kernel

Hi,

I'm currently having to mark various userspace programs I've added to the
samples/ directory as BROKEN in samples/Kconfig because the root Makefile
mucks up the dependencies between building samples and headers_install.

The main culprit seems to be:

	commit dd92478a15fa3bfd746ee08b4ef59401c1537804
	Author: Nicolas Pitre <nicolas.pitre@linaro.org>
	Date:   Sun Feb 28 22:00:00 2016 -0500
	kbuild: build sample modules along with the rest of the kernel
 
which make the samples build in parallel with the build, thereby voiding the
explicit dependency:

	Documentation/ samples/: headers_install

and thereby breaking:

	commit ddea05fa148b4d8e66498e522a616d87f9cf81e3
	Author: Arnd Bergmann <arnd@arndb.de>
	Date:   Mon Jul 4 16:39:35 2016 +0200
	kbuild: make samples depend on headers_install

The obvious fix is to revert commit dd92478a15fa3bfd746ee08b4ef59401c1537804
(see attached patch).

David
---
commit 5c186b58db93e2644012e2fcb4c6ca2e74c6754b
Author: David Howells <dhowells@redhat.com>
Date:   Wed Aug 1 14:48:22 2018 +0100

    Revert "kbuild: build sample modules along with the rest of the kernel"
    
    This reverts commit dd92478a15fa3bfd746ee08b4ef59401c1537804.
    
    The problem with this commit is that some of the samples require the header
    installation to occur first, but building them in parallel with the rest of
    the build breaks that requirement.
    
    Signed-off-by: David Howells <dhowells@redhat.com>

diff --git a/Makefile b/Makefile
index ca2af1ab91eb..30fc0a37ad41 100644
--- a/Makefile
+++ b/Makefile
@@ -1009,16 +1009,14 @@ vmlinux: scripts/link-vmlinux.sh autoksyms_recursive $(vmlinux-deps) FORCE
 ifdef CONFIG_HEADERS_CHECK
 	$(Q)$(MAKE) -f $(srctree)/Makefile headers_check
 endif
+ifdef CONFIG_SAMPLES
+	$(Q)$(MAKE) $(build)=samples
+endif
 ifdef CONFIG_GDB_SCRIPTS
 	$(Q)ln -fsn $(abspath $(srctree)/scripts/gdb/vmlinux-gdb.py)
 endif
 	+$(call if_changed,link-vmlinux)
 
-# Build samples along the rest of the kernel
-ifdef CONFIG_SAMPLES
-vmlinux-dirs += samples
-endif
-
 # The actual objects are generated when descending,
 # make sure no implicit rule kicks in
 $(sort $(vmlinux-deps)): $(vmlinux-dirs) ;

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: Can we fix samples/ dependency on headers please?
  2018-08-01 13:58 Can we fix samples/ dependency on headers please? David Howells
@ 2018-08-01 14:45 ` Al Viro
  2018-08-02 15:11 ` Masahiro Yamada
  1 sibling, 0 replies; 3+ messages in thread
From: Al Viro @ 2018-08-01 14:45 UTC (permalink / raw)
  To: David Howells
  Cc: Masahiro Yamada, Michal Marek, linux-kbuild, arnd, sfr, nico,
	linux-kernel

On Wed, Aug 01, 2018 at 02:58:11PM +0100, David Howells wrote:
> Hi,
> 
> I'm currently having to mark various userspace programs I've added to the
> samples/ directory as BROKEN in samples/Kconfig because the root Makefile
> mucks up the dependencies between building samples and headers_install.
> 
> The main culprit seems to be:
> 
> 	commit dd92478a15fa3bfd746ee08b4ef59401c1537804
> 	Author: Nicolas Pitre <nicolas.pitre@linaro.org>
> 	Date:   Sun Feb 28 22:00:00 2016 -0500
> 	kbuild: build sample modules along with the rest of the kernel
>  
> which make the samples build in parallel with the build, thereby voiding the
> explicit dependency:
> 
> 	Documentation/ samples/: headers_install
> 
> and thereby breaking:
> 
> 	commit ddea05fa148b4d8e66498e522a616d87f9cf81e3
> 	Author: Arnd Bergmann <arnd@arndb.de>
> 	Date:   Mon Jul 4 16:39:35 2016 +0200
> 	kbuild: make samples depend on headers_install

Breaking a commit 4 months before its creation is quite a feat...  Said that,
something along the lines of Arnd's commit is needed (build of samples/*
should happen against the kernel-supplied headers; it certainly should not
depend upon having make headers_install done on the same tree in previous
build.  The problem, AFAICS, is that dependency is for explicit samples/ in
the target list, not samples/<anything> being added there.  Worse, by the
time we get to those, we don't see top-level Makefile targets, so e.g.
adding explict
$(obj)/.test-fsmount.cmd: headers_install
won't work...

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Can we fix samples/ dependency on headers please?
  2018-08-01 13:58 Can we fix samples/ dependency on headers please? David Howells
  2018-08-01 14:45 ` Al Viro
@ 2018-08-02 15:11 ` Masahiro Yamada
  1 sibling, 0 replies; 3+ messages in thread
From: Masahiro Yamada @ 2018-08-02 15:11 UTC (permalink / raw)
  To: David Howells
  Cc: Michal Marek, Linux Kbuild mailing list, Al Viro, Arnd Bergmann,
	Stephen Rothwell, Nicolas Pitre, Linux Kernel Mailing List

Hi.



2018-08-01 22:58 GMT+09:00 David Howells <dhowells@redhat.com>:
> Hi,
>
> I'm currently having to mark various userspace programs I've added to the
> samples/ directory as BROKEN in samples/Kconfig because the root Makefile
> mucks up the dependencies between building samples and headers_install.
>
> The main culprit seems to be:
>
>         commit dd92478a15fa3bfd746ee08b4ef59401c1537804
>         Author: Nicolas Pitre <nicolas.pitre@linaro.org>
>         Date:   Sun Feb 28 22:00:00 2016 -0500
>         kbuild: build sample modules along with the rest of the kernel
>
> which make the samples build in parallel with the build, thereby voiding the
> explicit dependency:
>
>         Documentation/ samples/: headers_install
>
> and thereby breaking:
>
>         commit ddea05fa148b4d8e66498e522a616d87f9cf81e3
>         Author: Arnd Bergmann <arnd@arndb.de>
>         Date:   Mon Jul 4 16:39:35 2016 +0200
>         kbuild: make samples depend on headers_install
>
> The obvious fix is to revert commit dd92478a15fa3bfd746ee08b4ef59401c1537804
> (see attached patch).
>
> David
> ---
> commit 5c186b58db93e2644012e2fcb4c6ca2e74c6754b
> Author: David Howells <dhowells@redhat.com>
> Date:   Wed Aug 1 14:48:22 2018 +0100
>
>     Revert "kbuild: build sample modules along with the rest of the kernel"
>
>     This reverts commit dd92478a15fa3bfd746ee08b4ef59401c1537804.
>
>     The problem with this commit is that some of the samples require the header
>     installation to occur first, but building them in parallel with the rest of
>     the build breaks that requirement.
>
>     Signed-off-by: David Howells <dhowells@redhat.com>
>
> diff --git a/Makefile b/Makefile
> index ca2af1ab91eb..30fc0a37ad41 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -1009,16 +1009,14 @@ vmlinux: scripts/link-vmlinux.sh autoksyms_recursive $(vmlinux-deps) FORCE
>  ifdef CONFIG_HEADERS_CHECK
>         $(Q)$(MAKE) -f $(srctree)/Makefile headers_check
>  endif
> +ifdef CONFIG_SAMPLES
> +       $(Q)$(MAKE) $(build)=samples
> +endif
>  ifdef CONFIG_GDB_SCRIPTS
>         $(Q)ln -fsn $(abspath $(srctree)/scripts/gdb/vmlinux-gdb.py)
>  endif
>         +$(call if_changed,link-vmlinux)
>
> -# Build samples along the rest of the kernel
> -ifdef CONFIG_SAMPLES
> -vmlinux-dirs += samples
> -endif
> -
>  # The actual objects are generated when descending,
>  # make sure no implicit rule kicks in
>  $(sort $(vmlinux-deps)): $(vmlinux-dirs) ;
> --


I dot not understand why this would fix your problem.

Does the combination of CONFIG_SAMPLES=y and CONFIG_HEADERS_CHECK=n
still fail to build?


If you need to install headers before building samples,
this should work:


diff --git a/Makefile b/Makefile
index b47af5a..555ee84 100644
--- a/Makefile
+++ b/Makefile
@@ -1023,6 +1023,7 @@ endif
 # 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,




Please note Arnd's patch only works for single targets.
'samples/' and 'samples' are different targets.


-- 
Best Regards
Masahiro Yamada

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-08-02 15:11 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-08-01 13:58 Can we fix samples/ dependency on headers please? David Howells
2018-08-01 14:45 ` Al Viro
2018-08-02 15:11 ` 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).