Hi,
I think I got confused. Just clarify: my main goal is to be able to port symcc[1] to llvm-13.
Since I’m confused I went back to the beginning I have experimented with and HelloWorld [2] LLVM pass. As you can see in the following paragraph all went well:
root@eaa014e3667a:~/llvm-tutor/build# opt-13 -load-pass-plugin ./libHelloWorld.so -passes=hello-world -disable-output output.ll
(llvm-tutor) Hello from: foo
(llvm-tutor) number of arguments: 1
(llvm-tutor) Hello from: bar
(llvm-tutor) number of arguments: 2
(llvm-tutor) Hello from: fez
(llvm-tutor) number of arguments: 3
(llvm-tutor) Hello from: main
(llvm-tutor) number of arguments: 2
root@eaa014e3667a:~/llvm-tutor/build#
At this point I wanted to load directly the plugin via clang using the -fplugin parameter but I wasn’t able to do it. I tried the following command:
root@eaa014e3667a:~/llvm-tutor/build# clang -fpass-plugin=/root/llvm-tutor/build/libHelloWorld.so …/inputs/input_for_hello.c -o hello
root@eaa014e3667a:~/llvm-tutor/build# file hello
hello: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=ba237b79f2b2bcd362e894657b1e203af914aa9c, for GNU/Linux 3.2.0, not stripped
root@eaa014e3667a:~/llvm-tutor/build#
I was expecting the same output as before where the number of parameters were printed.
With some verbosity the interesting part was
“/usr/lib/llvm-13/bin/clang” -cc1 -triple x86_64-pc-linux-gnu -emit-obj -mrelax-all --mrelax-relocations -disable-free -disable-llvm-verifier -discard-value-names -main-file-name input_for_hello.c -mrelocation-model static -mframe-pointer=all -fmath-errno -fno-rounding-math -mconstructor-aliases -munwind-tables -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -v -fcoverage-compilation-dir=/root/llvm-tutor/build -resource-dir /usr/lib/llvm-13/lib/clang/13.0.1 -internal-isystem /usr/lib/llvm-13/lib/clang/13.0.1/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/…/lib/gcc/x86_64-linux-gnu/10/…/…/…/…/x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -fdebug-compilation-dir=/root/llvm-tutor/build -ferror-limit 19 -fgnuc-version=4.2.1 -fcolor-diagnostics -fpass-plugin=/root/llvm-tutor/build/libHelloWorld.so -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/input_for_hello-c52362.o -x c …/inputs/input_for_hello.c
symcc loads the plugin in this way:
➜ build git:(master) ✗ tail -n 8 symcc
exec $compiler
-Xclang -load -Xclang “$pass”
“$@”
-L"$runtime_dir"
-lSymRuntime
-Wl,-rpath,"$runtime_dir"
-Qunused-arguments
➜ build git:(master) ✗
How am I supposed to load the plugin via clang so I can just have the same output? I want to avoid the use of opt.
Thanks a lot for your help
Alberto
[1] https://github.com/eurecom-s3/symcc
[2] https://github.com/banach-space/llvm-tutor