banach-space / llvm-tutor

A collection of out-of-tree LLVM passes for teaching and learning
MIT License
3k stars 397 forks source link

unknown pass name 'hello-world' #96

Open sunheyi6 opened 1 year ago

sunheyi6 commented 1 year ago

image

banach-space commented 1 year ago

Please submit steps to reproduce.

sunheyi6 commented 1 year ago

Please submit steps to reproduce.

@banach-space I followed the instructions in the README and proceeded with the operation. First,

wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
sudo apt-add-repository "deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-16 main"
sudo apt-get update
sudo apt-get install -y llvm-16 llvm-16-dev llvm-16-tools clang-16

Second,

cd /root/llvm-tutor/build/
cmake -DLT_LLVM_INSTALL_DIR=/usr/lib/llvm-16 /root/llvm-tutor
make

Third

root@LAPTOP-OJLO0M82:~# cd llvm-tutor/build/
root@LAPTOP-OJLO0M82:~/llvm-tutor/build# ls
CMakeCache.txt  CMakeFiles  Makefile  cmake_install.cmake  input_for_hello.ll
root@LAPTOP-OJLO0M82:~/llvm-tutor/build#
root@LAPTOP-OJLO0M82:~/llvm-tutor/build# pwd
/root/llvm-tutor/build
root@LAPTOP-OJLO0M82:~/llvm-tutor/build# /usr/lib/llvm-16/bin/opt -load-pass-plugin ./libHelloWorld.so           -passes=hello-world -disable-output input_for_hello.ll
Failed to load passes from './libHelloWorld.so'. Request ignored.
/usr/lib/llvm-16/bin/opt: unknown pass name 'hello-world'
banach-space commented 1 year ago

Thanks for getting back to me. I've just checked this invocation works for me fine:

/opt/llvm-16/bin/opt -load-pass-plugin ./libHelloWorld.so -passes=hello-world -disable-output input_for_hello.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

Can you double check the command line that you are using the run the example?

adwait commented 1 year ago

You might have the wrong path to libHelloWorld.so. cmake -DLT_LLVM_INSTALL_DIR=/usr/lib/llvm-16 /root/llvm-tutor places all plugin libraries into <build-dir>/lib for me.