Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1423164 > unrolled thread

[PATCH v2 00/11] Kbuild: fix -Wmissing-include-path warnings

Started byArnd Bergmann <arnd@arndb.de>
First post2016-06-15 17:50 +0200
Last post2016-06-15 17:50 +0200
Articles 7 — 1 participant

Back to article view | Back to linux.kernel


Contents

  [PATCH v2 00/11] Kbuild: fix -Wmissing-include-path warnings Arnd Bergmann <arnd@arndb.de> - 2016-06-15 17:50 +0200
    [PATCH v2 11/11] [EXPERIMENTAL] Kbuild: enable -Wmissing-include-dirs by default Arnd Bergmann <arnd@arndb.de> - 2016-06-15 17:50 +0200
    [PATCH v2 05/11] Kbuild: don't add obj tree in additional includes Arnd Bergmann <arnd@arndb.de> - 2016-06-15 17:50 +0200
    [PATCH v2 01/11] Kbuild: don't add ../../ to include path Arnd Bergmann <arnd@arndb.de> - 2016-06-15 17:50 +0200
    [PATCH v2 08/11] drm: amd: remove broken include path Arnd Bergmann <arnd@arndb.de> - 2016-06-15 17:50 +0200
    [PATCH v2 03/11] Kbuild: always prefix objtree in LINUXINCLUDE Arnd Bergmann <arnd@arndb.de> - 2016-06-15 17:50 +0200
    [PATCH v2 02/11] Kbuild: avoid duplicate include path Arnd Bergmann <arnd@arndb.de> - 2016-06-15 17:50 +0200

#1423164 — [PATCH v2 00/11] Kbuild: fix -Wmissing-include-path warnings

FromArnd Bergmann <arnd@arndb.de>
Date2016-06-15 17:50 +0200
Subject[PATCH v2 00/11] Kbuild: fix -Wmissing-include-path warnings
Message-ID<rKleN-4pE-3@gated-at.bofh.it>
This warning is enabled at "make W=1" level, and found a bunch of
actual problems in code that adds -I flags to nonexisting directories.
All of these are harmless, but clearly wrong.

Kbuild itself also adds a bunch of extra directories, including in
some cases those outside of the kernel tree (e.g. ../../include),
which can have surprising consequences.

This series fixes all the warnings I found with -Wmissing-include-dirs
enabled on ARM randconfigs and x86 allmodconfig. The non-Kbuild
patches can all be applied independently, while we probably want
the Kbuild stuff to be kept as a series, if we decide to merge them.

I have added my test patch at the end, mainly to see if the Kbuild
bot finds any other warnings on additional architectures.

	Arnd

Arnd Bergmann (11):
  Kbuild: don't add ../../ to include path
  Kbuild: avoid duplicate include path
  Kbuild: always prefix objtree in LINUXINCLUDE
  Kbuild: arch: look for generated headers in obtree
  Kbuild: don't add obj tree in additional includes
  ARM: don't include removed directories
  ARM: hide mach-*/ include for ARM_SINGLE_ARMV7M
  drm: amd: remove broken include path
  net: skfb: remove obsolete -I cflag
  rtlwifi: don't add include path for rtl8188ee
  [EXPERIMENTAL] Kbuild: enable -Wmissing-include-dirs by default

 Makefile                                                | 16 ++++++++++------
 arch/alpha/boot/Makefile                                |  2 +-
 arch/arm/Makefile                                       |  2 ++
 arch/arm/mach-mvebu/Makefile                            |  3 +--
 arch/arm/mach-realview/Makefile                         |  3 +--
 arch/arm/mach-s5pv210/Makefile                          |  2 +-
 arch/powerpc/boot/Makefile                              |  2 +-
 arch/powerpc/kvm/Makefile                               |  2 +-
 arch/s390/boot/compressed/Makefile                      |  4 ++--
 arch/um/Makefile                                        |  4 ++--
 arch/x86/boot/Makefile                                  |  2 +-
 arch/x86/realmode/rm/Makefile                           |  2 +-
 drivers/gpu/drm/amd/acp/Makefile                        |  2 --
 drivers/net/fddi/skfp/Makefile                          |  2 +-
 drivers/net/wireless/realtek/rtlwifi/rtl8188ee/Makefile |  2 +-
 scripts/Kbuild.include                                  |  2 +-
 scripts/Makefile.lib                                    |  7 ++++---
 17 files changed, 31 insertions(+), 28 deletions(-)

