linux-arch.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 0/2] kbuild: Remove stale asm-generic wrappers
@ 2016-05-23  8:21 James Hogan
  2016-05-23  8:21 ` James Hogan
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: James Hogan @ 2016-05-23  8:21 UTC (permalink / raw)
  To: linux-kernel
  Cc: x86, linux-arch, linux-mips, Thomas Gleixner, Ingo Molnar,
	H. Peter Anvin, James Hogan, Michal Marek, Jonathan Corbet,
	Arnd Bergmann, Ralf Baechle, Paul Burton, Florian Fainelli,
	Heinrich Schuchardt, linux-kbuild, linux-doc

This patchset attempts to fix kbuild to automatically remove stale
asm-generic wrappers, i.e. when files are removed from generic-y and
added directly into arch/*/include/uapi/asm/, but where the existing
wrapper in arch/*/include/generated/asm/ continues to be used.

MIPS was recently burned by this in v4.3 (see patch 2), with continuing
reports of build failures when people upgrade their trees, which go away
after arch/mips/include/generated is removed (or reportedly make
mrproper/distclean). It is particularly irritating during bisection.

Since v2 I've seen other cases of this breaking MIPS build, and testing
on x86_64, starting a build first on v4.0 and then on mainline with this
patchset shows one stale generated header:
  REMOVE  arch/x86/include/generated/asm/scatterlist.h

Changes in v3:
- Ensure FORCE actually gets marked .PHONY.

Changes in v2:
- New patch 1 to add tracking of generated headers that aren't generic-y
  wrappers, via generated-y, particularly for x86 (thanks to kbuild test
  robot).
- Rewrite a bit, drawing inspiration from Makefile.headersinst.
- Exclude genhdr-y and generated-y (thanks to kbuild test robot).

James Hogan (2):
  kbuild, x86: Track generated headers with generated-y
  kbuild: Remove stale asm-generic wrappers

 Documentation/kbuild/makefiles.txt | 14 ++++++++++++++
 arch/x86/include/asm/Kbuild        |  6 ++++++
 scripts/Makefile.asm-generic       | 17 ++++++++++++++++-
 3 files changed, 36 insertions(+), 1 deletion(-)

Cc: Michal Marek <mmarek@suse.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: Paul Burton <paul.burton@imgtec.com>
Cc: Florian Fainelli <f.fainelli@gmail.com>
Cc: Heinrich Schuchardt <xypron.glpk@gmx.de>
Cc: linux-kbuild@vger.kernel.org
Cc: x86@kernel.org
Cc: linux-doc@vger.kernel.org
Cc: linux-arch@vger.kernel.org
Cc: linux-mips@linux-mips.org
-- 
2.4.10


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

* [PATCH v3 0/2] kbuild: Remove stale asm-generic wrappers
  2016-05-23  8:21 [PATCH v3 0/2] kbuild: Remove stale asm-generic wrappers James Hogan
@ 2016-05-23  8:21 ` James Hogan
  2016-05-23  8:21 ` [PATCH v3 1/2] kbuild, x86: Track generated headers with generated-y James Hogan
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 7+ messages in thread
From: James Hogan @ 2016-05-23  8:21 UTC (permalink / raw)
  To: linux-kernel
  Cc: x86, linux-arch, linux-mips, Thomas Gleixner, Ingo Molnar,
	H. Peter Anvin, James Hogan, Michal Marek, Jonathan Corbet,
	Arnd Bergmann, Ralf Baechle, Paul Burton, Florian Fainelli,
	Heinrich Schuchardt, linux-kbuild, linux-doc

This patchset attempts to fix kbuild to automatically remove stale
asm-generic wrappers, i.e. when files are removed from generic-y and
added directly into arch/*/include/uapi/asm/, but where the existing
wrapper in arch/*/include/generated/asm/ continues to be used.

MIPS was recently burned by this in v4.3 (see patch 2), with continuing
reports of build failures when people upgrade their trees, which go away
after arch/mips/include/generated is removed (or reportedly make
mrproper/distclean). It is particularly irritating during bisection.

Since v2 I've seen other cases of this breaking MIPS build, and testing
on x86_64, starting a build first on v4.0 and then on mainline with this
patchset shows one stale generated header:
  REMOVE  arch/x86/include/generated/asm/scatterlist.h

Changes in v3:
- Ensure FORCE actually gets marked .PHONY.

Changes in v2:
- New patch 1 to add tracking of generated headers that aren't generic-y
  wrappers, via generated-y, particularly for x86 (thanks to kbuild test
  robot).
- Rewrite a bit, drawing inspiration from Makefile.headersinst.
- Exclude genhdr-y and generated-y (thanks to kbuild test robot).

James Hogan (2):
  kbuild, x86: Track generated headers with generated-y
  kbuild: Remove stale asm-generic wrappers

 Documentation/kbuild/makefiles.txt | 14 ++++++++++++++
 arch/x86/include/asm/Kbuild        |  6 ++++++
 scripts/Makefile.asm-generic       | 17 ++++++++++++++++-
 3 files changed, 36 insertions(+), 1 deletion(-)

Cc: Michal Marek <mmarek@suse.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: Paul Burton <paul.burton@imgtec.com>
Cc: Florian Fainelli <f.fainelli@gmail.com>
Cc: Heinrich Schuchardt <xypron.glpk@gmx.de>
Cc: linux-kbuild@vger.kernel.org
Cc: x86@kernel.org
Cc: linux-doc@vger.kernel.org
Cc: linux-arch@vger.kernel.org
Cc: linux-mips@linux-mips.org
-- 
2.4.10


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

* [PATCH v3 1/2] kbuild, x86: Track generated headers with generated-y
  2016-05-23  8:21 [PATCH v3 0/2] kbuild: Remove stale asm-generic wrappers James Hogan
  2016-05-23  8:21 ` James Hogan
