diff mbox series

[v2] Makefile.extrawarn: enable -Wmissing-variable-declarations for W=1

Message ID 20230807-missing_proto-v2-1-3ae2e188bb0c@google.com (mailing list archive)
State New, archived
Headers show
Series [v2] Makefile.extrawarn: enable -Wmissing-variable-declarations for W=1 | expand

Commit Message

Nick Desaulniers Aug. 7, 2023, 4:57 p.m. UTC
I noticed Tom was sending patches where smatch was recommending
annotating functions as static when no previous declaration existed.
Surely the compiler could make such recommendations as well, I thought.

Looks like -Wmissing-variable-declarations can make such
recommendations.

GCC just added support for this warning (gcc 14.1.0 will ship with
support), and all versions of clang relevant to building the kernel
support this flag.

Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
---
Changes in v2:
- Fix typo in warning flag name. I thought I tested W=1 but I was
  looking at -Wmissing-declaration, not the expected
  -Wmissing-variable-declaration. Actually verified v2.
- Link to v1: https://lore.kernel.org/r/20230807-missing_proto-v1-1-7f566b7ba5ca@google.com
---
 scripts/Makefile.extrawarn | 1 +
 1 file changed, 1 insertion(+)


---
base-commit: 52a93d39b17dc7eb98b6aa3edb93943248e03b2f
change-id: 20230807-missing_proto-0cb90ec6454c

Best regards,

Comments

kernel test robot Aug. 8, 2023, 2:23 a.m. UTC | #1
Hi Nick,

kernel test robot noticed the following build warnings:

[auto build test WARNING on 52a93d39b17dc7eb98b6aa3edb93943248e03b2f]

