<div dir="ltr"><div dir="ltr">Hi,<div><br></div><div>` -Xclang -load -Xclang path/to/.../libmypass.so` is gonna load the pass inside clang, however clang will invoke the linker separately and it won't have your pass. I don't know if gold or lld can load dynamically passes like this?</div><div>An alternative it to link your pass statically with the gold plugin or with lld.</div><div><br></div><div>Best,</div><div><br></div><div>-- </div><div>Mehdi</div><div><br></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, Apr 19, 2020 at 11:53 PM y liu via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr">Hi, <div>I have written MyPass.cpp and I use "EP_FullLinkTimeOptimizationLast".</div><div>I compile it and get libMypass.so. </div><div>MyPass.so rely on some other code, such as,Init.c and Helper.c.</div><div>So, I  use following commands to get a static library libmypass-rt.a.</div><div>"</div><div>$ clang -fsanitize=safe-stack -c -emit-llvm -fpic -Wall -Wextra -O2 -I ../include -o obj/helpers.o helpers.c<br>$ clang -fsanitize=safe-stack -c -emit-llvm -fpic -Wall -Wextra -O2 -I ../include -o obj/init.o init.c<br></div><div>$ ar rcs obj/libmypass-rt.a obj/helpers.o obj/init.o<br></div><div>."</div><div>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.</div><div>So, I need LTO.</div><div>I use following commands:</div><div style="color:rgb(212,212,212);background-color:rgb(30,30,30);font-family:Consolas,"Courier New",monospace;font-size:18px;line-height:24px;white-space:pre-wrap"><div>$ export CC=clang</div><div>$ export CXX=clang++</div><div>$ export RANLIB=llvm-ranlib</div><div>$ export  LIBS="path/to/.../libmypass-rt.a"</div><div>$ export CFLAGS=" -fsanitize=safe-stack -Wall -Wextra -fpic -flto -Xclang -load -Xclang path/to/.../libmypass.so"</div><div>$ export LDFLAGS=" -flto -fuse-ld=gold"</div><div>$ ./configure</div></div><div><span style="background-color:rgb(30,30,30);color:rgb(212,212,212);font-family:Consolas,"Courier New",monospace;font-size:18px;white-space:pre-wrap">$ make</span></div><div>But, errors occurred. I check out config.log</div><div><div style="color:rgb(212,212,212);background-color:rgb(30,30,30);font-family:Consolas,"Courier New",monospace;font-size:18px;line-height:24px;white-space:pre-wrap"><div>/usr/bin/ld.gold: <span style="color:rgb(206,145,120);font-weight:bold">error:</span> path/to/.../libmemsentry-<span style="color:rgb(86,156,214)">rt.a</span>: no archive symbol table (run ranlib)</div><div>clang-<span style="color:rgb(86,156,214)">10</span>: <span style="color:rgb(206,145,120);font-weight:bold">error:</span> linker command failed with exit code <span style="color:rgb(86,156,214)">1</span> (use -v to see invocation)</div></div></div><div><br></div><div>What shuold I do?</div><div>If this problem is solved, please tell me whether my method can achieve my goal?</div><div><br></div><div>Thansk!</div><div><br></div><div><br></div><ul style="box-sizing:border-box;margin:0px;padding:0px;color:rgb(46,48,51);font-family:Arial,"Microsoft YaHei",微软雅黑,宋体,"Malgun Gothic",Meiryo,sans-serif;font-size:14px;font-variant-numeric:normal;font-variant-east-asian:normal;line-height:14px;background-color:rgb(247,248,250)"><li style="box-sizing:border-box;margin:0px 0px 10px;padding:0px;list-style:none"><p style="box-sizing:border-box;margin:0px;padding:0px;color:rgb(102,102,102);line-height:20px"></p></li></ul></div>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
</blockquote></div>