undefined reference to '__builtin_mul_overflow'
Jordi Sanfeliu
jordi@fibranet.cat
Fri Feb 25 11:24:50 GMT 2022
Hello,
I'm upgrading to Newlib 4.1.0 version (from Newlib 3.2.0) in my own
hobby operating system FiwixOS for i386, and after a successful build
with GCC 4.7.4 and Binutils 2.23.2, I found that I'm unable to compile a
simple C program:
# cat test.c
#include <stdio.h>
int main(void)
{
printf("newlib version %s\n", _NEWLIB_VERSION);
return 0;
}
# gcc -o test test.c
/usr/lib/gcc/i686-pc-fiwix/4.7.4/../../../../i686-pc-fiwix/lib/libc.a(lib_a-callocr.o):
In function `_calloc_r':
/mnt/builds/build-newlib-4.1.0.final/i386-fiwix/newlib/libc/stdlib/../../../../../newlib-4.1.0/newlib/libc/stdlib/mallocr.c:3210:
undefined reference to `__builtin_mul_overflow'
collect2: error: ld returned 1 exit status
Looking in the Newlib 4.2.0 source code, I'm indeed unable to find the
function '__builtin_mul_overflow'. This is what 'grep' says:
# grep -r __builtin_mul_overflow *
newlib/libc/stdlib/mallocr.c: if
(__builtin_mul_overflow((INTERNAL_SIZE_T) n, (INTERNAL_SIZE_T)
elem_size, &sz))
newlib/libc/stdlib/nano-mallocr.c: if (__builtin_mul_overflow (n,
elem, &bytes))
newlib/libc/stdlib/reallocarray.c: if (__builtin_mul_overflow (nmemb,
size, &bytes))
There are references to it but I don't see where this function is defined.
Any idea what I'm missing here?
Regards.
--
Jordi Sanfeliu
FIBRANET Network Services Provider
https://www.fibranet.cat
More information about the Newlib
mailing list