url:    https://github.com/intel-lab-lkp/linux/commits/Nick-Desaulniers/Makefile-extrawarn-enable-Wmissing-variable-declarations-for-W-1/20230808-005859
base:   52a93d39b17dc7eb98b6aa3edb93943248e03b2f
patch link:    https://lore.kernel.org/r/20230807-missing_proto-v2-1-3ae2e188bb0c%40google.com
patch subject: [PATCH v2] Makefile.extrawarn: enable -Wmissing-variable-declarations for W=1
config: riscv-randconfig-r014-20230807 (https://download.01.org/0day-ci/archive/20230808/202308081000.tTL1ElTr-lkp@intel.com/config)
compiler: clang version 17.0.0 (https://github.com/llvm/llvm-project.git 4a5ac14ee968ff0ad5d2cc1ffa0299048db4c88a)
reproduce: (https://download.01.org/0day-ci/archive/20230808/202308081000.tTL1ElTr-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202308081000.tTL1ElTr-lkp@intel.com/

All warnings (new ones prefixed by >>):

   In file included from arch/riscv/kernel/asm-offsets.c:10:
   In file included from include/linux/mm.h:7:
   In file included from include/linux/gfp.h:7:
   In file included from include/linux/mmzone.h:8:
   In file included from include/linux/spinlock.h:56:
   In file included from include/linux/preempt.h:79:
   In file included from ./arch/riscv/include/generated/asm/preempt.h:1:
   In file included from include/asm-generic/preempt.h:5:
   In file included from include/linux/thread_info.h:23:
>> arch/riscv/include/asm/current.h:20:30: warning: no previous extern declaration for non-static variable 'riscv_current_is_tp' [-Wmissing-variable-declarations]
      20 | register struct task_struct *riscv_current_is_tp __asm__("tp");
         |                              ^
   arch/riscv/include/asm/current.h:20:10: note: declare 'static' if the variable is not intended to be used outside of this translation unit
      20 | register struct task_struct *riscv_current_is_tp __asm__("tp");
         |          ^
>> arch/riscv/include/asm/current.h:36:24: warning: no previous extern declaration for non-static variable 'current_stack_pointer' [-Wmissing-variable-declarations]
      36 | register unsigned long current_stack_pointer __asm__("sp");
         |                        ^
   arch/riscv/include/asm/current.h:36:10: note: declare 'static' if the variable is not intended to be used outside of this translation unit
      36 | register unsigned long current_stack_pointer __asm__("sp");
         |          ^
   2 warnings generated.
--
   In file included from arch/riscv/kernel/process.c:10:
   In file included from include/linux/cpu.h:17:
   In file included from include/linux/node.h:18:
   In file included from include/linux/device.h:15:
   In file included from include/linux/dev_printk.h:16:
   In file included from include/linux/ratelimit.h:6:
   In file included from include/linux/sched.h:12:
>> arch/riscv/include/asm/current.h:20:30: warning: no previous extern declaration for non-static variable 'riscv_current_is_tp' [-Wmissing-variable-declarations]
      20 | register struct task_struct *riscv_current_is_tp __asm__("tp");
         |                              ^
   arch/riscv/include/asm/current.h:20:10: note: declare 'static' if the variable is not intended to be used outside of this translation unit
      20 | register struct task_struct *riscv_current_is_tp __asm__("tp");
         |          ^
>> arch/riscv/include/asm/current.h:36:24: warning: no previous extern declaration for non-static variable 'current_stack_pointer' [-Wmissing-variable-declarations]
      36 | register unsigned long current_stack_pointer __asm__("sp");
         |                        ^
   arch/riscv/include/asm/current.h:36:10: note: declare 'static' if the variable is not intended to be used outside of this translation unit
      36 | register unsigned long current_stack_pointer __asm__("sp");
         |          ^
>> arch/riscv/kernel/process.c:29:24: warning: no previous extern declaration for non-static variable 'gp_in_global' [-Wmissing-variable-declarations]
      29 | register unsigned long gp_in_global __asm__("gp");
         |                        ^
   arch/riscv/kernel/process.c:29:10: note: declare 'static' if the variable is not intended to be used outside of this translation unit
      29 | register unsigned long gp_in_global __asm__("gp");
         |          ^
   3 warnings generated.
--
   In file included from arch/riscv/mm/init.c:10:
   In file included from include/linux/mm.h:7:
   In file included from include/linux/gfp.h:7:
   In file included from include/linux/mmzone.h:8:
   In file included from include/linux/spinlock.h:56:
   In file included from include/linux/preempt.h:79:
   In file included from ./arch/riscv/include/generated/asm/preempt.h:1:
   In file included from include/asm-generic/preempt.h:5:
   In file included from include/linux/thread_info.h:23:
>> arch/riscv/include/asm/current.h:20:30: warning: no previous extern declaration for non-static variable 'riscv_current_is_tp' [-Wmissing-variable-declarations]
      20 | register struct task_struct *riscv_current_is_tp __asm__("tp");
         |                              ^
   arch/riscv/include/asm/current.h:20:10: note: declare 'static' if the variable is not intended to be used outside of this translation unit
      20 | register struct task_struct *riscv_current_is_tp __asm__("tp");
         |          ^
>> arch/riscv/include/asm/current.h:36:24: warning: no previous extern declaration for non-static variable 'current_stack_pointer' [-Wmissing-variable-declarations]
      36 | register unsigned long current_stack_pointer __asm__("sp");
         |                        ^
   arch/riscv/include/asm/current.h:36:10: note: declare 'static' if the variable is not intended to be used outside of this translation unit
      36 | register unsigned long current_stack_pointer __asm__("sp");
         |          ^
>> arch/riscv/mm/init.c:276:7: warning: no previous extern declaration for non-static variable 'trampoline_pg_dir' [-Wmissing-variable-declarations]
     276 | pgd_t trampoline_pg_dir[PTRS_PER_PGD] __page_aligned_bss;
         |       ^
   arch/riscv/mm/init.c:276:1: note: declare 'static' if the variable is not intended to be used outside of this translation unit
     276 | pgd_t trampoline_pg_dir[PTRS_PER_PGD] __page_aligned_bss;
         | ^
>> arch/riscv/mm/init.c:279:7: warning: no previous extern declaration for non-static variable 'early_pg_dir' [-Wmissing-variable-declarations]
     279 | pgd_t early_pg_dir[PTRS_PER_PGD] __initdata __aligned(PAGE_SIZE);
         |       ^
   arch/riscv/mm/init.c:279:1: note: declare 'static' if the variable is not intended to be used outside of this translation unit
     279 | pgd_t early_pg_dir[PTRS_PER_PGD] __initdata __aligned(PAGE_SIZE);
         | ^
   4 warnings generated.
--
   drivers/char/ipmi/ipmi_si_platform.c:272:15: warning: cast to smaller integer type 'enum si_type' from 'const void *' [-Wvoid-pointer-to-enum-cast]
     272 |         io.si_type      = (enum si_type) match->data;
         |                           ^~~~~~~~~~~~~~~~~~~~~~~~~~
   In file included from drivers/char/ipmi/ipmi_si_platform.c:13:
   In file included from include/linux/module.h:14:
   In file included from include/linux/buildid.h:5:
   In file included from include/linux/mm_types.h:8:
   In file included from include/linux/kref.h:16:
   In file included from include/linux/spinlock.h:56:
   In file included from include/linux/preempt.h:79:
   In file included from ./arch/riscv/include/generated/asm/preempt.h:1:
   In file included from include/asm-generic/preempt.h:5:
   In file included from include/linux/thread_info.h:23:
>> arch/riscv/include/asm/current.h:20:30: warning: no previous extern declaration for non-static variable 'riscv_current_is_tp' [-Wmissing-variable-declarations]
      20 | register struct task_struct *riscv_current_is_tp __asm__("tp");
         |                              ^
   arch/riscv/include/asm/current.h:20:10: note: declare 'static' if the variable is not intended to be used outside of this translation unit
      20 | register struct task_struct *riscv_current_is_tp __asm__("tp");
         |          ^
>> arch/riscv/include/asm/current.h:36:24: warning: no previous extern declaration for non-static variable 'current_stack_pointer' [-Wmissing-variable-declarations]
      36 | register unsigned long current_stack_pointer __asm__("sp");
         |                        ^
   arch/riscv/include/asm/current.h:36:10: note: declare 'static' if the variable is not intended to be used outside of this translation unit
      36 | register unsigned long current_stack_pointer __asm__("sp");
         |          ^
   3 warnings generated.
--
>> net/atm/mpc.c:123:21: warning: no previous extern declaration for non-static variable 'mpcs' [-Wmissing-variable-declarations]
     123 | struct mpoa_client *mpcs = NULL; /* FIXME */
         |                     ^
   net/atm/mpc.c:123:1: note: declare 'static' if the variable is not intended to be used outside of this translation unit
     123 | struct mpoa_client *mpcs = NULL; /* FIXME */
         | ^
   In file included from net/atm/mpc.c:6:
   In file included from include/linux/slab.h:16:
   In file included from include/linux/gfp.h:7:
   In file included from include/linux/mmzone.h:8:
   In file included from include/linux/spinlock.h:56:
   In file included from include/linux/preempt.h:79:
   In file included from ./arch/riscv/include/generated/asm/preempt.h:1:
   In file included from include/asm-generic/preempt.h:5:
   In file included from include/linux/thread_info.h:23:
>> arch/riscv/include/asm/current.h:20:30: warning: no previous extern declaration for non-static variable 'riscv_current_is_tp' [-Wmissing-variable-declarations]
      20 | register struct task_struct *riscv_current_is_tp __asm__("tp");
         |                              ^
   arch/riscv/include/asm/current.h:20:10: note: declare 'static' if the variable is not intended to be used outside of this translation unit
      20 | register struct task_struct *riscv_current_is_tp __asm__("tp");
         |          ^
>> arch/riscv/include/asm/current.h:36:24: warning: no previous extern declaration for non-static variable 'current_stack_pointer' [-Wmissing-variable-declarations]
      36 | register unsigned long current_stack_pointer __asm__("sp");
         |                        ^
   arch/riscv/include/asm/current.h:36:10: note: declare 'static' if the variable is not intended to be used outside of this translation unit
      36 | register unsigned long current_stack_pointer __asm__("sp");
         |          ^
   3 warnings generated.
--
>> net/llc/llc_conn.c:44:5: warning: no previous extern declaration for non-static variable 'sysctl_llc2_ack_timeout' [-Wmissing-variable-declarations]
      44 | int sysctl_llc2_ack_timeout = LLC2_ACK_TIME * HZ;
         |     ^
   net/llc/llc_conn.c:44:1: note: declare 'static' if the variable is not intended to be used outside of this translation unit
      44 | int sysctl_llc2_ack_timeout = LLC2_ACK_TIME * HZ;
         | ^
>> net/llc/llc_conn.c:45:5: warning: no previous extern declaration for non-static variable 'sysctl_llc2_p_timeout' [-Wmissing-variable-declarations]
      45 | int sysctl_llc2_p_timeout = LLC2_P_TIME * HZ;
         |     ^
   net/llc/llc_conn.c:45:1: note: declare 'static' if the variable is not intended to be used outside of this translation unit
      45 | int sysctl_llc2_p_timeout = LLC2_P_TIME * HZ;
         | ^
>> net/llc/llc_conn.c:46:5: warning: no previous extern declaration for non-static variable 'sysctl_llc2_rej_timeout' [-Wmissing-variable-declarations]
      46 | int sysctl_llc2_rej_timeout = LLC2_REJ_TIME * HZ;
         |     ^
   net/llc/llc_conn.c:46:1: note: declare 'static' if the variable is not intended to be used outside of this translation unit
      46 | int sysctl_llc2_rej_timeout = LLC2_REJ_TIME * HZ;
         | ^
>> net/llc/llc_conn.c:47:5: warning: no previous extern declaration for non-static variable 'sysctl_llc2_busy_timeout' [-Wmissing-variable-declarations]
      47 | int sysctl_llc2_busy_timeout = LLC2_BUSY_TIME * HZ;
         |     ^
   net/llc/llc_conn.c:47:1: note: declare 'static' if the variable is not intended to be used outside of this translation unit
      47 | int sysctl_llc2_busy_timeout = LLC2_BUSY_TIME * HZ;
         | ^
   In file included from net/llc/llc_conn.c:16:
   In file included from include/linux/slab.h:16:
   In file included from include/linux/gfp.h:7:
   In file included from include/linux/mmzone.h:8:
   In file included from include/linux/spinlock.h:56:
   In file included from include/linux/preempt.h:79:
   In file included from ./arch/riscv/include/generated/asm/preempt.h:1:
   In file included from include/asm-generic/preempt.h:5:
   In file included from include/linux/thread_info.h:23:
>> arch/riscv/include/asm/current.h:20:30: warning: no previous extern declaration for non-static variable 'riscv_current_is_tp' [-Wmissing-variable-declarations]
      20 | register struct task_struct *riscv_current_is_tp __asm__("tp");
         |                              ^
   arch/riscv/include/asm/current.h:20:10: note: declare 'static' if the variable is not intended to be used outside of this translation unit
      20 | register struct task_struct *riscv_current_is_tp __asm__("tp");
         |          ^
>> arch/riscv/include/asm/current.h:36:24: warning: no previous extern declaration for non-static variable 'current_stack_pointer' [-Wmissing-variable-declarations]
      36 | register unsigned long current_stack_pointer __asm__("sp");
         |                        ^
   arch/riscv/include/asm/current.h:36:10: note: declare 'static' if the variable is not intended to be used outside of this translation unit
      36 | register unsigned long current_stack_pointer __asm__("sp");
         |          ^
   6 warnings generated.
--
   drivers/i2c/busses/i2c-bcm-iproc.c:1039:3: warning: cast to smaller integer type 'enum bcm_iproc_i2c_type' from 'const void *' [-Wvoid-pointer-to-enum-cast]
    1039 |                 (enum bcm_iproc_i2c_type)of_device_get_match_data(&pdev->dev);
         |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   In file included from drivers/i2c/busses/i2c-bcm-iproc.c:4:
   In file included from include/linux/delay.h:23:
   In file included from include/linux/sched.h:12:
>> arch/riscv/include/asm/current.h:20:30: warning: no previous extern declaration for non-static variable 'riscv_current_is_tp' [-Wmissing-variable-declarations]
      20 | register struct task_struct *riscv_current_is_tp __asm__("tp");
         |                              ^
   arch/riscv/include/asm/current.h:20:10: note: declare 'static' if the variable is not intended to be used outside of this translation unit
      20 | register struct task_struct *riscv_current_is_tp __asm__("tp");
         |          ^
>> arch/riscv/include/asm/current.h:36:24: warning: no previous extern declaration for non-static variable 'current_stack_pointer' [-Wmissing-variable-declarations]
      36 | register unsigned long current_stack_pointer __asm__("sp");
         |                        ^
   arch/riscv/include/asm/current.h:36:10: note: declare 'static' if the variable is not intended to be used outside of this translation unit
      36 | register unsigned long current_stack_pointer __asm__("sp");
         |          ^
   3 warnings generated.
--
>> drivers/i2c/busses/i2c-amd756.c:286:20: warning: no previous extern declaration for non-static variable 'amd756_smbus' [-Wmissing-variable-declarations]
     286 | struct i2c_adapter amd756_smbus = {
         |                    ^
   drivers/i2c/busses/i2c-amd756.c:286:1: note: declare 'static' if the variable is not intended to be used outside of this translation unit
     286 | struct i2c_adapter amd756_smbus = {
         | ^
   In file included from drivers/i2c/busses/i2c-amd756.c:25:
   In file included from include/linux/module.h:14:
   In file included from include/linux/buildid.h:5:
   In file included from include/linux/mm_types.h:8:
   In file included from include/linux/kref.h:16:
   In file included from include/linux/spinlock.h:56:
   In file included from include/linux/preempt.h:79:
   In file included from ./arch/riscv/include/generated/asm/preempt.h:1:
   In file included from include/asm-generic/preempt.h:5:
   In file included from include/linux/thread_info.h:23:
>> arch/riscv/include/asm/current.h:20:30: warning: no previous extern declaration for non-static variable 'riscv_current_is_tp' [-Wmissing-variable-declarations]
      20 | register struct task_struct *riscv_current_is_tp __asm__("tp");
         |                              ^
   arch/riscv/include/asm/current.h:20:10: note: declare 'static' if the variable is not intended to be used outside of this translation unit
      20 | register struct task_struct *riscv_current_is_tp __asm__("tp");
         |          ^
>> arch/riscv/include/asm/current.h:36:24: warning: no previous extern declaration for non-static variable 'current_stack_pointer' [-Wmissing-variable-declarations]
      36 | register unsigned long current_stack_pointer __asm__("sp");
         |                        ^
   arch/riscv/include/asm/current.h:36:10: note: declare 'static' if the variable is not intended to be used outside of this translation unit
      36 | register unsigned long current_stack_pointer __asm__("sp");
         |          ^
   3 warnings generated.
--
   drivers/i2c/busses/i2c-rcar.c:1066:18: warning: cast to smaller integer type 'enum rcar_i2c_type' from 'const void *' [-Wvoid-pointer-to-enum-cast]
    1066 |         priv->devtype = (enum rcar_i2c_type)of_device_get_match_data(dev);
         |                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   In file included from drivers/i2c/busses/i2c-rcar.c:15:
   In file included from include/linux/clk.h:14:
   In file included from include/linux/notifier.h:14:
   In file included from include/linux/mutex.h:14:
>> arch/riscv/include/asm/current.h:20:30: warning: no previous extern declaration for non-static variable 'riscv_current_is_tp' [-Wmissing-variable-declarations]
      20 | register struct task_struct *riscv_current_is_tp __asm__("tp");
         |                              ^
   arch/riscv/include/asm/current.h:20:10: note: declare 'static' if the variable is not intended to be used outside of this translation unit
      20 | register struct task_struct *riscv_current_is_tp __asm__("tp");
         |          ^
>> arch/riscv/include/asm/current.h:36:24: warning: no previous extern declaration for non-static variable 'current_stack_pointer' [-Wmissing-variable-declarations]
      36 | register unsigned long current_stack_pointer __asm__("sp");
         |                        ^
   arch/riscv/include/asm/current.h:36:10: note: declare 'static' if the variable is not intended to be used outside of this translation unit
      36 | register unsigned long current_stack_pointer __asm__("sp");
         |          ^
   3 warnings generated.
--
   scripts/genksyms/parse.y: warning: 9 shift/reduce conflicts [-Wconflicts-sr]
   scripts/genksyms/parse.y: warning: 5 reduce/reduce conflicts [-Wconflicts-rr]
   scripts/genksyms/parse.y: note: rerun with option '-Wcounterexamples' to generate conflict counterexamples
   In file included from arch/riscv/kernel/asm-offsets.c:10:
   In file included from include/linux/mm.h:7:
   In file included from include/linux/gfp.h:7:
   In file included from include/linux/mmzone.h:8:
   In file included from include/linux/spinlock.h:56:
   In file included from include/linux/preempt.h:79:
   In file included from ./arch/riscv/include/generated/asm/preempt.h:1:
   In file included from include/asm-generic/preempt.h:5:
   In file included from include/linux/thread_info.h:23:
>> arch/riscv/include/asm/current.h:20:30: warning: no previous extern declaration for non-static variable 'riscv_current_is_tp' [-Wmissing-variable-declarations]
      20 | register struct task_struct *riscv_current_is_tp __asm__("tp");
         |                              ^
   arch/riscv/include/asm/current.h:20:10: note: declare 'static' if the variable is not intended to be used outside of this translation unit
      20 | register struct task_struct *riscv_current_is_tp __asm__("tp");
         |          ^
>> arch/riscv/include/asm/current.h:36:24: warning: no previous extern declaration for non-static variable 'current_stack_pointer' [-Wmissing-variable-declarations]
      36 | register unsigned long current_stack_pointer __asm__("sp");
         |                        ^
   arch/riscv/include/asm/current.h:36:10: note: declare 'static' if the variable is not intended to be used outside of this translation unit
      36 | register unsigned long current_stack_pointer __asm__("sp");
         |          ^
   2 warnings generated.


vim +/riscv_current_is_tp +20 arch/riscv/include/asm/current.h

7db91e57a0acde Palmer Dabbelt 2017-07-10  19  
52e7c52d2ded59 Palmer Dabbelt 2020-02-27 @20  register struct task_struct *riscv_current_is_tp __asm__("tp");
52e7c52d2ded59 Palmer Dabbelt 2020-02-27  21  
7db91e57a0acde Palmer Dabbelt 2017-07-10  22  /*
7db91e57a0acde Palmer Dabbelt 2017-07-10  23   * This only works because "struct thread_info" is at offset 0 from "struct
7db91e57a0acde Palmer Dabbelt 2017-07-10  24   * task_struct".  This constraint seems to be necessary on other architectures
7db91e57a0acde Palmer Dabbelt 2017-07-10  25   * as well, but __switch_to enforces it.  We can't check TASK_TI here because
7db91e57a0acde Palmer Dabbelt 2017-07-10  26   * <asm/asm-offsets.h> includes this, and I can't get the definition of "struct
7db91e57a0acde Palmer Dabbelt 2017-07-10  27   * task_struct" here due to some header ordering problems.
7db91e57a0acde Palmer Dabbelt 2017-07-10  28   */
7db91e57a0acde Palmer Dabbelt 2017-07-10  29  static __always_inline struct task_struct *get_current(void)
7db91e57a0acde Palmer Dabbelt 2017-07-10  30  {
52e7c52d2ded59 Palmer Dabbelt 2020-02-27  31  	return riscv_current_is_tp;
7db91e57a0acde Palmer Dabbelt 2017-07-10  32  }
7db91e57a0acde Palmer Dabbelt 2017-07-10  33  
7db91e57a0acde Palmer Dabbelt 2017-07-10  34  #define current get_current()
7db91e57a0acde Palmer Dabbelt 2017-07-10  35  
fdecfea09328b3 Kees Cook      2022-02-23 @36  register unsigned long current_stack_pointer __asm__("sp");
fdecfea09328b3 Kees Cook      2022-02-23  37
kernel test robot Aug. 8, 2023, 2:44 a.m. UTC | #2
Hi Nick,

kernel test robot noticed the following build warnings:

[auto build test WARNING on 52a93d39b17dc7eb98b6aa3edb93943248e03b2f]

url:    https://github.com/intel-lab-lkp/linux/commits/Nick-Desaulniers/Makefile-extrawarn-enable-Wmissing-variable-declarations-for-W-1/20230808-005859
base:   52a93d39b17dc7eb98b6aa3edb93943248e03b2f
patch link:    https://lore.kernel.org/r/20230807-missing_proto-v2-1-3ae2e188bb0c%40google.com
patch subject: [PATCH v2] Makefile.extrawarn: enable -Wmissing-variable-declarations for W=1
config: um-randconfig-r031-20230807 (https://download.01.org/0day-ci/archive/20230808/202308081050.sZEw4cQ5-lkp@intel.com/config)
compiler: clang version 14.0.6 (https://github.com/llvm/llvm-project.git f28c006a5895fc0e329fe15fead81e37457cb1d1)
reproduce: (https://download.01.org/0day-ci/archive/20230808/202308081050.sZEw4cQ5-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202308081050.sZEw4cQ5-lkp@intel.com/

All warnings (new ones prefixed by >>):

   In file included from scripts/mod/devicetable-offsets.c:3:
   In file included from include/linux/mod_devicetable.h:14:
   In file included from include/linux/uuid.h:11:
   In file included from include/linux/string.h:20:
   In file included from arch/x86/include/asm/string.h:5:
   In file included from arch/x86/include/asm/string_64.h:6:
   In file included from include/linux/jump_label.h:255:
   In file included from include/linux/atomic.h:7:
   In file included from arch/x86/include/asm/atomic.h:7:
   In file included from arch/x86/include/asm/alternative.h:7:
>> arch/x86/include/asm/asm.h:208:24: warning: no previous extern declaration for non-static variable 'current_stack_pointer' [-Wmissing-variable-declarations]
   register unsigned long current_stack_pointer asm(_ASM_SP);
                          ^
   arch/x86/include/asm/asm.h:208:10: note: declare 'static' if the variable is not intended to be used outside of this translation unit
   register unsigned long current_stack_pointer asm(_ASM_SP);
            ^
   1 warning generated.
--
   In file included from arch/um/kernel/asm-offsets.c:1:
   arch/x86/um/shared/sysdep/kernel-offsets.h:9:6: warning: no previous prototype for function 'foo' [-Wmissing-prototypes]
   void foo(void)
        ^
   arch/x86/um/shared/sysdep/kernel-offsets.h:9:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
   void foo(void)
   ^
   static 
   In file included from arch/um/kernel/asm-offsets.c:1:
   In file included from arch/x86/um/shared/sysdep/kernel-offsets.h:3:
   In file included from include/linux/sched.h:12:
   In file included from ./arch/um/include/generated/asm/current.h:1:
   In file included from include/asm-generic/current.h:5:
   In file included from include/linux/thread_info.h:27:
   In file included from include/linux/bitops.h:34:
   In file included from include/asm-generic/bitops/generic-non-atomic.h:7:
   In file included from arch/x86/um/asm/barrier.h:6:
   In file included from arch/x86/include/asm/alternative.h:7:
>> arch/x86/include/asm/asm.h:208:24: warning: no previous extern declaration for non-static variable 'current_stack_pointer' [-Wmissing-variable-declarations]
   register unsigned long current_stack_pointer asm(_ASM_SP);
                          ^
   arch/x86/include/asm/asm.h:208:10: note: declare 'static' if the variable is not intended to be used outside of this translation unit
   register unsigned long current_stack_pointer asm(_ASM_SP);
            ^
   2 warnings generated.
--
   In file included from arch/um/drivers/hostaudio_kern.c:6:
   In file included from include/linux/fs.h:6:
   In file included from include/linux/wait_bit.h:8:
   In file included from include/linux/wait.h:7:
   In file included from include/linux/list.h:11:
   In file included from arch/x86/um/asm/barrier.h:6:
   In file included from arch/x86/include/asm/alternative.h:7:
>> arch/x86/include/asm/asm.h:208:24: warning: no previous extern declaration for non-static variable 'current_stack_pointer' [-Wmissing-variable-declarations]
   register unsigned long current_stack_pointer asm(_ASM_SP);
                          ^
   arch/x86/include/asm/asm.h:208:10: note: declare 'static' if the variable is not intended to be used outside of this translation unit
   register unsigned long current_stack_pointer asm(_ASM_SP);
            ^
>> arch/um/drivers/hostaudio_kern.c:316:3: warning: no previous extern declaration for non-static variable 'module_data' [-Wmissing-variable-declarations]
   } module_data;
     ^
   arch/um/drivers/hostaudio_kern.c:313:1: note: declare 'static' if the variable is not intended to be used outside of this translation unit
   struct {
   ^
   2 warnings generated.
--
   In file included from arch/um/drivers/daemon_kern.c:10:
   In file included from include/linux/netdevice.h:38:
   In file included from include/net/net_namespace.h:43:
   In file included from include/linux/skbuff.h:17:
   In file included from include/linux/bvec.h:10:
   In file included from include/linux/highmem.h:12:
   In file included from include/linux/hardirq.h:11:
   In file included from arch/um/include/asm/hardirq.h:5:
   In file included from include/asm-generic/hardirq.h:17:
   In file included from include/linux/irq.h:20:
   In file included from include/linux/io.h:13:
   In file included from arch/um/include/asm/io.h:24:
   include/asm-generic/io.h:547:31: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           val = __raw_readb(PCI_IOBASE + addr);
                             ~~~~~~~~~~ ^
   include/asm-generic/io.h:560:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           val = __le16_to_cpu((__le16 __force)__raw_readw(PCI_IOBASE + addr));
                                                           ~~~~~~~~~~ ^
   include/uapi/linux/byteorder/little_endian.h:37:51: note: expanded from macro '__le16_to_cpu'
   #define __le16_to_cpu(x) ((__force __u16)(__le16)(x))
                                                     ^
   In file included from arch/um/drivers/daemon_kern.c:10:
   In file included from include/linux/netdevice.h:38:
   In file included from include/net/net_namespace.h:43:
   In file included from include/linux/skbuff.h:17:
   In file included from include/linux/bvec.h:10:
   In file included from include/linux/highmem.h:12:
   In file included from include/linux/hardirq.h:11:
   In file included from arch/um/include/asm/hardirq.h:5:
   In file included from include/asm-generic/hardirq.h:17:
   In file included from include/linux/irq.h:20:
   In file included from include/linux/io.h:13:
   In file included from arch/um/include/asm/io.h:24:
   include/asm-generic/io.h:573:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           val = __le32_to_cpu((__le32 __force)__raw_readl(PCI_IOBASE + addr));
                                                           ~~~~~~~~~~ ^
   include/uapi/linux/byteorder/little_endian.h:35:51: note: expanded from macro '__le32_to_cpu'
   #define __le32_to_cpu(x) ((__force __u32)(__le32)(x))
                                                     ^
   In file included from arch/um/drivers/daemon_kern.c:10:
   In file included from include/linux/netdevice.h:38:
   In file included from include/net/net_namespace.h:43:
   In file included from include/linux/skbuff.h:17:
   In file included from include/linux/bvec.h:10:
   In file included from include/linux/highmem.h:12:
   In file included from include/linux/hardirq.h:11:
   In file included from arch/um/include/asm/hardirq.h:5:
   In file included from include/asm-generic/hardirq.h:17:
   In file included from include/linux/irq.h:20:
   In file included from include/linux/io.h:13:
   In file included from arch/um/include/asm/io.h:24:
   include/asm-generic/io.h:584:33: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           __raw_writeb(value, PCI_IOBASE + addr);
                               ~~~~~~~~~~ ^
   include/asm-generic/io.h:594:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           __raw_writew((u16 __force)cpu_to_le16(value), PCI_IOBASE + addr);
                                                         ~~~~~~~~~~ ^
   include/asm-generic/io.h:604:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           __raw_writel((u32 __force)cpu_to_le32(value), PCI_IOBASE + addr);
                                                         ~~~~~~~~~~ ^
   include/asm-generic/io.h:692:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           readsb(PCI_IOBASE + addr, buffer, count);
                  ~~~~~~~~~~ ^
   include/asm-generic/io.h:700:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           readsw(PCI_IOBASE + addr, buffer, count);
                  ~~~~~~~~~~ ^
   include/asm-generic/io.h:708:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           readsl(PCI_IOBASE + addr, buffer, count);
                  ~~~~~~~~~~ ^
   include/asm-generic/io.h:717:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           writesb(PCI_IOBASE + addr, buffer, count);
                   ~~~~~~~~~~ ^
   include/asm-generic/io.h:726:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           writesw(PCI_IOBASE + addr, buffer, count);
                   ~~~~~~~~~~ ^
   include/asm-generic/io.h:735:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           writesl(PCI_IOBASE + addr, buffer, count);
                   ~~~~~~~~~~ ^
   In file included from arch/um/drivers/daemon_kern.c:10:
   In file included from include/linux/netdevice.h:24:
   In file included from include/linux/timer.h:5:
   In file included from include/linux/list.h:11:
   In file included from arch/x86/um/asm/barrier.h:6:
   In file included from arch/x86/include/asm/alternative.h:7:
>> arch/x86/include/asm/asm.h:208:24: warning: no previous extern declaration for non-static variable 'current_stack_pointer' [-Wmissing-variable-declarations]
   register unsigned long current_stack_pointer asm(_ASM_SP);
                          ^
   arch/x86/include/asm/asm.h:208:10: note: declare 'static' if the variable is not intended to be used outside of this translation unit
   register unsigned long current_stack_pointer asm(_ASM_SP);
            ^
   13 warnings generated.
--
   In file included from arch/um/drivers/port_kern.c:7:
   In file included from include/linux/interrupt.h:11:
   In file included from include/linux/hardirq.h:11:
   In file included from arch/um/include/asm/hardirq.h:5:
   In file included from include/asm-generic/hardirq.h:17:
   In file included from include/linux/irq.h:20:
   In file included from include/linux/io.h:13:
   In file included from arch/um/include/asm/io.h:24:
   include/asm-generic/io.h:547:31: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           val = __raw_readb(PCI_IOBASE + addr);
                             ~~~~~~~~~~ ^
   include/asm-generic/io.h:560:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           val = __le16_to_cpu((__le16 __force)__raw_readw(PCI_IOBASE + addr));
                                                           ~~~~~~~~~~ ^
   include/uapi/linux/byteorder/little_endian.h:37:51: note: expanded from macro '__le16_to_cpu'
   #define __le16_to_cpu(x) ((__force __u16)(__le16)(x))
                                                     ^
   In file included from arch/um/drivers/port_kern.c:7:
   In file included from include/linux/interrupt.h:11:
   In file included from include/linux/hardirq.h:11:
   In file included from arch/um/include/asm/hardirq.h:5:
   In file included from include/asm-generic/hardirq.h:17:
   In file included from include/linux/irq.h:20:
   In file included from include/linux/io.h:13:
   In file included from arch/um/include/asm/io.h:24:
   include/asm-generic/io.h:573:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           val = __le32_to_cpu((__le32 __force)__raw_readl(PCI_IOBASE + addr));
                                                           ~~~~~~~~~~ ^
   include/uapi/linux/byteorder/little_endian.h:35:51: note: expanded from macro '__le32_to_cpu'
   #define __le32_to_cpu(x) ((__force __u32)(__le32)(x))
                                                     ^
   In file included from arch/um/drivers/port_kern.c:7:
   In file included from include/linux/interrupt.h:11:
   In file included from include/linux/hardirq.h:11:
   In file included from arch/um/include/asm/hardirq.h:5:
   In file included from include/asm-generic/hardirq.h:17:
   In file included from include/linux/irq.h:20:
   In file included from include/linux/io.h:13:
   In file included from arch/um/include/asm/io.h:24:
   include/asm-generic/io.h:584:33: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           __raw_writeb(value, PCI_IOBASE + addr);
                               ~~~~~~~~~~ ^
   include/asm-generic/io.h:594:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           __raw_writew((u16 __force)cpu_to_le16(value), PCI_IOBASE + addr);
                                                         ~~~~~~~~~~ ^
   include/asm-generic/io.h:604:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           __raw_writel((u32 __force)cpu_to_le32(value), PCI_IOBASE + addr);
                                                         ~~~~~~~~~~ ^
   include/asm-generic/io.h:692:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           readsb(PCI_IOBASE + addr, buffer, count);
                  ~~~~~~~~~~ ^
   include/asm-generic/io.h:700:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           readsw(PCI_IOBASE + addr, buffer, count);
                  ~~~~~~~~~~ ^
   include/asm-generic/io.h:708:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           readsl(PCI_IOBASE + addr, buffer, count);
                  ~~~~~~~~~~ ^
   include/asm-generic/io.h:717:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           writesb(PCI_IOBASE + addr, buffer, count);
                   ~~~~~~~~~~ ^
   include/asm-generic/io.h:726:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           writesw(PCI_IOBASE + addr, buffer, count);
                   ~~~~~~~~~~ ^
   include/asm-generic/io.h:735:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           writesl(PCI_IOBASE + addr, buffer, count);
                   ~~~~~~~~~~ ^
>> arch/um/drivers/port_kern.c:147:14: warning: no previous extern declaration for non-static variable 'port_work' [-Wmissing-variable-declarations]
   DECLARE_WORK(port_work, port_work_proc);
                ^
   arch/um/drivers/port_kern.c:147:1: note: declare 'static' if the variable is not intended to be used outside of this translation unit
   DECLARE_WORK(port_work, port_work_proc);
   ^
   include/linux/workqueue.h:194:2: note: expanded from macro 'DECLARE_WORK'
           struct work_struct n = __WORK_INITIALIZER(n, f)
           ^
   In file included from arch/um/drivers/port_kern.c:6:
   In file included from include/linux/completion.h:12:
   In file included from include/linux/swait.h:5:
   In file included from include/linux/list.h:11:
   In file included from arch/x86/um/asm/barrier.h:6:
   In file included from arch/x86/include/asm/alternative.h:7:
>> arch/x86/include/asm/asm.h:208:24: warning: no previous extern declaration for non-static variable 'current_stack_pointer' [-Wmissing-variable-declarations]
   register unsigned long current_stack_pointer asm(_ASM_SP);
                          ^
   arch/x86/include/asm/asm.h:208:10: note: declare 'static' if the variable is not intended to be used outside of this translation unit
   register unsigned long current_stack_pointer asm(_ASM_SP);
            ^
   14 warnings generated.
--
   In file included from arch/um/drivers/xterm_kern.c:10:
   In file included from arch/um/include/shared/irq_kern.h:9:
   In file included from include/linux/interrupt.h:11:
   In file included from include/linux/hardirq.h:11:
   In file included from arch/um/include/asm/hardirq.h:5:
   In file included from include/asm-generic/hardirq.h:17:
   In file included from include/linux/irq.h:20:
   In file included from include/linux/io.h:13:
   In file included from arch/um/include/asm/io.h:24:
   include/asm-generic/io.h:547:31: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           val = __raw_readb(PCI_IOBASE + addr);
                             ~~~~~~~~~~ ^
   include/asm-generic/io.h:560:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           val = __le16_to_cpu((__le16 __force)__raw_readw(PCI_IOBASE + addr));
                                                           ~~~~~~~~~~ ^
   include/uapi/linux/byteorder/little_endian.h:37:51: note: expanded from macro '__le16_to_cpu'
   #define __le16_to_cpu(x) ((__force __u16)(__le16)(x))
                                                     ^
   In file included from arch/um/drivers/xterm_kern.c:10:
   In file included from arch/um/include/shared/irq_kern.h:9:
   In file included from include/linux/interrupt.h:11:
   In file included from include/linux/hardirq.h:11:
   In file included from arch/um/include/asm/hardirq.h:5:
   In file included from include/asm-generic/hardirq.h:17:
   In file included from include/linux/irq.h:20:
   In file included from include/linux/io.h:13:
   In file included from arch/um/include/asm/io.h:24:
   include/asm-generic/io.h:573:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           val = __le32_to_cpu((__le32 __force)__raw_readl(PCI_IOBASE + addr));
                                                           ~~~~~~~~~~ ^
   include/uapi/linux/byteorder/little_endian.h:35:51: note: expanded from macro '__le32_to_cpu'
   #define __le32_to_cpu(x) ((__force __u32)(__le32)(x))
                                                     ^
   In file included from arch/um/drivers/xterm_kern.c:10:
   In file included from arch/um/include/shared/irq_kern.h:9:
   In file included from include/linux/interrupt.h:11:
   In file included from include/linux/hardirq.h:11:
   In file included from arch/um/include/asm/hardirq.h:5:
   In file included from include/asm-generic/hardirq.h:17:
   In file included from include/linux/irq.h:20:
   In file included from include/linux/io.h:13:
   In file included from arch/um/include/asm/io.h:24:
   include/asm-generic/io.h:584:33: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           __raw_writeb(value, PCI_IOBASE + addr);
                               ~~~~~~~~~~ ^
   include/asm-generic/io.h:594:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           __raw_writew((u16 __force)cpu_to_le16(value), PCI_IOBASE + addr);
                                                         ~~~~~~~~~~ ^
   include/asm-generic/io.h:604:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           __raw_writel((u32 __force)cpu_to_le32(value), PCI_IOBASE + addr);
                                                         ~~~~~~~~~~ ^
   include/asm-generic/io.h:692:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           readsb(PCI_IOBASE + addr, buffer, count);
                  ~~~~~~~~~~ ^
   include/asm-generic/io.h:700:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           readsw(PCI_IOBASE + addr, buffer, count);
                  ~~~~~~~~~~ ^
   include/asm-generic/io.h:708:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           readsl(PCI_IOBASE + addr, buffer, count);
                  ~~~~~~~~~~ ^
   include/asm-generic/io.h:717:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           writesb(PCI_IOBASE + addr, buffer, count);
                   ~~~~~~~~~~ ^
   include/asm-generic/io.h:726:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           writesw(PCI_IOBASE + addr, buffer, count);
                   ~~~~~~~~~~ ^
   include/asm-generic/io.h:735:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           writesl(PCI_IOBASE + addr, buffer, count);
                   ~~~~~~~~~~ ^
   arch/um/drivers/xterm_kern.c:35:5: warning: no previous prototype for function 'xterm_fd' [-Wmissing-prototypes]
   int xterm_fd(int socket, int *pid_out)
       ^
   arch/um/drivers/xterm_kern.c:35:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
   int xterm_fd(int socket, int *pid_out)
   ^
   static 
   In file included from arch/um/drivers/xterm_kern.c:6:
   In file included from include/linux/slab.h:16:
   In file included from include/linux/gfp.h:7:
   In file included from include/linux/mmzone.h:8:
   In file included from include/linux/spinlock.h:56:
   In file included from include/linux/preempt.h:12:
   In file included from include/linux/list.h:11:
   In file included from arch/x86/um/asm/barrier.h:6:
   In file included from arch/x86/include/asm/alternative.h:7:
>> arch/x86/include/asm/asm.h:208:24: warning: no previous extern declaration for non-static variable 'current_stack_pointer' [-Wmissing-variable-declarations]
   register unsigned long current_stack_pointer asm(_ASM_SP);
                          ^
   arch/x86/include/asm/asm.h:208:10: note: declare 'static' if the variable is not intended to be used outside of this translation unit
   register unsigned long current_stack_pointer asm(_ASM_SP);
            ^
   14 warnings generated.
..


vim +/current_stack_pointer +208 arch/x86/include/asm/asm.h

a34746bc43eb63 include/asm-x86/asm.h      H. Peter Anvin  2008-02-04  201  
f5caf621ee3572 arch/x86/include/asm/asm.h Josh Poimboeuf  2017-09-20  202  /*
f5caf621ee3572 arch/x86/include/asm/asm.h Josh Poimboeuf  2017-09-20  203   * This output constraint should be used for any inline asm which has a "call"
f5caf621ee3572 arch/x86/include/asm/asm.h Josh Poimboeuf  2017-09-20  204   * instruction.  Otherwise the asm may be inserted before the frame pointer
f5caf621ee3572 arch/x86/include/asm/asm.h Josh Poimboeuf  2017-09-20  205   * gets set up by the containing function.  If you forget to do this, objtool
f5caf621ee3572 arch/x86/include/asm/asm.h Josh Poimboeuf  2017-09-20  206   * may print a "call without frame pointer save/setup" warning.
f5caf621ee3572 arch/x86/include/asm/asm.h Josh Poimboeuf  2017-09-20  207   */
196bd485ee4f03 arch/x86/include/asm/asm.h Andrey Ryabinin 2017-09-29 @208  register unsigned long current_stack_pointer asm(_ASM_SP);
196bd485ee4f03 arch/x86/include/asm/asm.h Andrey Ryabinin 2017-09-29  209  #define ASM_CALL_CONSTRAINT "+r" (current_stack_pointer)
28b60197b573cd arch/x86/include/asm/asm.h Borislav Petkov 2020-06-04  210  #endif /* __ASSEMBLY__ */
f5caf621ee3572 arch/x86/include/asm/asm.h Josh Poimboeuf  2017-09-20  211
kernel test robot Aug. 8, 2023, 8:03 a.m. UTC | #3
Hi Nick,

kernel test robot noticed the following build errors:

[auto build test ERROR on 52a93d39b17dc7eb98b6aa3edb93943248e03b2f]

url:    https://github.com/intel-lab-lkp/linux/commits/Nick-Desaulniers/Makefile-extrawarn-enable-Wmissing-variable-declarations-for-W-1/20230808-005859
base:   52a93d39b17dc7eb98b6aa3edb93943248e03b2f
patch link:    https://lore.kernel.org/r/20230807-missing_proto-v2-1-3ae2e188bb0c%40google.com
patch subject: [PATCH v2] Makefile.extrawarn: enable -Wmissing-variable-declarations for W=1
config: arm64-randconfig-r013-20230807 (https://download.01.org/0day-ci/archive/20230808/202308081508.EI3CRzQo-lkp@intel.com/config)
compiler: clang version 17.0.0 (https://github.com/llvm/llvm-project.git 4a5ac14ee968ff0ad5d2cc1ffa0299048db4c88a)
reproduce: (https://download.01.org/0day-ci/archive/20230808/202308081508.EI3CRzQo-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202308081508.EI3CRzQo-lkp@intel.com/

All errors (new ones prefixed by >>):

   In file included from lib/test_bitops.c:9:
   In file included from include/linux/module.h:13:
   In file included from include/linux/stat.h:19:
   In file included from include/linux/time.h:60:
   In file included from include/linux/time32.h:13:
   In file included from include/linux/timex.h:67:
   In file included from arch/arm64/include/asm/timex.h:8:
   In file included from arch/arm64/include/asm/arch_timer.h:18:
   In file included from include/linux/smp.h:110:
   In file included from include/linux/preempt.h:79:
   In file included from arch/arm64/include/asm/preempt.h:6:
   In file included from include/linux/thread_info.h:60:
   In file included from arch/arm64/include/asm/thread_info.h:18:
>> arch/arm64/include/asm/stack_pointer.h:8:24: error: no previous extern declaration for non-static variable 'current_stack_pointer' [-Werror,-Wmissing-variable-declarations]
       8 | register unsigned long current_stack_pointer asm ("sp");
         |                        ^
   arch/arm64/include/asm/stack_pointer.h:8:10: note: declare 'static' if the variable is not intended to be used outside of this translation unit
       8 | register unsigned long current_stack_pointer asm ("sp");
         |          ^
   1 error generated.


vim +/current_stack_pointer +8 arch/arm64/include/asm/stack_pointer.h

a9ea0017ebe888 Mark Rutland 2016-11-03  4  
a9ea0017ebe888 Mark Rutland 2016-11-03  5  /*
a9ea0017ebe888 Mark Rutland 2016-11-03  6   * how to get the current stack pointer from C
a9ea0017ebe888 Mark Rutland 2016-11-03  7   */
a9ea0017ebe888 Mark Rutland 2016-11-03 @8  register unsigned long current_stack_pointer asm ("sp");
a9ea0017ebe888 Mark Rutland 2016-11-03  9
Nick Desaulniers Aug. 8, 2023, 4:01 p.m. UTC | #4
On Tue, Aug 8, 2023 at 1:03 AM kernel test robot <lkp@intel.com> wrote:
>
> Hi Nick,
>
> kernel test robot noticed the following build errors:
>
> [auto build test ERROR on 52a93d39b17dc7eb98b6aa3edb93943248e03b2f]
>
> url:    https://github.com/intel-lab-lkp/linux/commits/Nick-Desaulniers/Makefile-extrawarn-enable-Wmissing-variable-declarations-for-W-1/20230808-005859
> base:   52a93d39b17dc7eb98b6aa3edb93943248e03b2f
> patch link:    https://lore.kernel.org/r/20230807-missing_proto-v2-1-3ae2e188bb0c%40google.com
> patch subject: [PATCH v2] Makefile.extrawarn: enable -Wmissing-variable-declarations for W=1
> config: arm64-randconfig-r013-20230807 (https://download.01.org/0day-ci/archive/20230808/202308081508.EI3CRzQo-lkp@intel.com/config)
> compiler: clang version 17.0.0 (https://github.com/llvm/llvm-project.git 4a5ac14ee968ff0ad5d2cc1ffa0299048db4c88a)
> reproduce: (https://download.01.org/0day-ci/archive/20230808/202308081508.EI3CRzQo-lkp@intel.com/reproduce)
>
> If you fix the issue in a separate patch/commit (i.e. not just a new version of
> the same patch/commit), kindly add following tags
> | Reported-by: kernel test robot <lkp@intel.com>
> | Closes: https://lore.kernel.org/oe-kbuild-all/202308081508.EI3CRzQo-lkp@intel.com/
>
> All errors (new ones prefixed by >>):
>
>    In file included from lib/test_bitops.c:9:
>    In file included from include/linux/module.h:13:
>    In file included from include/linux/stat.h:19:
>    In file included from include/linux/time.h:60:
>    In file included from include/linux/time32.h:13:
>    In file included from include/linux/timex.h:67:
>    In file included from arch/arm64/include/asm/timex.h:8:
>    In file included from arch/arm64/include/asm/arch_timer.h:18:
>    In file included from include/linux/smp.h:110:
>    In file included from include/linux/preempt.h:79:
>    In file included from arch/arm64/include/asm/preempt.h:6:
>    In file included from include/linux/thread_info.h:60:
>    In file included from arch/arm64/include/asm/thread_info.h:18:
> >> arch/arm64/include/asm/stack_pointer.h:8:24: error: no previous extern declaration for non-static variable 'current_stack_pointer' [-Werror,-Wmissing-variable-declarations]
>        8 | register unsigned long current_stack_pointer asm ("sp");
>          |                        ^
>    arch/arm64/include/asm/stack_pointer.h:8:10: note: declare 'static' if the variable is not intended to be used outside of this translation unit
>        8 | register unsigned long current_stack_pointer asm ("sp");
>          |          ^

I actually don't think that either compiler should warn for variables
with register storage.  I spoke briefly with some GCC folks on IRC and
the initial assesment was agreed.  I've filed
- https://github.com/llvm/llvm-project/issues/64509
- https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110947

Also, I've received 3 emails from zero day; this is expected as the
tree is not W=1 clean (actually, I think Arnd has been a lot of
cleanup around these groups of warnings, so I take that back).  What's
more curious to me is that none are GCC builds. I wonder if 0day bot
team is only testing W=1 with clang and not GCC?  That would seem like
perhaps the bar is higher for LLVM?

Masahiro, Nathan,
What are your thoughts on how to proceed here? Do we need the tree to
be free of warnings before it can be added to W=1? Hopefully not; I
would think that's the criteria for promoting a warning from being
hidden behind W=1 to being on by default in the top level Makefile.
What are your thoughts?

>    1 error generated.
>
>
> vim +/current_stack_pointer +8 arch/arm64/include/asm/stack_pointer.h
>
> a9ea0017ebe888 Mark Rutland 2016-11-03  4
> a9ea0017ebe888 Mark Rutland 2016-11-03  5  /*
> a9ea0017ebe888 Mark Rutland 2016-11-03  6   * how to get the current stack pointer from C
> a9ea0017ebe888 Mark Rutland 2016-11-03  7   */
> a9ea0017ebe888 Mark Rutland 2016-11-03 @8  register unsigned long current_stack_pointer asm ("sp");
> a9ea0017ebe888 Mark Rutland 2016-11-03  9
>
> --
> 0-DAY CI Kernel Test Service
> https://github.com/intel/lkp-tests/wiki
Nathan Chancellor Aug. 8, 2023, 4:17 p.m. UTC | #5
On Tue, Aug 08, 2023 at 09:01:38AM -0700, Nick Desaulniers wrote:
> On Tue, Aug 8, 2023 at 1:03 AM kernel test robot <lkp@intel.com> wrote:
> >
> > Hi Nick,
> >
> > kernel test robot noticed the following build errors:
> >
> > [auto build test ERROR on 52a93d39b17dc7eb98b6aa3edb93943248e03b2f]
> >
> > url:    https://github.com/intel-lab-lkp/linux/commits/Nick-Desaulniers/Makefile-extrawarn-enable-Wmissing-variable-declarations-for-W-1/20230808-005859
> > base:   52a93d39b17dc7eb98b6aa3edb93943248e03b2f
> > patch link:    https://lore.kernel.org/r/20230807-missing_proto-v2-1-3ae2e188bb0c%40google.com
> > patch subject: [PATCH v2] Makefile.extrawarn: enable -Wmissing-variable-declarations for W=1
> > config: arm64-randconfig-r013-20230807 (https://download.01.org/0day-ci/archive/20230808/202308081508.EI3CRzQo-lkp@intel.com/config)
> > compiler: clang version 17.0.0 (https://github.com/llvm/llvm-project.git 4a5ac14ee968ff0ad5d2cc1ffa0299048db4c88a)
> > reproduce: (https://download.01.org/0day-ci/archive/20230808/202308081508.EI3CRzQo-lkp@intel.com/reproduce)
> >
> > If you fix the issue in a separate patch/commit (i.e. not just a new version of
> > the same patch/commit), kindly add following tags
> > | Reported-by: kernel test robot <lkp@intel.com>
> > | Closes: https://lore.kernel.org/oe-kbuild-all/202308081508.EI3CRzQo-lkp@intel.com/
> >
> > All errors (new ones prefixed by >>):
> >
> >    In file included from lib/test_bitops.c:9:
> >    In file included from include/linux/module.h:13:
> >    In file included from include/linux/stat.h:19:
> >    In file included from include/linux/time.h:60:
> >    In file included from include/linux/time32.h:13:
> >    In file included from include/linux/timex.h:67:
> >    In file included from arch/arm64/include/asm/timex.h:8:
> >    In file included from arch/arm64/include/asm/arch_timer.h:18:
> >    In file included from include/linux/smp.h:110:
> >    In file included from include/linux/preempt.h:79:
> >    In file included from arch/arm64/include/asm/preempt.h:6:
> >    In file included from include/linux/thread_info.h:60:
> >    In file included from arch/arm64/include/asm/thread_info.h:18:
> > >> arch/arm64/include/asm/stack_pointer.h:8:24: error: no previous extern declaration for non-static variable 'current_stack_pointer' [-Werror,-Wmissing-variable-declarations]
> >        8 | register unsigned long current_stack_pointer asm ("sp");
> >          |                        ^
> >    arch/arm64/include/asm/stack_pointer.h:8:10: note: declare 'static' if the variable is not intended to be used outside of this translation unit
> >        8 | register unsigned long current_stack_pointer asm ("sp");
> >          |          ^
> 
> I actually don't think that either compiler should warn for variables
> with register storage.  I spoke briefly with some GCC folks on IRC and
> the initial assesment was agreed.  I've filed
> - https://github.com/llvm/llvm-project/issues/64509
> - https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110947
> 
> Also, I've received 3 emails from zero day; this is expected as the
> tree is not W=1 clean (actually, I think Arnd has been a lot of
> cleanup around these groups of warnings, so I take that back).  What's
> more curious to me is that none are GCC builds. I wonder if 0day bot
> team is only testing W=1 with clang and not GCC?  That would seem like
> perhaps the bar is higher for LLVM?

As far as I am aware, the 0day bot tests both compilers with W=1. I
think the more likely explanation is that the robot is not testing with
prerelease versions of GCC, which is currently 14.x, which is the only
version of GCC that has this warning implemented.

> Masahiro, Nathan,
> What are your thoughts on how to proceed here? Do we need the tree to
> be free of warnings before it can be added to W=1? Hopefully not; I

No, otherwise we wouldn't be adding it to W=1 ;)

> would think that's the criteria for promoting a warning from being
> hidden behind W=1 to being on by default in the top level Makefile.
> What are your thoughts?

I think the register storage issue should be resolved in at least clang
before this patch is accepted, as that seems to be where the majority of
warnings are coming from so far. Like we talked about, I'll take a shot
at fixing that. Once that is fixed, I'll build mainline with
-Wmissing-variable-declarations to see how many instances there are and
if there are any other interesting edge cases that should be fixed in
the compiler. After that, I think this should be good to go in. Does
that sound reasonable?

Cheers,
Nathan
Masahiro Yamada Aug. 8, 2023, 6:41 p.m. UTC | #6
On Wed, Aug 9, 2023 at 1:17 AM Nathan Chancellor <nathan@kernel.org> wrote:
>
> On Tue, Aug 08, 2023 at 09:01:38AM -0700, Nick Desaulniers wrote:
> > On Tue, Aug 8, 2023 at 1:03 AM kernel test robot <lkp@intel.com> wrote:
> > >
> > > Hi Nick,
> > >
> > > kernel test robot noticed the following build errors:
> > >
> > > [auto build test ERROR on 52a93d39b17dc7eb98b6aa3edb93943248e03b2f]
> > >
> > > url:    https://github.com/intel-lab-lkp/linux/commits/Nick-Desaulniers/Makefile-extrawarn-enable-Wmissing-variable-declarations-for-W-1/20230808-005859
> > > base:   52a93d39b17dc7eb98b6aa3edb93943248e03b2f
> > > patch link:    https://lore.kernel.org/r/20230807-missing_proto-v2-1-3ae2e188bb0c%40google.com
> > > patch subject: [PATCH v2] Makefile.extrawarn: enable -Wmissing-variable-declarations for W=1
> > > config: arm64-randconfig-r013-20230807 (https://download.01.org/0day-ci/archive/20230808/202308081508.EI3CRzQo-lkp@intel.com/config)
> > > compiler: clang version 17.0.0 (https://github.com/llvm/llvm-project.git 4a5ac14ee968ff0ad5d2cc1ffa0299048db4c88a)
> > > reproduce: (https://download.01.org/0day-ci/archive/20230808/202308081508.EI3CRzQo-lkp@intel.com/reproduce)
> > >
> > > If you fix the issue in a separate patch/commit (i.e. not just a new version of
> > > the same patch/commit), kindly add following tags
> > > | Reported-by: kernel test robot <lkp@intel.com>
> > > | Closes: https://lore.kernel.org/oe-kbuild-all/202308081508.EI3CRzQo-lkp@intel.com/
> > >
> > > All errors (new ones prefixed by >>):
> > >
> > >    In file included from lib/test_bitops.c:9:
> > >    In file included from include/linux/module.h:13:
> > >    In file included from include/linux/stat.h:19:
> > >    In file included from include/linux/time.h:60:
> > >    In file included from include/linux/time32.h:13:
> > >    In file included from include/linux/timex.h:67:
> > >    In file included from arch/arm64/include/asm/timex.h:8:
> > >    In file included from arch/arm64/include/asm/arch_timer.h:18:
> > >    In file included from include/linux/smp.h:110:
> > >    In file included from include/linux/preempt.h:79:
> > >    In file included from arch/arm64/include/asm/preempt.h:6:
> > >    In file included from include/linux/thread_info.h:60:
> > >    In file included from arch/arm64/include/asm/thread_info.h:18:
> > > >> arch/arm64/include/asm/stack_pointer.h:8:24: error: no previous extern declaration for non-static variable 'current_stack_pointer' [-Werror,-Wmissing-variable-declarations]
> > >        8 | register unsigned long current_stack_pointer asm ("sp");
> > >          |                        ^
> > >    arch/arm64/include/asm/stack_pointer.h:8:10: note: declare 'static' if the variable is not intended to be used outside of this translation unit
> > >        8 | register unsigned long current_stack_pointer asm ("sp");
> > >          |          ^
> >
> > I actually don't think that either compiler should warn for variables
> > with register storage.  I spoke briefly with some GCC folks on IRC and
> > the initial assesment was agreed.  I've filed
> > - https://github.com/llvm/llvm-project/issues/64509
> > - https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110947
> >
> > Also, I've received 3 emails from zero day; this is expected as the
> > tree is not W=1 clean (actually, I think Arnd has been a lot of
> > cleanup around these groups of warnings, so I take that back).  What's
> > more curious to me is that none are GCC builds. I wonder if 0day bot
> > team is only testing W=1 with clang and not GCC?  That would seem like
> > perhaps the bar is higher for LLVM?
>
> As far as I am aware, the 0day bot tests both compilers with W=1. I
> think the more likely explanation is that the robot is not testing with
> prerelease versions of GCC, which is currently 14.x, which is the only
> version of GCC that has this warning implemented.
>
> > Masahiro, Nathan,
> > What are your thoughts on how to proceed here? Do we need the tree to
> > be free of warnings before it can be added to W=1? Hopefully not; I
>
> No, otherwise we wouldn't be adding it to W=1 ;)
>
> > would think that's the criteria for promoting a warning from being
> > hidden behind W=1 to being on by default in the top level Makefile.
> > What are your thoughts?
>
> I think the register storage issue should be resolved in at least clang
> before this patch is accepted, as that seems to be where the majority of
> warnings are coming from so far. Like we talked about, I'll take a shot
> at fixing that. Once that is fixed, I'll build mainline with
> -Wmissing-variable-declarations to see how many instances there are and
> if there are any other interesting edge cases that should be fixed in
> the compiler. After that, I think this should be good to go in. Does
> that sound reasonable?


Sounds reasonable!
Thank you.
Nathan Chancellor Aug. 9, 2023, 3:42 p.m. UTC | #7
On Tue, Aug 08, 2023 at 09:17:07AM -0700, Nathan Chancellor wrote:
> I think the register storage issue should be resolved in at least clang
> before this patch is accepted, as that seems to be where the majority of
> warnings are coming from so far. Like we talked about, I'll take a shot
> at fixing that. Once that is fixed, I'll build mainline with
> -Wmissing-variable-declarations to see how many instances there are and
> if there are any other interesting edge cases that should be fixed in
> the compiler. After that, I think this should be good to go in. Does
> that sound reasonable?

I don't think there are any other edge cases from the brief glance I
gave my build logs but my matrix counts 700+ unique instances of this
(give or take some, due to interleaving issues). Quite a few but I see
several in certain files so it might not actually be too bad.

Cheers,
Nathan
diff mbox series

Patch

diff --git a/scripts/Makefile.extrawarn b/scripts/Makefile.extrawarn
index 40cd13eca82e..18ce75c5c384 100644
--- a/scripts/Makefile.extrawarn
+++ b/scripts/Makefile.extrawarn
@@ -32,6 +32,7 @@  KBUILD_CFLAGS += $(call cc-option, -Wunused-but-set-variable)
 KBUILD_CFLAGS += $(call cc-option, -Wunused-const-variable)
 KBUILD_CFLAGS += $(call cc-option, -Wpacked-not-aligned)
 KBUILD_CFLAGS += $(call cc-option, -Wstringop-truncation)
+KBUILD_CFLAGS += $(call cc-option, -Wmissing-variable-declarations)
 # The following turn off the warnings enabled by -Wextra
 KBUILD_CFLAGS += -Wno-missing-field-initializers
 KBUILD_CFLAGS += -Wno-sign-compare