Re: ld.lld: error: undefined symbol: __bad_ndelay
From: Andy Shevchenko
Date: Wed Apr 08 2026 - 10:27:25 EST
On Tue, Mar 31, 2026 at 07:21:42PM +0800, kernel test robot wrote:
> tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
> head: d0c3bcd5b8976159d835a897254048e078f447e6
> commit: 4434072a893e4864519c167947083ff3e4cc2d95 iio: adc: Add the NXP SAR ADC support for the s32g2/3 platforms
> date: 3 months ago
> config: x86_64-buildonly-randconfig-001-20260331 (https://download.01.org/0day-ci/archive/20260331/202603311958.ly6uROit-lkp@xxxxxxxxx/config)
> compiler: clang version 20.1.8 (https://github.com/llvm/llvm-project 87f0227cb60147a26a1eeb4fb06e3b505e9c7261)
> reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260331/202603311958.ly6uROit-lkp@xxxxxxxxx/reproduce)
>
> If you fix the issue in a separate patch/commit (i.e. not just a new version of
> the same patch/commit), kindly add following tags
> | Reported-by: kernel test robot <lkp@xxxxxxxxx>
> | Closes: https://lore.kernel.org/oe-kbuild-all/202603311958.ly6uROit-lkp@xxxxxxxxx/
My understanding that in some interesting cases (CONFIG_COMMON_CLK=n) this
leads to division by 0 that compiler prevents by saturating the value. Note,
I haven't checked the real assembly for that, just a speculation based on
the code reading and kernel configuration (*).
With saturated value it's obviously is over any given threshold which is
currently 20000.
*Yes, seems the specifications says that this is UB (as unspecified)
and compiler may do whatever it wants in such a case. Here it seems does
the saturation (which is logically okay as 0 is compile-time constant).
Related: https://github.com/llvm/llvm-project/issues/136679.
> All errors (new ones prefixed by >>):
>
> >> ld.lld: error: undefined symbol: __bad_ndelay
> >>> referenced by delay.h:78 (include/asm-generic/delay.h:78)
> >>> vmlinux.o:(nxp_sar_adc_probe)
> >>> referenced by delay.h:78 (include/asm-generic/delay.h:78)
> >>> vmlinux.o:(nxp_sar_adc_read_raw)
> >>> referenced by delay.h:78 (include/asm-generic/delay.h:78)
> >>> vmlinux.o:(nxp_sar_adc_read_raw)
> >>> referenced 2 more times
--
With Best Regards,
Andy Shevchenko