@ 2016-05-23  8:21 ` James Hogan
  2016-05-23  8:21 ` [PATCH v3 2/2] kbuild: Remove stale asm-generic wrappers James Hogan
  2016-05-23 15:55 ` [PATCH v3 0/2] " Arnd Bergmann
  3 siblings, 0 replies; 7+ messages in thread
From: James Hogan @ 2016-05-23  8:21 UTC (permalink / raw)
  To: linux-kernel
  Cc: x86, linux-arch, linux-mips, Thomas Gleixner, Ingo Molnar,
	H. Peter Anvin, James Hogan, Michal Marek, Jonathan Corbet,
	linux-kbuild, linux-doc

Track generated header files which aren't already in genhdr-y, alongside
generic-y wrappers in the */include/generated/[uapi/]asm/ directories.
Currently only x86 generates extra headers in these directories, for the
purposes of enumerating system calls for different ABIs, and xen
hypercalls.

This will allow the asm-generic wrapper handling code to remove stale
wrappers when files are removed from generic-y, without also removing
these headers which are generated separately.

Reported-by: kbuild test robot <fengguang.wu@intel.com>
Signed-off-by: James Hogan <james.hogan@imgtec.com>
Cc: Michal Marek <mmarek@suse.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: linux-kbuild@vger.kernel.org
Cc: x86@kernel.org
Cc: linux-doc@vger.kernel.org
---
Changes in v2:
- New patch (thanks to kbuild test robot).
---
 Documentation/kbuild/makefiles.txt | 14 ++++++++++++++
 arch/x86/include/asm/Kbuild        |  6 ++++++
 2 files changed, 20 insertions(+)

diff --git a/Documentation/kbuild/makefiles.txt b/Documentation/kbuild/makefiles.txt
index 13f888a02a3d..385a5ef41c17 100644
--- a/Documentation/kbuild/makefiles.txt
+++ b/Documentation/kbuild/makefiles.txt
@@ -47,6 +47,7 @@ This document describes the Linux kernel Makefiles.
 		--- 7.2 genhdr-y
 		--- 7.3 destination-y
 		--- 7.4 generic-y
+		--- 7.5 generated-y
 
 	=== 8 Kbuild Variables
 	=== 9 Makefile language
@@ -1319,6 +1320,19 @@ See subsequent chapter for the syntax of the Kbuild file.
 		Example: termios.h
 			#include <asm-generic/termios.h>
 
+	--- 7.5 generated-y
+
+	If an architecture generates other header files alongside generic-y
+	wrappers, and not included in genhdr-y, then generated-y specifies
+	them.
+
+	This prevents them being treated as stale asm-generic wrappers and
+	removed.
+
+		Example:
+			#arch/x86/include/asm/Kbuild
+			generated-y += syscalls_32.h
+
 === 8 Kbuild Variables
 
 The top Makefile exports the following variables:
diff --git a/arch/x86/include/asm/Kbuild b/arch/x86/include/asm/Kbuild
index aeac434c9feb..2cfed174e3c9 100644
--- a/arch/x86/include/asm/Kbuild
+++ b/arch/x86/include/asm/Kbuild
@@ -1,5 +1,11 @@
 
 
+generated-y += syscalls_32.h
+generated-y += syscalls_64.h
+generated-y += unistd_32_ia32.h
+generated-y += unistd_64_x32.h
+generated-y += xen-hypercalls.h
+
 genhdr-y += unistd_32.h
 genhdr-y += unistd_64.h
 genhdr-y += unistd_x32.h
-- 
2.4.10

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

* [PATCH v3 2/2] kbuild: Remove stale asm-generic wrappers
  2016-05-23  8:21 [PATCH v3 0/2] kbuild: Remove stale asm-generic wrappers James Hogan
  2016-05-23  8:21 ` James Hogan
  2016-05-23  8:21 ` [PATCH v3 1/2] kbuild, x86: Track generated headers with generated-y James Hogan
@ 2016-05-23  8:21 ` James Hogan
  2016-05-23  8:21   ` James Hogan
  2016-05-23 15:55 ` [PATCH v3 0/2] " Arnd Bergmann
  3 siblings, 1 reply; 7+ messages in thread
