[PATCH 1/2] riscv: vdso: Do not use LTO for the vDSO
Thomas Weißschuh
thomas.weissschuh at linutronix.de
Mon Jul 6 23:10:19 PDT 2026
On Mon, Jul 06, 2026 at 02:01:58PM -0700, Nathan Chancellor wrote:
> On Wed, Jul 01, 2026 at 11:21:22AM +0200, Thomas Weißschuh wrote:
> > With LTO enabled the compiler assumes that the vDSO functions are not
> > used and optimizes them away completely. Currently this happens to
> > __vdso_clock_getres(), __vdso_clock_gettime(), __vdso_getrandom(),
> > __vdso_gettimeofday() and __vdso_riscv_hwprobe().
> >
> > Disable LTO for the vDSO, as these functions are hand-optimized anyways.
> >
> > Reported-by: kernel test robot <lkp at intel.com>
> > Closes: https://lore.kernel.org/oe-kbuild-all/202606301855.WvkSC4kD-lkp@intel.com/
>
> While this change seems correct, is this really the fix for that report?
> It seems like that error happens in clang but I would expect this sort
> of issue to only appear once LTO has run through ld.lld?
At this point the vDSO userspace library has already run through ld.lld.
That has optimized away the futex symbols, which means their offsets are not
defined when building the regular vDSO *kernel* code.
> > Fixes: 021d23428bdb ("RISC-V: build: Allow LTO to be selected")
> > Cc: stable at vger.kernel.org
> > Signed-off-by: Thomas Weißschuh <thomas.weissschuh at linutronix.de>
> > ---
> > arch/riscv/kernel/vdso/Makefile | 6 +++---
> > 1 file changed, 3 insertions(+), 3 deletions(-)
> >
> > diff --git a/arch/riscv/kernel/vdso/Makefile b/arch/riscv/kernel/vdso/Makefile
> > index a842dc034571..43ee881f6c6f 100644
> > --- a/arch/riscv/kernel/vdso/Makefile
> > +++ b/arch/riscv/kernel/vdso/Makefile
> > @@ -69,9 +69,9 @@ CPPFLAGS_$(vdso_lds) += -DHAS_VGETTIMEOFDAY
> > endif
> >
> > # Disable -pg to prevent insert call site
> > -CFLAGS_REMOVE_vgettimeofday.o = $(CC_FLAGS_FTRACE) $(CC_FLAGS_SCS)
> > -CFLAGS_REMOVE_getrandom.o = $(CC_FLAGS_FTRACE) $(CC_FLAGS_SCS)
> > -CFLAGS_REMOVE_hwprobe.o = $(CC_FLAGS_FTRACE) $(CC_FLAGS_SCS)
> > +CFLAGS_REMOVE_vgettimeofday.o = $(CC_FLAGS_FTRACE) $(CC_FLAGS_SCS) $(CC_FLAGS_LTO)
> > +CFLAGS_REMOVE_getrandom.o = $(CC_FLAGS_FTRACE) $(CC_FLAGS_SCS) $(CC_FLAGS_LTO)
> > +CFLAGS_REMOVE_hwprobe.o = $(CC_FLAGS_FTRACE) $(CC_FLAGS_SCS) $(CC_FLAGS_LTO)
> >
> > # Force dependency
> > $(obj)/$(vdso_o): $(obj)/$(vdso_so)
> >
> > --
> > 2.55.0
> >
>
> --
> Cheers,
> Nathan
More information about the linux-riscv
mailing list