Since 5.0.2 release gcc-9.0.1 fails to compile kernel with -march= option with the following output: <...> CC arch/x86/entry/vdso/vma.o In file included from ./arch/x86/include/asm/atomic.h:265, from ./arch/x86/include/asm/msr.h:67, from ./arch/x86/include/asm/processor.h:21, from ./arch/x86/include/asm/cpufeature.h:5, from ./arch/x86/include/asm/thread_info.h:53, from ./include/linux/thread_info.h:38, from ./arch/x86/include/asm/preempt.h:7, from ./include/linux/preempt.h:78, from ./include/linux/spinlock.h:51, from ./include/linux/mmzone.h:8, from ./include/linux/gfp.h:6, from ./include/linux/mm.h:10, from arch/x86/entry/vdso/vma.c:7: ./arch/x86/include/asm/mshyperv.h: In function ‘vmbus_signal_eom’: ./arch/x86/include/asm/mshyperv.h:61:14: warning: taking address of packed member of ‘struct hv_message_header’ may result in an unaligned pointer value [-Waddress-of-packed-member] 61 | if (cmpxchg(&msg->header.message_type, old_msg_type, ./include/asm-generic/atomic-instrumented.h:420:26: note: in definition of macro ‘cmpxchg’ 420 | typeof(ptr) __ai_ptr = (ptr); \ | ^~~ CC arch/x86/entry/vdso/vdso32-setup.o LDS arch/x86/entry/vdso/vdso.lds AS arch/x86/entry/vdso/vdso-note.o CC arch/x86/entry/vdso/vclock_gettime.o In file included from ./arch/x86/include/asm/atomic.h:265, from ./arch/x86/include/asm/msr.h:67, from ./arch/x86/include/asm/processor.h:21, from ./arch/x86/include/asm/cpufeature.h:5, from ./arch/x86/include/asm/thread_info.h:53, from ./include/linux/thread_info.h:38, from ./arch/x86/include/asm/preempt.h:7, from ./include/linux/preempt.h:78, from ./include/linux/spinlock.h:51, from ./include/linux/seqlock.h:36, from ./include/linux/time.h:6, from ./include/uapi/linux/timex.h:56, from ./include/linux/timex.h:56, from ./include/linux/clocksource.h:13, from ./arch/x86/include/asm/vgtod.h:6, from arch/x86/entry/vdso/vclock_gettime.c:15: ./arch/x86/include/asm/mshyperv.h: In function ‘vmbus_signal_eom’: ./arch/x86/include/asm/mshyperv.h:61:14: warning: taking address of packed member of ‘struct hv_message_header’ may result in an unaligned pointer value [-Waddress-of-packed-member] 61 | if (cmpxchg(&msg->header.message_type, old_msg_type, ./include/asm-generic/atomic-instrumented.h:420:26: note: in definition of macro ‘cmpxchg’ 420 | typeof(ptr) __ai_ptr = (ptr); \ | ^~~ CC arch/x86/entry/vdso/vgetcpu.o VDSO arch/x86/entry/vdso/vdso64.so.dbg OBJCOPY arch/x86/entry/vdso/vdso64.so HOSTCC arch/x86/entry/vdso/vdso2c VDSO2C arch/x86/entry/vdso/vdso-image-64.c CC arch/x86/entry/vdso/vdso-image-64.o LDS arch/x86/entry/vdso/vdso32/vdso32.lds CC arch/x86/entry/vdso/vdso32/vclock_gettime.o In file included from ./arch/x86/include/asm/atomic.h:265, from ./arch/x86/include/asm/msr.h:67, from ./arch/x86/include/asm/processor.h:21, from ./arch/x86/include/asm/cpufeature.h:5, from ./arch/x86/include/asm/thread_info.h:53, from ./include/linux/thread_info.h:38, from ./arch/x86/include/asm/preempt.h:7, from ./include/linux/preempt.h:78, from ./include/linux/spinlock.h:51, from ./include/linux/seqlock.h:36, from ./include/linux/time.h:6, from ./include/uapi/linux/timex.h:56, from ./include/linux/timex.h:56, from ./include/linux/clocksource.h:13, from ./arch/x86/include/asm/vgtod.h:6, from arch/x86/entry/vdso/vdso32/../vclock_gettime.c:15, from arch/x86/entry/vdso/vdso32/vclock_gettime.c:31: ./arch/x86/include/asm/mshyperv.h: In function ‘vmbus_signal_eom’: ./arch/x86/include/asm/mshyperv.h:61:14: warning: taking address of packed member of ‘struct hv_message_header’ may result in an unaligned pointer value [-Waddress-of-packed-member] 61 | if (cmpxchg(&msg->header.message_type, old_msg_type, ./include/asm-generic/atomic-instrumented.h:420:26: note: in definition of macro ‘cmpxchg’ 420 | typeof(ptr) __ai_ptr = (ptr); \ | ^~~ AS arch/x86/entry/vdso/vdso32/note.o AS arch/x86/entry/vdso/vdso32/system_call.o AS arch/x86/entry/vdso/vdso32/sigreturn.o VDSO arch/x86/entry/vdso/vdso32.so.dbg OBJCOPY arch/x86/entry/vdso/vdso32.so VDSO2C arch/x86/entry/vdso/vdso-image-32.c CC arch/x86/entry/vdso/vdso-image-32.o AR arch/x86/entry/vdso/built-in.a CC arch/x86/entry/vsyscall/vsyscall_gtod.o CC arch/x86/entry/vsyscall/vsyscall_64.o AS arch/x86/entry/vsyscall/vsyscall_emu_64.o AR arch/x86/entry/vsyscall/built-in.a AS arch/x86/entry/entry_64.o AS arch/x86/entry/thunk_64.o CC arch/x86/entry/syscall_64.o CC arch/x86/entry/common.o AS arch/x86/entry/entry_64_compat.o CC arch/x86/entry/syscall_32.o AR arch/x86/entry/built-in.a CC arch/x86/events/amd/core.o In file included from arch/x86/events/amd/core.c:8: arch/x86/events/amd/../perf_event.h:1035:45: warning: ‘struct cpu_hw_event’ declared inside parameter list will not be visible outside of this definition or declaration 1035 | static inline int intel_cpuc_prepare(struct cpu_hw_event *cpuc, int cpu) | ^~~~~~~~~~~~ arch/x86/events/amd/../perf_event.h:1040:45: warning: ‘struct cpu_hw_event’ declared inside parameter list will not be visible outside of this definition or declaration 1040 | static inline void intel_cpuc_finish(struct cpu_hw_event *cpuc) | ^~~~~~~~~~~~ CC arch/x86/events/amd/uncore.o CC arch/x86/events/amd/ibs.o In file included from arch/x86/events/amd/ibs.c:19: arch/x86/events/amd/../perf_event.h:1035:45: warning: ‘struct cpu_hw_event’ declared inside parameter list will not be visible outside of this definition or declaration 1035 | static inline int intel_cpuc_prepare(struct cpu_hw_event *cpuc, int cpu) | ^~~~~~~~~~~~ arch/x86/events/amd/../perf_event.h:1040:45: warning: ‘struct cpu_hw_event’ declared inside parameter list will not be visible outside of this definition or declaration 1040 | static inline void intel_cpuc_finish(struct cpu_hw_event *cpuc) | ^~~~~~~~~~~~ CC arch/x86/events/amd/iommu.o In file included from arch/x86/events/amd/iommu.c:21: arch/x86/events/amd/../perf_event.h:1035:45: warning: ‘struct cpu_hw_event’ declared inside parameter list will not be visible outside of this definition or declaration 1035 | static inline int intel_cpuc_prepare(struct cpu_hw_event *cpuc, int cpu) | ^~~~~~~~~~~~ arch/x86/events/amd/../perf_event.h:1040:45: warning: ‘struct cpu_hw_event’ declared inside parameter list will not be visible outside of this definition or declaration 1040 | static inline void intel_cpuc_finish(struct cpu_hw_event *cpuc) | ^~~~~~~~~~~~ AR arch/x86/events/amd/built-in.a CC [M] arch/x86/events/amd/power.o In file included from arch/x86/events/amd/power.c:17: arch/x86/events/amd/../perf_event.h:1035:45: warning: ‘struct cpu_hw_event’ declared inside parameter list will not be visible outside of this definition or declaration 1035 | static inline int intel_cpuc_prepare(struct cpu_hw_event *cpuc, int cpu) | ^~~~~~~~~~~~ arch/x86/events/amd/../perf_event.h:1040:45: warning: ‘struct cpu_hw_event’ declared inside parameter list will not be visible outside of this definition or declaration 1040 | static inline void intel_cpuc_finish(struct cpu_hw_event *cpuc) | ^~~~~~~~~~~~ CC arch/x86/events/core.o In file included from arch/x86/events/core.c:44: arch/x86/events/perf_event.h:1035:45: warning: ‘struct cpu_hw_event’ declared inside parameter list will not be visible outside of this definition or declaration 1035 | static inline int intel_cpuc_prepare(struct cpu_hw_event *cpuc, int cpu) | ^~~~~~~~~~~~ arch/x86/events/perf_event.h:1040:45: warning: ‘struct cpu_hw_event’ declared inside parameter list will not be visible outside of this definition or declaration 1040 | static inline void intel_cpuc_finish(struct cpu_hw_event *cpuc) | ^~~~~~~~~~~~ arch/x86/events/core.c: In function ‘free_fake_cpuc’: arch/x86/events/core.c:1998:20: error: passing argument 1 of ‘intel_cpuc_finish’ from incompatible pointer type [-Werror=incompatible-pointer-types] 1998 | intel_cpuc_finish(cpuc); | ^~~~ | | | struct cpu_hw_events * In file included from arch/x86/events/core.c:44: arch/x86/events/perf_event.h:1040:59: note: expected ‘struct cpu_hw_event *’ but argument is of type ‘struct cpu_hw_events *’ 1040 | static inline void intel_cpuc_finish(struct cpu_hw_event *cpuc) | ~~~~~~~~~~~~~~~~~~~~~^~~~ arch/x86/events/core.c: In function ‘allocate_fake_cpuc’: arch/x86/events/core.c:2012:25: error: passing argument 1 of ‘intel_cpuc_prepare’ from incompatible pointer type [-Werror=incompatible-pointer-types] 2012 | if (intel_cpuc_prepare(cpuc, cpu)) | ^~~~ | | | struct cpu_hw_events * In file included from arch/x86/events/core.c:44: arch/x86/events/perf_event.h:1035:59: note: expected ‘struct cpu_hw_event *’ but argument is of type ‘struct cpu_hw_events *’ 1035 | static inline int intel_cpuc_prepare(struct cpu_hw_event *cpuc, int cpu) | ~~~~~~~~~~~~~~~~~~~~~^~~~ cc1: some warnings being treated as errors make[2]: *** [scripts/Makefile.build:277: arch/x86/events/core.o] Error 1 make[1]: *** [scripts/Makefile.build:492: arch/x86/events] Error 2 make: *** [Makefile:1043: arch/x86] Error 2
Kernel 5.0.1 compiles well under the same conditions.
Vlad, you might want to see these: https://bugzilla.kernel.org/show_bug.cgi?id=202923 and the original fix provided by mmelchert: https://bugzilla.kernel.org/show_bug.cgi?id=202917
*** This bug has been marked as a duplicate of bug 202917 ***