From: James Hogan @ 2016-05-23  8:21 UTC (permalink / raw)
  To: linux-kernel
  Cc: x86, linux-arch, linux-mips, Thomas Gleixner, Ingo Molnar,
	H. Peter Anvin, James Hogan, Michal Marek, Arnd Bergmann,
	Ralf Baechle, Paul Burton, Florian Fainelli, linux-kbuild

When a header file is removed from generic-y (often accompanied by the
addition of an arch specific header), the generated wrapper file will
persist, and in some cases may still take precedence over the new arch
header.

For example commit f1fe2d21f4e1 ("MIPS: Add definitions for extended
context") removed ucontext.h from generic-y in arch/mips/include/asm/,
and added an arch/mips/include/uapi/asm/ucontext.h. The continued use of
the wrapper when reusing a dirty build tree resulted in build failures
in arch/mips/kernel/signal.c:

arch/mips/kernel/signal.c: In function ‘sc_to_extcontext’:
arch/mips/kernel/signal.c:142:12: error: ‘struct ucontext’ has no member named ‘uc_extcontext’
  return &uc->uc_extcontext;
            ^

Fix by detecting and removing wrapper headers in generated header
directories that do not correspond to a filename in generic-y, genhdr-y,
or the newly introduced generated-y.

Reported-by: Jacek Anaszewski <j.anaszewski@samsung.com>
Reported-by: Hauke Mehrtens <hauke@hauke-m.de>
Reported-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Signed-off-by: James Hogan <james.hogan@imgtec.com>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Florian Fainelli <f.fainelli@gmail.com>
Cc: Michal Marek <mmarek@suse.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: Paul Burton <paul.burton@imgtec.com>
Cc: Florian Fainelli <f.fainelli@gmail.com>
Cc: linux-kbuild@vger.kernel.org
Cc: linux-arch@vger.kernel.org
Cc: linux-mips@linux-mips.org
---
Changes in v3:
- Ensure FORCE actually gets marked .PHONY.

Changes in v2:
- Rewrite a bit, drawing inspiration from Makefile.headersinst.
- Exclude genhdr-y and generated-y (thanks to kbuild test robot).
---
 scripts/Makefile.asm-generic | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/scripts/Makefile.asm-generic b/scripts/Makefile.asm-generic
index 045e0098e962..e4d017d53819 100644
--- a/scripts/Makefile.asm-generic
+++ b/scripts/Makefile.asm-generic
@@ -13,11 +13,26 @@ include scripts/Kbuild.include
 # Create output directory if not already present
 _dummy := $(shell [ -d $(obj) ] || mkdir -p $(obj))
 
+# Stale wrappers when the corresponding files are removed from generic-y
+# need removing.
+generated-y   := $(generic-y) $(genhdr-y) $(generated-y)
+all-files     := $(patsubst %, $(obj)/%, $(generated-y))
+old-headers   := $(wildcard $(obj)/*.h)
+unwanted      := $(filter-out $(all-files),$(old-headers))
+
 quiet_cmd_wrap = WRAP    $@
 cmd_wrap = echo "\#include <asm-generic/$*.h>" >$@
 
-all: $(patsubst %, $(obj)/%, $(generic-y))
+quiet_cmd_remove = REMOVE  $(unwanted)
+cmd_remove = rm -f $(unwanted)
+
+all: $(patsubst %, $(obj)/%, $(generic-y)) FORCE
+	$(if $(unwanted),$(call cmd,remove),)
 	@:
 
 $(obj)/%.h:
 	$(call cmd,wrap)
+
+PHONY += FORCE
+.PHONY: $(PHONY)
+FORCE: ;
-- 
2.4.10

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

* [PATCH v3 2/2] kbuild: Remove stale asm-generic wrappers
  2016-05-23  8:21 ` [PATCH v3 2/2] kbuild: Remove stale asm-generic wrappers James Hogan
@ 2016-05-23  8:21   ` James Hogan
  0 siblings, 0 replies; 7+ messages in thread
From: James Hogan @ 2016-05-23  8:21 UTC (permalink / raw)
  To: linux-kernel
  Cc: x86, linux-arch, linux-mips, Thomas Gleixner, Ingo Molnar,
	H. Peter Anvin, James Hogan, Michal Marek, Arnd Bergmann,
	Ralf Baechle, Paul Burton, Florian Fainelli, linux-kbuild

When a header file is removed from generic-y (often accompanied by the
addition of an arch specific header), the generated wrapper file will
persist, and in some cases may still take precedence over the new arch
header.

For example commit f1fe2d21f4e1 ("MIPS: Add definitions for extended
context") removed ucontext.h from generic-y in arch/mips/include/asm/,
and added an arch/mips/include/uapi/asm/ucontext.h. The continued use of
the wrapper when reusing a dirty build tree resulted in build failures
in arch/mips/kernel/signal.c:

arch/mips/kernel/signal.c: In function ‘sc_to_extcontext’:
arch/mips/kernel/signal.c:142:12: error: ‘struct ucontext’ has no member named ‘uc_extcontext’
  return &uc->uc_extcontext;
            ^

Fix by detecting and removing wrapper headers in generated header
directories that do not correspond to a filename in generic-y, genhdr-y,
or the newly introduced generated-y.

Reported-by: Jacek Anaszewski <j.anaszewski@samsung.com>
Reported-by: Hauke Mehrtens <hauke@hauke-m.de>
Reported-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Signed-off-by: James Hogan <james.hogan@imgtec.com>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Florian Fainelli <f.fainelli@gmail.com>
Cc: Michal Marek <mmarek@suse.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: Paul Burton <paul.burton@imgtec.com>
Cc: Florian Fainelli <f.fainelli@gmail.com>
Cc: linux-kbuild@vger.kernel.org
Cc: linux-arch@vger.kernel.org
Cc: linux-mips@linux-mips.org
---
Changes in v3:
- Ensure FORCE actually gets marked .PHONY.

Changes in v2:
- Rewrite a bit, drawing inspiration from Makefile.headersinst.
- Exclude genhdr-y and generated-y (thanks to kbuild test robot).
---
 scripts/Makefile.asm-generic | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/scripts/Makefile.asm-generic b/scripts/Makefile.asm-generic
index 045e0098e962..e4d017d53819 100644
--- a/scripts/Makefile.asm-generic
+++ b/scripts/Makefile.asm-generic
@@ -13,11 +13,26 @@ include scripts/Kbuild.include
 # Create output directory if not already present
 _dummy := $(shell [ -d $(obj) ] || mkdir -p $(obj))
 
+# Stale wrappers when the corresponding files are removed from generic-y
+# need removing.
+generated-y   := $(generic-y) $(genhdr-y) $(generated-y)
+all-files     := $(patsubst %, $(obj)/%, $(generated-y))
+old-headers   := $(wildcard $(obj)/*.h)
+unwanted      := $(filter-out $(all-files),$(old-headers))
+
 quiet_cmd_wrap = WRAP    $@
 cmd_wrap = echo "\#include <asm-generic/$*.h>" >$@
 
-all: $(patsubst %, $(obj)/%, $(generic-y))
+quiet_cmd_remove = REMOVE  $(unwanted)
+cmd_remove = rm -f $(unwanted)
+
+all: $(patsubst %, $(obj)/%, $(generic-y)) FORCE
+	$(if $(unwanted),$(call cmd,remove),)
 	@:
 
 $(obj)/%.h:
 	$(call cmd,wrap)
+
+PHONY += FORCE
+.PHONY: $(PHONY)
+FORCE: ;
-- 
2.4.10


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

* Re: [PATCH v3 0/2] kbuild: Remove stale asm-generic wrappers
  2016-05-23  8:21 [PATCH v3 0/2] kbuild: Remove stale asm-generic wrappers James Hogan
                   ` (2 preceding siblings ...)
  2016-05-23  8:21 ` [PATCH v3 2/2] kbuild: Remove stale asm-generic wrappers James Hogan
@ 2016-05-23 15:55 ` Arnd Bergmann
  2016-05-23 15:55   ` Arnd Bergmann
  3 siblings, 1 reply; 7+ messages in thread
From: Arnd Bergmann @ 2016-05-23 15:55 UTC (permalink / raw)
  To: James Hogan
  Cc: linux-kernel, x86, linux-arch, linux-mips, Thomas Gleixner,
	Ingo Molnar, H. Peter Anvin, Michal Marek, Jonathan Corbet,
	Ralf Baechle, Paul Burton, Florian Fainelli, Heinrich Schuchardt,
	linux-kbuild, linux-doc

On Monday, May 23, 2016 9:21:19 AM CEST James Hogan wrote:
> This patchset attempts to fix kbuild to automatically remove stale
> asm-generic wrappers, i.e. when files are removed from generic-y and
> added directly into arch/*/include/uapi/asm/, but where the existing
> wrapper in arch/*/include/generated/asm/ continues to be used.
> 
> MIPS was recently burned by this in v4.3 (see patch 2), with continuing
> reports of build failures when people upgrade their trees, which go away
> after arch/mips/include/generated is removed (or reportedly make
> mrproper/distclean). It is particularly irritating during bisection.

Nice series!

Acked-by: Arnd Bergmann <arnd@arndb.de>

There are a number of files that we leave behind after a make clean,
and I also wondered if we could remove some more of them, but I couldn't
easily figure out which of them were left intentionally.

The asm-generic wrappers certainly are not there for a good reason,
and it's good to see them gone.

	Arnd

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

* Re: [PATCH v3 0/2] kbuild: Remove stale asm-generic wrappers
  2016-05-23 15:55 ` [PATCH v3 0/2] " Arnd Bergmann
@ 2016-05-23 15:55   ` Arnd Bergmann
  0 siblings, 0 replies; 7+ messages in thread
From: Arnd Bergmann @ 2016-05-23 15:55 UTC (permalink / raw)
  To: James Hogan
  Cc: linux-kernel, x86, linux-arch, linux-mips, Thomas Gleixner,
	Ingo Molnar, H. Peter Anvin, Michal Marek, Jonathan Corbet,
	Ralf Baechle, Paul Burton, Florian Fainelli, Heinrich Schuchardt,
	linux-kbuild, linux-doc

On Monday, May 23, 2016 9:21:19 AM CEST James Hogan wrote:
> This patchset attempts to fix kbuild to automatically remove stale
> asm-generic wrappers, i.e. when files are removed from generic-y and
> added directly into arch/*/include/uapi/asm/, but where the existing
> wrapper in arch/*/include/generated/asm/ continues to be used.
> 
> MIPS was recently burned by this in v4.3 (see patch 2), with continuing
> reports of build failures when people upgrade their trees, which go away
> after arch/mips/include/generated is removed (or reportedly make
> mrproper/distclean). It is particularly irritating during bisection.

Nice series!

Acked-by: Arnd Bergmann <arnd@arndb.de>

There are a number of files that we leave behind after a make clean,
and I also wondered if we could remove some more of them, but I couldn't
easily figure out which of them were left intentionally.

The asm-generic wrappers certainly are not there for a good reason,
and it's good to see them gone.

	Arnd

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

end of thread, other threads:[~2016-05-23 15:57 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-05-23  8:21 [PATCH v3 0/2] kbuild: Remove stale asm-generic wrappers James Hogan
2016-05-23  8:21 ` James Hogan
2016-05-23  8:21 ` [PATCH v3 1/2] kbuild, x86: Track generated headers with generated-y James Hogan
2016-05-23  8:21 ` [PATCH v3 2/2] kbuild: Remove stale asm-generic wrappers James Hogan
2016-05-23  8:21   ` James Hogan
2016-05-23 15:55 ` [PATCH v3 0/2] " Arnd Bergmann
2016-05-23 15:55   ` Arnd Bergmann

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).