[Debian-lego-team] Bug#1015360: binutils-h8300-hms: ftbfs with LTO (link time optimization) enabled

Nicolas Schodet nico at ni.fr.eu.org
Sat Nov 1 09:48:13 GMT 2025


* Matthias Klose <doko at debian.org> [251101 09:19]:
> This package currently fails to build (at least on the amd64
> architecture) with link time optimizations enabled.  For a background
> for LTO please see

Hi,

I can reproduce the error and what I found is that when LTO is enabled,
an AC_CHECK_FUNCS test in autoconf fails to detect that the function is
not available. Later, build fails because the function and its
associated type declarations are actually not present.

I can reproduce the test like this:

/* t.c */
char pstat_getstatic ();
char (*f) () = pstat_getstatic;
int main(void) {
    return f != pstat_getstatic;
}

When building without LTO:

% gcc -O2 t.c -o t                  
/usr/bin/ld: /tmp/cc2qPlTb.o: in function `main':
t.c:(.text.startup+0x3): undefined reference to `pstat_getstatic'
/usr/bin/ld: /tmp/cc2qPlTb.o:(.data.rel+0x0): undefined reference to `pstat_getstatic'
collect2: error: ld returned 1 exit status
%

When building with LTO:

% gcc -flto=auto -ffat-lto-objects -O2 t.c -o t
% ./t
% echo $?
0
%

GCC optimize the comparison, even when the tested symbol does not exist.

Is it a known problem?

Kind regards,

Nicolas.



More information about the Debian-lego-team mailing list