[llvm-dev] How to optimize a large project in llvm pass?

y liu via llvm-dev llvm-dev at lists.llvm.org
Sun Apr 19 23:53:27 PDT 2020

I have written MyPass.cpp and I use "EP_FullLinkTimeOptimizationLast".
I compile it and get libMypass.so.
MyPass.so rely on some other code, such as,Init.c and Helper.c.
So, I  use following commands to get a static library libmypass-rt.a.
$ clang -fsanitize=safe-stack -c -emit-llvm -fpic -Wall -Wextra -O2 -I
../include -o obj/helpers.o helpers.c
$ clang -fsanitize=safe-stack -c -emit-llvm -fpic -Wall -Wextra -O2 -I
../include -o obj/init.o init.c
$ ar rcs obj/libmypass-rt.a obj/helpers.o obj/init.o
When mypass optimizes the target program, it reles on libmypass-rt.a
library. So I need to link libmypass-rt.a to the target program, then
optimize after link.
So, I need LTO.
I use following commands:
$ export CC=clang
$ export CXX=clang++
$ export RANLIB=llvm-ranlib
$ export  LIBS="path/to/.../libmypass-rt.a"
$ export CFLAGS=" -fsanitize=safe-stack -Wall -Wextra -fpic -flto
-Xclang -load -Xclang path/to/.../libmypass.so"
$ export LDFLAGS=" -flto -fuse-ld=gold"
$ ./configure
$ make
But, errors occurred. I check out config.log
/usr/bin/ld.gold: error: path/to/.../libmemsentry-rt.a
: no archive symbol table (run ranlib)
clang-10: error: linker command failed with exit code 1
 (use -v to see invocation)

What shuold I do?
If this problem is solved, please tell me whether my method can achieve my


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20200420/c240d4c9/attachment.html>

More information about the llvm-dev mailing list