[LLVMdev] Error with Gold Linker during LTO
Daniel Stewart
stewartd at codeaurora.org
Fri May 30 09:01:23 PDT 2014
We've found an error during the use of LTO that appears to happen only
during the use of the gold linker.
We essentially have a file which is compiled *without* LTO:
f1() {
h1();
}
And a second file that is compiled/linked *with* LTO:
f2() {
f1();
h1();
}
This second file has the function h1() inlined during LTO.
The resulting executable fails because the symbol for h1 is weak in the
first .o and doesn't exist in the second .o.
All the actual code is below for reproducing the error.
Is this an error in the linker itself or in how LLVM deals with the symbols?
Daniel
cat > weakCpp.h << \!
class C {
public:
int simple_method() {return 1;}
int caller_method() ;
};
!
cat > weakImpl.cpp << \!
#include "weakCpp.h"
int C::caller_method() {
return simple_method();
}
!
cat > weakMain.cpp << \!
#include "weakCpp.h"
int call_methods_main() {
C instance;
return instance.simple_method() + instance.caller_method();
}
int main() {
return call_methods_main();
}
!
clang++ -O0 weakImpl.cpp -o weakImpl.o -c
clang++ -O1 -o weakMainO1.exe -flto -mcpu=cortex-a15 -mllvm
-debug-only=inline -static weakMain.cpp weakImpl.o -v
-Wl,-plugin-opt=-debug-only=inline -Wl,-fuse-ld=gold
-Wl,-plugin-opt=also-emit-llvm -Wl,-plugin-opt=obj-path=. >& O1.log
Daniel
--
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by
The Linux Foundation
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20140530/96469afa/attachment.html>
More information about the llvm-dev
mailing list