Alessandro Fanfarillo via llvm-dev
2016-Aug-03 01:12 UTC
[llvm-dev] Issue with HelloWorld pass
Dear all, I'm new to the LLVM world and I'm trying to run reproduce the hello world example described here http://llvm.org/releases/3.8.1/docs/WritingAnLLVMPass.html. I started with a fresh new llvm-3.8.1 installation based on cmake (running on Linux x86) using the following command: cmake -DCMAKE_INSTALL_PREFIX=/path/to/llvm -DLLVM_TARGETS_TO_BUILD="X86" ../ The build directory was inside the top directory of the llvm-3.8.1 source. I copied and pasted the pass example reported at the end of the "Basic code required" section and I managed to compile everything correctly with CMake. Because there is already a Hello example (with the correspondent LLVMHello.so file), I decided to call it NewHello. When I try to test the pass with the following string opt -load /path/to/llvm-3.8.1.src/build/lib/LLVMNewHello.so -hello < new_hello.bc > /dev/null I get the following error: Expected no forward declarations! !0 = <temporary!> !{} incorrect number of operands in llvm.ident metadata !0 = <temporary!> !{} opt: -: error: input module is broken! I've also tried with the LLVMHello.so file but I got the same error message. Do you have any suggestions?
> On Aug 2, 2016, at 6:12 PM, Alessandro Fanfarillo via llvm-dev <llvm-dev at lists.llvm.org> wrote: > > Dear all, > I'm new to the LLVM world and I'm trying to run reproduce the hello > world example described here > http://llvm.org/releases/3.8.1/docs/WritingAnLLVMPass.html. > > I started with a fresh new llvm-3.8.1 installation based on cmake > (running on Linux x86) using the following command: > > cmake -DCMAKE_INSTALL_PREFIX=/path/to/llvm -DLLVM_TARGETS_TO_BUILD="X86" ../ > > The build directory was inside the top directory of the llvm-3.8.1 source. > > I copied and pasted the pass example reported at the end of the "Basic > code required" section and I managed to compile everything correctly > with CMake. > Because there is already a Hello example (with the correspondent > LLVMHello.so file), I decided to call it NewHello. > > When I try to test the pass with the following string > > opt -load /path/to/llvm-3.8.1.src/build/lib/LLVMNewHello.so -hello < > new_hello.bc > /dev/nullIs “opt” here the same version as LLVMNewHello.so?> > I get the following error: > Expected no forward declarations! > !0 = <temporary!> !{} > incorrect number of operands in llvm.ident metadata > !0 = <temporary!> !{} > opt: -: error: input module is broken! > > I've also tried with the LLVMHello.so file but I got the same error message. > > Do you have any suggestions?Does round-tripping without loading your own pass work? Something like: opt < new_hello.bc > /dev/null How did you generate the new_hello.bc file? Did you use clang? If so, did you use the same version of clang as your opt and your pass? — Mehdi
Hi, Why don't you use https://github.com/sampsyo/llvm-pass-skeleton ? If cmake doesn't pick up the path automatically, just export If you have problems in setting up LLVM, you can use docker as a development container. https://github.com/d11wtq/llvm-docker/blob/master/Dockerfile I faced some problem initially, I use docker container and it works. On 8/3/2016 03:12, Alessandro Fanfarillo via llvm-dev wrote:> Dear all, > I'm new to the LLVM world and I'm trying to run reproduce the hello > world example described here > http://llvm.org/releases/3.8.1/docs/WritingAnLLVMPass.html. > > I started with a fresh new llvm-3.8.1 installation based on cmake > (running on Linux x86) using the following command: > > cmake -DCMAKE_INSTALL_PREFIX=/path/to/llvm -DLLVM_TARGETS_TO_BUILD="X86" ../ > > The build directory was inside the top directory of the llvm-3.8.1 source. > > I copied and pasted the pass example reported at the end of the "Basic > code required" section and I managed to compile everything correctly > with CMake. > Because there is already a Hello example (with the correspondent > LLVMHello.so file), I decided to call it NewHello. > > When I try to test the pass with the following string > > opt -load /path/to/llvm-3.8.1.src/build/lib/LLVMNewHello.so -hello < > new_hello.bc > /dev/null > > I get the following error: > Expected no forward declarations! > !0 = <temporary!> !{} > incorrect number of operands in llvm.ident metadata > !0 = <temporary!> !{} > opt: -: error: input module is broken! > > I've also tried with the LLVMHello.so file but I got the same error message. > > Do you have any suggestions? > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev-- Warm Regards, Asit Dhal http://asit-dhal.github.io/
Alessandro Fanfarillo via llvm-dev
2016-Aug-03 04:12 UTC
[llvm-dev] Issue with HelloWorld pass
2016-08-02 19:18 GMT-06:00 Mehdi Amini <mehdi.amini at apple.com>:> > Is “opt” here the same version as LLVMNewHello.so?Yes, it is.> > Does round-tripping without loading your own pass work? > Something like: opt < new_hello.bc > /dev/null >Apparently, even without the pass, I still get the same error.> How did you generate the new_hello.bc file?With this command: clang -O3 -emit-llvm testHello.c -c -o new_hello.bc> Did you use clang? If so, did you use the same version of clang as your opt and your pass? >Here is the problem, thanks for asking this. Even though I installed clang 3.8.1 with LLVM and I put the /llvm/bin path in my $PATH env var, my system was using a different version of clang (installed in /usr/local/bin). Apparently, the llvm/bin patch doesn't get added to the $PATH (https://github.com/Homebrew/legacy-homebrew/issues/29733). Thanks for the support (thanks to Asit as well).> — > Mehdi >
Apparently Analagous Threads
- Translation of custom attribute (defined for variables) from clang to llvm
- Translation of custom attribute (defined for variables) from clang to llvm
- How to debug passes
- Translation of custom attribute (defined for variables) from clang to llvm
- [LLVMdev] How to explain this weird phenomenon????????