-- 
2.9.0

[toc] | [next] | [standalone]


#1423165 — [PATCH v2 11/11] [EXPERIMENTAL] Kbuild: enable -Wmissing-include-dirs by default

FromArnd Bergmann <arnd@arndb.de>
Date2016-06-15 17:50 +0200
Subject[PATCH v2 11/11] [EXPERIMENTAL] Kbuild: enable -Wmissing-include-dirs by default
Message-ID<rKleO-4pE-37@gated-at.bofh.it>
In reply to#1423164
I have fixed up all -Wmissing-include-dirs on ARM randconfig builds,
so we could make this the default, but I have not tested this at all
on other architectures.

This enables it anyway, just to see what other warnings we get
when the build bot analyses the branch.

Don't apply (yet).

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 Makefile | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/Makefile b/Makefile
index 969924783543..2305cbd61e60 100644
--- a/Makefile
+++ b/Makefile
@@ -781,6 +781,9 @@ endif
 NOSTDINC_FLAGS += -nostdinc -isystem $(shell $(CC) -print-file-name=include)
 CHECKFLAGS     += $(NOSTDINC_FLAGS)
 
+# warn about incorrect -I include paths
+KBUILD_CFLAGS += -Wmissing-include-dirs
+
 # warn about C99 declaration after statement
 KBUILD_CFLAGS += $(call cc-option,-Wdeclaration-after-statement,)
 
-- 
2.9.0

[toc] | [prev] | [next] | [standalone]


#1423169 — [PATCH v2 05/11] Kbuild: don't add obj tree in additional includes

FromArnd Bergmann <arnd@arndb.de>
Date2016-06-15 17:50 +0200
Subject[PATCH v2 05/11] Kbuild: don't add obj tree in additional includes
Message-ID<rKleP-4pE-51@gated-at.bofh.it>
In reply to#1423164
When building with separate object directories and driver specific
Makefiles that add additional header include paths, Kbuild adjusts
the gcc flags so that we include both the directory in the source
tree and in the object tree.

However, due to another bug I fixed earlier, this did not actually
include the correct directory in the object tree, so we know that
we only really need the source tree here. Also, including the
object tree sometimes causes warnings about nonexisting directories
when the include path only exists in the source.

This changes the logic to only emit the -I argument for the srctree,
not for objects. We still need both $(srctree)/$(src) and $(obj)
though, so I'm adding them manually.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 scripts/Kbuild.include | 2 +-
 scripts/Makefile.lib   | 7 ++++---
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include
index f8b45eb47ed3..15b196fc2f49 100644
--- a/scripts/Kbuild.include
+++ b/scripts/Kbuild.include
@@ -202,7 +202,7 @@ hdr-inst := -f $(srctree)/scripts/Makefile.headersinst obj
 # Prefix -I with $(srctree) if it is not an absolute path.
 # skip if -I has no parameter
 addtree = $(if $(patsubst -I%,%,$(1)), \
-$(if $(filter-out -I/% -I../%,$(1)),$(patsubst -I%,-I$(srctree)/%,$(1))) $(1))
+$(if $(filter-out -I/% -I./% -I../%,$(1)),$(patsubst -I%,-I$(srctree)/%,$(1)),$(1)))
 
 # Find all -I options and call addtree
 flags = $(foreach o,$($(1)),$(if $(filter -I%,$(o)),$(call addtree,$(o)),$(o)))
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index 76494e15417b..0a07f9014944 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -155,9 +155,10 @@ else
 # $(call addtree,-I$(obj)) locates .h files in srctree, from generated .c files
 #   and locates generated .h files
 # FIXME: Replace both with specific CFLAGS* statements in the makefiles
-__c_flags	= $(call addtree,-I$(obj)) $(call flags,_c_flags)
-__a_flags	=                          $(call flags,_a_flags)
-__cpp_flags     =                          $(call flags,_cpp_flags)
+__c_flags	= $(if $(obj),-I$(srctree)/$(src) -I$(obj)) \
+		  $(call flags,_c_flags)
+__a_flags	= $(call flags,_a_flags)
+__cpp_flags     = $(call flags,_cpp_flags)
 endif
 
 c_flags        = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(LINUXINCLUDE)     \
