[Bug c++/65199] New: Linker failure with -flto
goswin-v-b at web dot de
gcc-bugzilla@gcc.gnu.org
Wed Feb 25 00:55:00 GMT 2015
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65199
Bug ID: 65199
Summary: Linker failure with -flto
Product: gcc
Version: 4.8.3
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: goswin-v-b at web dot de
Host: x86_64-linux-gnu
Target: x86_64-linux-gnu
Build: arm-none-eabi
I'm building a bare-metal kernel for a Raspberry Pi 2 (armv7) in c++. At some
point this failed with "undefined reference to `memcpy'" so I implemented one
as extern "C" void * memcpy(void *dest, const void *src, uint32_t n). But that
gives a different error:
% arm-none-eabi-g++ -O2 -W -Wall -fPIE -flto -march=armv7-a -mfloat-abi=hard
-mfpu=vfpv3-d16 -ffreestanding -nostdlib -std=gnu++11 -fno-exceptions -fno-rtti
-c -o main.o main.cc
% arm-none-eabi-g++ -fPIE -nostdlib -O2 -flto boot.o font.o main.o -lgcc
-Tlink-arm-eabi.ld -o kernel.elf
`memcpy' referenced in section `.text' of /tmp/cc7IkgU6.ltrans0.ltrans.o:
defined in discarded section `.text' of main.o (symbol from plugin)
collect2: error: ld returned 1 exit status
Running the same command to link but without -flto succeeds:
% arm-none-eabi-g++ -fPIE -nostdlib -O2 boot.o font.o main.o -lgcc
-Tlink-arm-eabi.ld -o kernel.elf
More information about the Gcc-bugs
mailing list