GCC LTO fails static linking while builtins are enabled

Grigoriy Kraynov grigoriy.kraynov@gmail.com
Mon Mar 24 16:38:00 GMT 2014


GCC LTO fails static linking while builtins are enabled

Minimal case:
#include <stddef.h>
int memcmp(const char *s1, const char *s2, size_t n) {
    return 0;
}
int main() {
    memcmp("x", "y", 1);
    return 0;
}

$ gcc -flto -static
fails with message like this:
xxx.ltrans.o: In function `memcmp':
xxx.ltrans0.o:(.text+0x0): multiple definition of `memcmp'
/zzz/libc.a(memcmp.o):(.text+0x0): first defined here
collect2: error: ld returned 1 exit status

But -fno-builtin solves this problem.
If we have function defined as weak alias in static libc (like
strncasecmp() in GlibC) there is no problem.

Is there any way to ignore libc's symbols redefinition without hacks
like disabling builtins or enabling multiple definition?
-- 
Regards
Grigoriy Kraynov



More information about the Gcc-help mailing list