【发布时间】:2015-04-26 19:26:41
【问题描述】:
我的程序在没有 -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 之外没有涉及任何外部库。
有人知道那里发生了什么吗?
【问题讨论】:
-
g++-4.9.2 出现同样的错误
标签: c++ g++ linker-errors