-- 
2.9.0

[toc] | [prev] | [next] | [standalone]


#1423170 — [PATCH v2 01/11] Kbuild: don't add ../../ to include path

FromArnd Bergmann <arnd@arndb.de>
Date2016-06-15 17:50 +0200
Subject[PATCH v2 01/11] Kbuild: don't add ../../ to include path
Message-ID<rKleP-4pE-53@gated-at.bofh.it>
In reply to#1423164
When we build with O=objdir and objdir is directly below the source tree,
$(srctree) becomes '..'.

When a Makefile adds a CFLAGS option like -Ipath/to/headers and
we are building with a separate object directory, Kbuild tries to
add two -I options, one for the source tree and one for the object
tree. An absolute path is treated as a special case, and don't add
this one twice. This also normally catches -I$(srctree)/$(src)
as $(srctree) usually is an absolute directory like /home/arnd/linux/.

The combination of the two behaviors however results in an invalid
path name to be included: we get both ../$(src) and ../../$(src),
the latter one pointing outside of the source tree, usually to a
nonexisting directory. Building with 'make W=1' makes this obvious:

cc1: error: ../../arch/arm/mach-s3c24xx/include: No such file or directory [-Werror=missing-include-dirs]

This adds another special case, treating path names starting with ../
like those starting with / so we don't try to prefix that with
$(srctree).

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 scripts/Kbuild.include | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include
index 0f82314621f2..f8b45eb47ed3 100644
--- a/scripts/Kbuild.include
+++ b/scripts/Kbuild.include
@@ -202,7 +202,7 @@ hdr-inst := -f $(srctree)/scripts/Makefile.headersinst obj
 # Prefix -I with $(srctree) if it is not an absolute path.
 # skip if -I has no parameter
 addtree = $(if $(patsubst -I%,%,$(1)), \
-$(if $(filter-out -I/%,$(1)),$(patsubst -I%,-I$(srctree)/%,$(1))) $(1))
+$(if $(filter-out -I/% -I../%,$(1)),$(patsubst -I%,-I$(srctree)/%,$(1))) $(1))
 
 # Find all -I options and call addtree
 flags = $(foreach o,$($(1)),$(if $(filter -I%,$(o)),$(call addtree,$(o)),$(o)))
-- 
2.9.0

[toc] | [prev] | [next] | [standalone]


#1423171 — [PATCH v2 08/11] drm: amd: remove broken include path

FromArnd Bergmann <arnd@arndb.de>
Date2016-06-15 17:50 +0200
Subject[PATCH v2 08/11] drm: amd: remove broken include path
Message-ID<rKleP-4pE-55@gated-at.bofh.it>
In reply to#1423164
The AMD ACP driver adds "-I../acp -I../acp/include" to the gcc command
line, which makes no sense, since these are evaluated relative to the
build directory. When we build with "make W=1", they instead cause
a warning:

cc1: error: ../acp/: No such file or directory [-Werror=missing-include-dirs]
cc1: error: ../acp/include: No such file or directory [-Werror=missing-include-dirs]
cc1: all warnings being treated as errors
../scripts/Makefile.build:289: recipe for target 'drivers/gpu/drm/amd/amdgpu/amdgpu_drv.o' failed
../scripts/Makefile.build:289: recipe for target 'drivers/gpu/drm/amd/amdgpu/amdgpu_device.o' failed
../scripts/Makefile.build:289: recipe for target 'drivers/gpu/drm/amd/amdgpu/amdgpu_kms.o' failed

This removes the subdir-ccflags variable that evidently did not
serve any purpose here.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 drivers/gpu/drm/amd/acp/Makefile | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/acp/Makefile b/drivers/gpu/drm/amd/acp/Makefile
index 8363cb57915b..8a08e81ee90d 100644
--- a/drivers/gpu/drm/amd/acp/Makefile
+++ b/drivers/gpu/drm/amd/acp/Makefile
@@ -3,6 +3,4 @@
 # of AMDSOC/AMDGPU drm driver.
 # It provides the HW control for ACP related functionalities.
 
