Building 6.12.1 with -O3 causes error but -O2 is fine ... why?

I'd like to compiled 6.12-rc7 for x86/64. I applied the WIP PR#16547 but am finding that the kernel compilation fails with the following error. Wondering if anyone has some thoughts to circumvent it.

EDIT: the source of this error is the following in my .config:

CONFIG_KERNEL_CFLAGS="-march=x86-64-v3 -O3 -pipe"

If I replace the -O3 with -O2 I do not see the error. Why?

In file included from ./include/linux/string.h:390,
                 from ./include/linux/bitmap.h:13,
                 from ./include/linux/cpumask.h:12,
                 from ./arch/x86/include/asm/paravirt.h:21,
                 from ./arch/x86/include/asm/irqflags.h:80,
                 from ./include/linux/irqflags.h:18,
                 from ./include/linux/spinlock.h:59,
                 from ./include/linux/swait.h:7,
                 from ./include/linux/completion.h:12,
                 from kernel/padata.c:14:
In function 'bitmap_copy',
    inlined from 'cpumask_copy' at ./include/linux/cpumask.h:839:2,
    inlined from '__padata_set_cpumasks' at kernel/padata.c:730:2:
./include/linux/fortify-string.h:114:33: error: '__builtin_memcpy' reading between 65 and 536870904 bytes from a region of size 64 [-Werror=stringop-overread]
  114 | #define __underlying_memcpy     __builtin_memcpy
      |                                 ^
./include/linux/fortify-string.h:633:9: note: in expansion of macro '__underlying_memcpy'
  633 |         __underlying_##op(p, q, __fortify_size);                        \
      |         ^~~~~~~~~~~~~
./include/linux/fortify-string.h:678:26: note: in expansion of macro '__fortify_memcpy_chk'
  678 | #define memcpy(p, q, s)  __fortify_memcpy_chk(p, q, s,                  \
      |                          ^~~~~~~~~~~~~~~~~~~~
./include/linux/bitmap.h:259:17: note: in expansion of macro 'memcpy'
  259 |                 memcpy(dst, src, len);
      |                 ^~~~~~
kernel/padata.c: In function '__padata_set_cpumasks':
kernel/padata.c:713:48: note: source object 'pcpumask' of size [0, 64]
  713 |                                  cpumask_var_t pcpumask,
      |                                  ~~~~~~~~~~~~~~^~~~~~~~
In function 'bitmap_copy',
    inlined from 'cpumask_copy' at ./include/linux/cpumask.h:839:2,
    inlined from '__padata_set_cpumasks' at kernel/padata.c:730:2:
./include/linux/fortify-string.h:114:33: error: '__builtin_memcpy' reading between 65 and 536870904 bytes from a region of size 64 [-Werror=stringop-overread]
  114 | #define __underlying_memcpy     __builtin_memcpy
      |                                 ^
./include/linux/fortify-string.h:633:9: note: in expansion of macro '__underlying_memcpy'
  633 |         __underlying_##op(p, q, __fortify_size);                        \
      |         ^~~~~~~~~~~~~
./include/linux/fortify-string.h:678:26: note: in expansion of macro '__fortify_memcpy_chk'
  678 | #define memcpy(p, q, s)  __fortify_memcpy_chk(p, q, s,                  \
      |                          ^~~~~~~~~~~~~~~~~~~~
./include/linux/bitmap.h:259:17: note: in expansion of macro 'memcpy'
  259 |                 memcpy(dst, src, len);
      |                 ^~~~~~
kernel/padata.c: In function '__padata_set_cpumasks':
kernel/padata.c:713:48: note: source object 'pcpumask' of size [0, 64]
  713 |                                  cpumask_var_t pcpumask,
      |                                  ~~~~~~~~~~~~~~^~~~~~~~
  CC      drivers/usb/host/xhci-ext-caps.o
  AR      drivers/media/platform/st/sti/hva/built-in.a
  CC      drivers/usb/host/xhci-ring.o
  AR      drivers/media/platform/st/stm32/built-in.a
  CC      drivers/acpi/acpica/nsparse.o
  CC      fs/proc/kcore.o
  CC [M]  net/netfilter/nf_flow_table_inet.o
  AR      drivers/media/platform/st/built-in.a
  CC      drivers/ptp/ptp_sysfs.o
  CC [M]  drivers/i2c/i2c-smbus.o
  AR      drivers/media/platform/sunxi/sun4i-csi/built-in.a
  AR      drivers/media/platform/sunxi/sun6i-csi/built-in.a
  AR      drivers/media/platform/sunxi/sun6i-mipi-csi2/built-in.a
cc1: all warnings being treated as errors
  AR      drivers/media/platform/sunxi/sun8i-a83t-mipi-csi2/built-in.a
make[8]: *** [scripts/Makefile.build:229: kernel/padata.o] Error 1

Fixed, redownload PR#16547

1 Like