Re: Fwd: error: 'const_pcpu_hot' causes a section type conflict with 'pcpu_hot' when compiling with -flto
From: Uros Bizjak
Date: Wed Aug 07 2024 - 10:39:06 EST
On Wed, Aug 7, 2024 at 4:08 PM Thomas Gleixner <tglx@xxxxxxxxxxxxx> wrote:
>
> On Sat, Aug 03 2024 at 10:55, Bagas Sanjaya wrote:
> >> 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);
> >
> > He could reproduce the build error on mainline:
>
> That's caused by:
>
> ed2f752e0e0a ("x86/percpu: Introduce const-qualified const_pcpu_hot to micro-optimize code generation")
>
> Uros?
I have taken the discussion to the bugreport, where the potential
patch is also posted.
For reference, my answer is as follows:
--cut here--
(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@xxxxxxxxxx/
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.
--cut here--
Thanks,
Uros.