-subdir-ccflags-y += -I$(AMDACPPATH)/ -I$(AMDACPPATH)/include
-
 AMD_ACP_FILES := $(AMDACPPATH)/acp_hw.o
-- 
2.9.0

[toc] | [prev] | [next] | [standalone]


#1423172 — [PATCH v2 03/11] Kbuild: always prefix objtree in LINUXINCLUDE

FromArnd Bergmann <arnd@arndb.de>
Date2016-06-15 17:50 +0200
Subject[PATCH v2 03/11] Kbuild: always prefix objtree in LINUXINCLUDE
Message-ID<rKleP-4pE-57@gated-at.bofh.it>
In reply to#1423164
When $(LINUXINCLUDE) is added to the cflags of a target that
normall doesn't have it (e.g. HOSTCFLAGS), each entry in the
list is expanded so that we search both $(objtree) and $(srctree),
which is a bit silly, as we already know which of the two we
want for each entry in LINUXINCLUDE.

Also, a follow-up patch changes the behavior so we only look in
$(srctree) for manually added include path, and that breaks finding
the generated headers.

This adds an explicit $(objtree) for each tree that we want to
look for generated files.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 Makefile | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/Makefile b/Makefile
index 45159861e645..969924783543 100644
--- a/Makefile
+++ b/Makefile
@@ -377,19 +377,19 @@ CFLAGS_KCOV	:= $(call cc-option,-fsanitize-coverage=trace-pc,)
 # Use USERINCLUDE when you must reference the UAPI directories only.
 USERINCLUDE    := \
 		-I$(srctree)/arch/$(hdr-arch)/include/uapi \
-		-Iarch/$(hdr-arch)/include/generated/uapi \
+		-I$(objtree)/arch/$(hdr-arch)/include/generated/uapi \
 		-I$(srctree)/include/uapi \
-		-Iinclude/generated/uapi \
+		-I$(objtree)/include/generated/uapi \
                 -include $(srctree)/include/linux/kconfig.h
 
 # Use LINUXINCLUDE when you must reference the include/ directory.
 # Needed to be compatible with the O= option
 LINUXINCLUDE    := \
 		-I$(srctree)/arch/$(hdr-arch)/include \
-		-Iarch/$(hdr-arch)/include/generated/uapi \
-		-Iarch/$(hdr-arch)/include/generated \
+		-I$(objtree)/arch/$(hdr-arch)/include/generated/uapi \
+		-I$(objtree)/arch/$(hdr-arch)/include/generated \
 		$(if $(KBUILD_SRC), -I$(srctree)/include) \
-		-Iinclude
+		-I$(objtree)/include
 
 LINUXINCLUDE	+= $(filter-out $(LINUXINCLUDE),$(USERINCLUDE))
 
-- 
2.9.0

[toc] | [prev] | [next] | [standalone]


#1423173 — [PATCH v2 02/11] Kbuild: avoid duplicate include path

FromArnd Bergmann <arnd@arndb.de>
Date2016-06-15 17:50 +0200
Subject[PATCH v2 02/11] Kbuild: avoid duplicate include path
Message-ID<rKleP-4pE-59@gated-at.bofh.it>
In reply to#1423164
arch/$(hdr-arch)/include/generated/uapi is included twice in the
header search path, which is unnecessary, so this changes the
top-level Makefile to drop the second instance by filtering out
everything from USERINCLUDE that was already part of LINUXINCLUDE.

This should have very little effect other than making the 'make V=1'
output slightly smaller and making the build time faster by a miniscule
amount, but it seems to be cleaner.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 Makefile | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/Makefile b/Makefile
index 8b80a1506be0..45159861e645 100644
--- a/Makefile
+++ b/Makefile
@@ -389,8 +389,9 @@ LINUXINCLUDE    := \
 		-Iarch/$(hdr-arch)/include/generated/uapi \
 		-Iarch/$(hdr-arch)/include/generated \
 		$(if $(KBUILD_SRC), -I$(srctree)/include) \
-		-Iinclude \
-		$(USERINCLUDE)
+		-Iinclude
+
+LINUXINCLUDE	+= $(filter-out $(LINUXINCLUDE),$(USERINCLUDE))
 
 KBUILD_CPPFLAGS := -D__KERNEL__
 
-- 
2.9.0

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web