Created attachment 306623 [details] Build log Hello, when compiling linux kernel 6.9-6.10 with -flto compiler outputs: ./arch/x86/include/asm/current.h:42:25: error: 'const_pcpu_hot' causes a section type conflict with 'pcpu_hot' const_pcpu_hot); I have attached a buildlog.
(In reply to mrwizardwizard from comment #0) > Created attachment 306623 [details] > Build log > > Hello, > > when compiling linux kernel 6.9-6.10 with -flto > > compiler outputs: > > ./arch/x86/include/asm/current.h:42:25: error: 'const_pcpu_hot' causes a > section type conflict with 'pcpu_hot' const_pcpu_hot); > Can you reproduce above on current mainline (v6.11-rc1)?
(In reply to Bagas Sanjaya from comment #1) > (In reply to mrwizardwizard from comment #0) > > Created attachment 306623 [details] > > Build log > > > > Hello, > > > > when compiling linux kernel 6.9-6.10 with -flto > > > > compiler outputs: > > > > ./arch/x86/include/asm/current.h:42:25: error: 'const_pcpu_hot' causes a > > section type conflict with 'pcpu_hot' const_pcpu_hot); > > > > Can you reproduce above on current mainline (v6.11-rc1)? same messages mkdir -p /home/mrwizardwizard/Documents/Kernel/linux-6.11-rc1/tools/objtool && make O=/home/mrwizardwizard/Documents/Kernel/linux-6.11-rc1 subdir=tools/objtool --no-print-directory -C objtool INSTALL libsubcmd_headers CALL scripts/checksyscalls.sh CC init/main.o AS arch/x86/entry/entry.o AS arch/x86/entry/entry_64.o arch/x86/entry/entry_64.o: warning: objtool: __switch_to_asm+0x18: stack layout conflict in alternatives: .altinstr_replacement+0x1d CC arch/x86/entry/syscall_64.o In file included from ./include/asm-generic/percpu.h:7, from ./arch/x86/include/asm/percpu.h:616, from ./arch/x86/include/asm/current.h:11, from ./arch/x86/include/asm/processor.h:17, from ./arch/x86/include/asm/timex.h:5, from ./include/linux/timex.h:67, from ./include/linux/time32.h:13, from ./include/linux/time.h:60, from ./include/linux/stat.h:19, from ./include/linux/module.h:13, from init/main.c:17: ./arch/x86/include/asm/current.h:42:25: error: 'const_pcpu_hot' causes a section type conflict with 'pcpu_hot' 42 | const_pcpu_hot); | ^~~~~~~~~~~~~~ ./arch/x86/include/asm/current.h:38:42: note: 'pcpu_hot' was declared here 38 | DECLARE_PER_CPU_ALIGNED(struct pcpu_hot, pcpu_hot); | ^~~~~~~~ make[3]: *** [scripts/Makefile.build:244: init/main.o] Error 1 make[2]: *** [scripts/Makefile.build:485: init] Error 2 make[2]: *** Waiting for unfinished jobs.... CC arch/x86/entry/common.o CC arch/x86/events/core.o CC arch/x86/entry/vdso/vma.o In file included from ./include/asm-generic/percpu.h:7, from ./arch/x86/include/asm/percpu.h:616, from ./arch/x86/include/asm/current.h:11, from ./include/linux/sched.h:12, from ./include/linux/ptrace.h:6, from ./include/uapi/asm-generic/bpf_perf_event.h:4, from ./arch/x86/include/generated/uapi/asm/bpf_perf_event.h:1, from ./include/uapi/linux/bpf_perf_event.h:11, from ./include/linux/perf_event.h:18, from arch/x86/events/core.c:15: ./arch/x86/include/asm/current.h:42:25: error: 'const_pcpu_hot' causes a section type conflict with 'pcpu_hot' 42 | const_pcpu_hot); | ^~~~~~~~~~~~~~ ./arch/x86/include/asm/current.h:38:42: note: 'pcpu_hot' was declared here 38 | DECLARE_PER_CPU_ALIGNED(struct pcpu_hot, pcpu_hot); | ^~~~~~~~ make[4]: *** [scripts/Makefile.build:244: arch/x86/events/core.o] Error 1 make[3]: *** [scripts/Makefile.build:485: arch/x86/events] Error 2 make[3]: *** Waiting for unfinished jobs.... AR arch/x86/entry/vsyscall/built-in.a CC arch/x86/entry/vdso/extable.o LDS arch/x86/entry/vdso/vdso.lds AS arch/x86/entry/vdso/vdso-note.o CC arch/x86/entry/vdso/vclock_gettime.o CC arch/x86/entry/vdso/vgetcpu.o CC arch/x86/entry/vdso/vgetrandom.o AS arch/x86/entry/vdso/vgetrandom-chacha.o HOSTCC arch/x86/entry/vdso/vdso2c VDSO arch/x86/entry/vdso/vdso64.so.dbg OBJCOPY arch/x86/entry/vdso/vdso64.so VDSO2C arch/x86/entry/vdso/vdso-image-64.c CC arch/x86/entry/vdso/vdso-image-64.o AR arch/x86/entry/vdso/built-in.a AS arch/x86/entry/thunk.o AR arch/x86/entry/built-in.a make[2]: *** [scripts/Makefile.build:485: arch/x86] Error 2 make[1]: *** [/home/mrwizardwizard/Documents/Kernel/linux-6.11-rc1/Makefile:1927: .] Error 2 make: *** [Makefile:224: __sub-make] Error 2
Please attach your .config.
Created attachment 306663 [details] kernel .config
(In reply to mrwizardwizard from comment #0) > when compiling linux kernel 6.9-6.10 with -flto You need a whole lot more patches to successfully compile kernel with GCC LTO. The last revision can be found at: https://lore.kernel.org/lkml/20221114114344.18650-1-jirislaby@kernel.org/ The patchset defines CONFIG_LTO, which can be used to disable offending optimization, something like the to-be attached patch. Ideally, a LTO-compatible "const __seg_gs" qualified alias to struct pcpu_hot should be declared, so LTO can retain the disabled optimization, but ... ... the LTO patchset was rejected mainly due to: - the performance is the same - the resulting image is bigger - we need a whole lot of ugly hacks to placate the linker.
Created attachment 306665 [details] Patch to disable offending optimization for CONFIG_LTO Untested patch.