It might be a duplicate of bug 51205 but it's happening again. [test.cpp] typedef void (*action_t)(const unsigned char*); extern "C" void _start(action_t action) { const unsigned char foo[256] = {}; action(foo); } typedef __SIZE_TYPE__ size_t; extern "C" void* //__attribute__((externally_visible)) // Workaround memset(void* dst, int c, size_t len) { unsigned char * d = (unsigned char*)dst; while(len--) *d++ = c; return dst; } [error] $ arm-none-linux-gnueabi-g++ -fno-exceptions -nostartfiles -static -nostdlib -nodefaultlibs -flto test.cpp -o test `memset' referenced in section `.text' of /tmp/cc7ooAE0.ltrans0.ltrans.o: defined in discarded section `.text' of /tmp/ccVDnjy6.o (symbol from plugin) collect2: error: ld returned 1 exit status [versions] arm-none-linux-gnueabi-g++ --version : 4.8.1 arm-none-linux-gnueabi-ld --version : 2.23.2
Created attachment 30679 [details] Test case
At present the runtime functions are not supposed to be LTOed, because references to them may appear late in the codegen. I suppose things could work with explicit "used" attribute.
*** Bug 99559 has been marked as a duplicate of this bug. ***
*** Bug 60395 has been marked as a duplicate of this bug. ***
.
*** Bug 65199 has been marked as a duplicate of this bug. ***