kbuild: move -Wundef from KBUILD_CFLAGS to KBUILD_CPPFLAGS
Subsystems (4)
PATCH v2 1/1 kbuild: move -Wundef from KBUILD_CFLAGS to KBUILD_CPPFLAGS
The use of an undefined macro in an #if directive is warned, but only in *.c files. No warning from other files such as *.S, *.lds.S.
Since -Wundef is a preprocessor-related warning, it should be added to KBUILD_CPPFLAGS instead of KBUILD_CFLAGS.
Fix some uncovered issues.
[1] Add -D__LINUX_ARM_ARCH__=* to KBUILD_CPPFLAGS
In file included from arch/arm/kernel/vmlinux.lds.S:13:./arch/arm/include/asm/cache.h:23:31: warning: "__LINUX_ARM_ARCH__" is not defined, evaluates to 0 [-Wundef]
23 | #if defined(CONFIG_AEABI) && (__LINUX_ARM_ARCH__ >= 5)
| ^~~~~~~~~~~~~~~~~~
[2] Add missing #include <asm/pgtable.h>
In file included from arch/arm/mm/cache-v7.S:17:arch/arm/mm/proc-macros.S:109:5: warning: "L_PTE_SHARED" is not defined, evaluates to 0 [-Wundef]
109 | #if L_PTE_SHARED != PTE_EXT_SHARED
| ^~~~~~~~~~~~
arch/arm/mm/proc-macros.S:109:21: warning: "PTE_EXT_SHARED" is not defined, evaluates to 0 [-Wundef]
109 | #if L_PTE_SHARED != PTE_EXT_SHARED
| ^~~~~~~~~~~~~~
arch/arm/mm/proc-macros.S:113:10: warning: "L_PTE_XN" is not defined, evaluates to 0 [-Wundef]
113 | (L_PTE_XN+L_PTE_USER+L_PTE_RDONLY+L_PTE_DIRTY+L_PTE_YOUNG+\
| ^~~~~~~~
arch/arm/mm/proc-macros.S:113:19: warning: "L_PTE_USER" is not defined, evaluates to 0 [-Wundef]
113 | (L_PTE_XN+L_PTE_USER+L_PTE_RDONLY+L_PTE_DIRTY+L_PTE_YOUNG+\
| ^~~~~~~~~~
arch/arm/mm/proc-macros.S:113:30: warning: "L_PTE_RDONLY" is not defined, evaluates to 0 [-Wundef]
113 | (L_PTE_XN+L_PTE_USER+L_PTE_RDONLY+L_PTE_DIRTY+L_PTE_YOUNG+\
| ^~~~~~~~~~~~arch/arm/mm/proc-macros.S:113:43: warning: "L_PTE_DIRTY" is not defined, evaluates to 0 [-Wundef]
113 | (L_PTE_XN+L_PTE_USER+L_PTE_RDONLY+L_PTE_DIRTY+L_PTE_YOUNG+\
| ^~~~~~~~~~~arch/arm/mm/proc-macros.S:113:55: warning: "L_PTE_YOUNG" is not defined, evaluates to 0 [-Wundef]
113 | (L_PTE_XN+L_PTE_USER+L_PTE_RDONLY+L_PTE_DIRTY+L_PTE_YOUNG+\
| ^~~~~~~~~~~arch/arm/mm/proc-macros.S:114:10: warning: "L_PTE_PRESENT" is not defined, evaluates to 0 [-Wundef]
114 | L_PTE_PRESENT) > L_PTE_SHARED
| ^~~~~~~~~~~~~
arch/arm/mm/proc-macros.S:114:27: warning: "L_PTE_SHARED" is not defined, evaluates to 0 [-Wundef]
114 | L_PTE_PRESENT) > L_PTE_SHARED
| ^~~~~~~~~~~~[3] #if -> #ifdef
arch/riscv/kernel/head.S:329:5: warning: "CONFIG_RISCV_BOOT_SPINWAIT" is not defined, evaluates to 0 [-Wundef]
329 | #if CONFIG_RISCV_BOOT_SPINWAIT
| ^~~~~~~~~~~~~~~~~~~~~~~~~~
[4] #elif -> #elif defined()
arch/s390/boot/decompressor.c:28:7: warning: "CONFIG_KERNEL_ZSTD" is not defined, evaluates to 0 [-Wundef]
28 | #elif CONFIG_KERNEL_ZSTD
| ^~~~~~~~~~~~~~~~~~
---
Changes in v2:
- Fix warnings
Makefile | 4 ++-- arch/arm/Makefile | 1 + arch/arm/mm/proc-macros.S | 1 + arch/riscv/kernel/head.S | 2 +- arch/s390/boot/decompressor.c | 2 +- 5 files changed, 6 insertions(+), 4 deletions(-)
Makefile +2 -2
@@ -523,12 +523,12 @@ LINUXINCLUDE := \ $(USERINCLUDE) KBUILD_AFLAGS := -D__ASSEMBLY__ -fno-PIE -KBUILD_CFLAGS := -Wall -Wundef -Werror=strict-prototypes -Wno-trigraphs \ +KBUILD_CFLAGS := -Wall -Werror=strict-prototypes -Wno-trigraphs \ -fno-strict-aliasing -fno-common -fshort-wchar -fno-PIE \ -Werror=implicit-function-declaration -Werror=implicit-int \ -Werror=return-type -Wno-format-security \ -std=gnu11 -KBUILD_CPPFLAGS := -D__KERNEL__ +KBUILD_CPPFLAGS := -D__KERNEL__ -Wundef KBUILD_AFLAGS_KERNEL := KBUILD_CFLAGS_KERNEL := KBUILD_AFLAGS_MODULE := -DMODULE
arch/arm/Makefile +1 -0
@@ -129,6 +129,7 @@ AFLAGS_ISA :=$(CFLAGS_ISA) endif # Need -Uarm for gcc < 3.x +KBUILD_CPPFLAGS += $(filter -D%, $(arch-y)) KBUILD_CFLAGS +=$(CFLAGS_ABI) $(CFLAGS_ISA) $(arch-y) $(tune-y) $(call cc-option,-mshort-load-bytes,$(call cc-option,-malignment-traps,)) -msoft-float -Uarm KBUILD_AFLAGS +=$(CFLAGS_ABI) $(AFLAGS_ISA) $(arch-y) $(tune-y) -include asm/unified.h -msoft-float
arch/arm/mm/proc-macros.S +1 -0
@@ -6,6 +6,7 @@ * VM_EXEC */ #include <asm/asm-offsets.h> +#include <asm/pgtable.h> #include <asm/thread_info.h> #ifdef CONFIG_CPU_V7M
arch/riscv/kernel/head.S +1 -1
@@ -326,7 +326,7 @@ clear_bss_done: call soc_early_init tail start_kernel -#if CONFIG_RISCV_BOOT_SPINWAIT +#ifdef CONFIG_RISCV_BOOT_SPINWAIT .Lsecondary_start: /* Set trap vector to spin forever to help debug */ la a3, .Lsecondary_park
arch/s390/boot/decompressor.c +1 -1
@@ -25,7 +25,7 @@#ifdef CONFIG_KERNEL_BZIP2 #define BOOT_HEAP_SIZE 0x400000 -#elif CONFIG_KERNEL_ZSTD +#elif defined(CONFIG_KERNEL_ZSTD )#define BOOT_HEAP_SIZE 0x30000#else #define BOOT_HEAP_SIZE 0x10000
Signature · 7 lines
2.34.1 _______________________________________________ linux-riscv mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-riscv
kernel test robot
build botI love your patch! Perhaps something to improve:
Hi Masahiro,
I love your patch! Perhaps something to improve:
[auto build test WARNING on masahiroy-kbuild/for-next]
[also build test WARNING on s390/features soc/for-next linus/master v6.0-rc6] [cannot apply to next-20220921]
[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Masahiro-Yamada/kbuild-move-Wundef-from-KBUILD_CFLAGS-to-KBUILD_CPPFLAGS/20220913-161447 base: https://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild.git for-next config: arm64-buildonly-randconfig-r003-20220922 (https://download.01.org/0day-ci/archive/20220923/[email protected]/config) compiler: aarch64-linux-gcc (GCC) 12.1.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/intel-lab-lkp/linux/commit/ccf1a82d3dedb27a2b1b21f64e09183b197e1f6f
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Masahiro-Yamada/kbuild-move-Wundef-from-KBUILD_CFLAGS-to-KBUILD_CPPFLAGS/20220913-161447 git checkout ccf1a82d3dedb27a2b1b21f64e09183b197e1f6f
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=arm64 SHELL=/bin/bash arch/arm64/kernel/
If you fix the issue, kindly add following tag where applicable | Reported-by: kernel test robot <[email protected]>
All warnings (new ones prefixed by >>):
In file included from arch/arm64/kernel/vmlinux.lds.S:65:
>> arch/arm64/include/asm/kernel-pgtable.h:135:41: warning: "PMD_SHIFT" is not defined, evaluates to 0 [-Wundef]
135 | #define ARM64_MEMSTART_SHIFT PMD_SHIFT
| ^~~~~~~~~ arch/arm64/include/asm/kernel-pgtable.h:144:5: note: in expansion of macro 'ARM64_MEMSTART_SHIFT'
144 | #if ARM64_MEMSTART_SHIFT < SECTION_SIZE_BITS
| ^~~~~~~~~~~~~~~~~~~~
vim +/PMD_SHIFT +135 arch/arm64/include/asm/kernel-pgtable.h
87d1587bef394c Suzuki K. Poulose 2015-10-19 122 a7f8de168ace48 Ard Biesheuvel 2016-02-16 123 /* a7f8de168ace48 Ard Biesheuvel 2016-02-16 124 * To make optimal use of block mappings when laying out the linear a7f8de168ace48 Ard Biesheuvel 2016-02-16 125 * mapping, round down the base of physical memory to a size that can a7f8de168ace48 Ard Biesheuvel 2016-02-16 126 * be mapped efficiently, i.e., either PUD_SIZE (4k granule) or PMD_SIZE a7f8de168ace48 Ard Biesheuvel 2016-02-16 127 * (64k granule), or a multiple that can be mapped using contiguous bits a7f8de168ace48 Ard Biesheuvel 2016-02-16 128 * in the page tables: 32 * PMD_SIZE (16k granule) a7f8de168ace48 Ard Biesheuvel 2016-02-16 129 */ 06e9bf2fd9b372 Ard Biesheuvel 2016-03-30 130 #if defined(CONFIG_ARM64_4K_PAGES) 06e9bf2fd9b372 Ard Biesheuvel 2016-03-30 131 #define ARM64_MEMSTART_SHIFT PUD_SHIFT 06e9bf2fd9b372 Ard Biesheuvel 2016-03-30 132 #elif defined(CONFIG_ARM64_16K_PAGES) ca6ece6a76a8b5 Anshuman Khandual 2021-06-14 133 #define ARM64_MEMSTART_SHIFT CONT_PMD_SHIFT a7f8de168ace48 Ard Biesheuvel 2016-02-16 134 #else 06e9bf2fd9b372 Ard Biesheuvel 2016-03-30 @135 #define ARM64_MEMSTART_SHIFT PMD_SHIFT 06e9bf2fd9b372 Ard Biesheuvel 2016-03-30 136 #endif 06e9bf2fd9b372 Ard Biesheuvel 2016-03-30 137
Signature · 2 lines
0-DAY CI Kernel Test Service https://01.org/lkp