我的程序在没有使用-flto的情况下可以编译通过,但是使用-flto时会出现以下错误:
% arm-none-eabi-g++ --version
arm-none-eabi-g++ (4.8.3-9+11) 4.8.3 20140820 (release)
Copyright (C) 2013 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
% 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 memcpy.o font.o main.o -lgcc -Tlink-arm-eabi.ld -o kernel.elf
`memcpy' referenced in section `.text' of /tmp/ccYO5wE8.ltrans0.ltrans.o: defined in discarded section `.text' of memcpy.o (symbol from plugin)
collect2: error: ld returned 1 exit status
我尝试将memcpy.o移动到不同的位置以尝试不同的链接顺序,但错误始终相同。我看到这是一个常见的问题,但之前问题的答案都不适用。我没有安装损坏的boost或使用不同的编译器版本进行编译。我正在构建一个裸机内核,因此除了libgcc之外,没有涉及任何外部库。
有人知道发生了什么吗?