[llvm-dev] Question about the example of link time optimization

Florian Hahn via llvm-dev llvm-dev at lists.llvm.org
Sun Oct 11 10:27:15 PDT 2020



> On Oct 10, 2020, at 11:39, Enna1 via llvm-dev <llvm-dev at lists.llvm.org> wrote:
> 
> Hi all!
> 
> I played around with the LLVM LTO
> example(https://llvm.org/docs/LinkTimeOptimization.html#example-of-link-time-optimization),
> but got some questions.
> 
> As the document says, the function foo4 should be removed. However,
> under my test, function foo4 is not removed.
> I have tried both gnu ld with LLVMgold.so and lld, neither of them
> removes function foo4.
> 
> I compile and run the example as instructed:
> % clang -flto -c a.c -o a.o        # <-- a.o is LLVM bitcode file
> % clang -c main.c -o main.o        # <-- main.o is native object file


I think you also need to build main.c with -flto.

Cheers,
Florian


More information about the llvm-dev mailing list