IITH-Compilers / IR2Vec

Implementation of IR2Vec, LLVM IR Based Scalable Program Embeddings
Other
84 stars 39 forks source link

IR2Vec Linking error on LLVM 17 #109

Closed amirjamez closed 6 months ago

amirjamez commented 6 months ago

Having built LLVM 17 and Eigen 3.3.7, running make on main branch leads to this linking error:

cd IR2Vec/build
cmake -DLT_LLVM_INSTALL_DIR=/DIR/TO/LLVM-17x/install -DEigen3_DIR=/DIR/TO/eigen-build  ..
make -j32
[ 44%] Built target objlib
[ 55%] Linking CXX shared library ../lib/libIR2Vec.so
[ 66%] Linking CXX static library ../lib/libIR2Vec.a
[ 77%] Linking CXX executable ../bin/ir2vec
[ 77%] Built target IR2Vec_Static
[ 77%] Built target IR2Vec
/usr/bin/ld: CMakeFiles/ir2vec.dir/IR2Vec.cpp.o: in function `main':
IR2Vec.cpp:(.text.startup+0x1650): undefined reference to `llvm::cl::ParseCommandLineOptions(int, char const* const*, llvm::StringRef, llvm::raw_ostream*, char const*, bool)'
collect2: error: ld returned 1 exit status
make[2]: *** [src/CMakeFiles/ir2vec.dir/build.make:152: bin/ir2vec] Error 1
make[1]: *** [CMakeFiles/Makefile2:232: src/CMakeFiles/ir2vec.dir/all] Error 2
make: *** [Makefile:136: all] Error 2

Any ideas? Thanks!

svkeerthy commented 6 months ago

Hi Amir,

Can you please share the cmake command that you are using?

Thanks, Venkat

On Wed, 29 May 2024 at 6:11 AM, Amir H. Ashouri @.***> wrote:

Having built LLVM 17 and Eigen 3.3.7, running make on main branch leads to this linking error:

make -j32 [ 44%] Built target objlib [ 55%] Linking CXX shared library ../lib/libIR2Vec.so [ 66%] Linking CXX static library ../lib/libIR2Vec.a [ 77%] Linking CXX executable ../bin/ir2vec [ 77%] Built target IR2Vec_Static [ 77%] Built target IR2Vec /usr/bin/ld: CMakeFiles/ir2vec.dir/IR2Vec.cpp.o: in function main': IR2Vec.cpp:(.text.startup+0x1650): undefined reference tollvm::cl::ParseCommandLineOptions(int, char const const, llvm::StringRef, llvm::raw_ostream, char const, bool)' collect2: error: ld returned 1 exit status make[2]: [src/CMakeFiles/ir2vec.dir/build.make:152: bin/ir2vec] Error 1 make[1]: [CMakeFiles/Makefile2:232: src/CMakeFiles/ir2vec.dir/all] Error 2 make: *** [Makefile:136: all] Error 2

Any ideas? Thanks!

— Reply to this email directly, view it on GitHub https://github.com/IITH-Compilers/IR2Vec/issues/109, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHPGBASF63YPQNOGK3SFVT3ZEUP4BAVCNFSM6AAAAABIN42S5SVHI2DSMVQWIX3LMV43ASLTON2WKOZSGMZDEMJTGAYTOOI . You are receiving this because you are subscribed to this thread.Message ID: @.***>

--

Disclaimer:- This footer text is to convey that this email is sent by one of the users of IITH. So, do not mark it as SPAM.

amirjamez commented 6 months ago

@svkeerthy I have updated my question. Thanks

svkeerthy commented 6 months ago

Hi, I tried building LLVM-17 and IR2Vec (main) from scratch with the cmake command you had mentioned. Weirdly, I could build it without any issues. (The builds in GH Actions are successful as well!)

Here is the cmake command I used for building LLVM 17 - cmake -G Ninja -S ../llvm -B . -DCMAKE_BUILD_TYPE="Release" -DLLVM_ENABLE_PROJECTS="clang" -DLLVM_TARGETS_TO_BUILD="X86" -DCMAKE_EXPORT_COMPILE_COMMANDS=1 -DLLVM_CCACHE_BUILD=ON -DCMAKE_INSTALL_PREFIX=./Install

And, here is the cmake command used for building IR2Vec - cmake -DLT_LLVM_INSTALL_DIR=../../llvm-project/build-17/Install -DEigen3_DIR=../build/eigen-build ..

From the log, I can see that the build could not find the definition of LLVM's ParseCommandLineOptions API. Could it be the case that the LLVM build is not complete?

amirjamez commented 6 months ago

@svkeerthy Looks like my LLVM was 17.0.6. I tested it with 17.0.5 and it looks OK, but not anything after. Do you happen to know the reason why? FYI. LLVM release/17x is 17.0.6

Is there a new support coming for newer LLVM versions? Thanks

svkeerthy commented 6 months ago

Yeah, main branch of IR2Vec supports 17.0.6. I had checked by building release/17.x and it seems to build fine. The automated builds also use 17.0.6 (workflow code) .

And, by the latest versions do you mean LLVM 18 or main? I just tried using LLVM release/18.x and changed src/CMakeLists.txt to use LLVM 18.1.6 in place of 17. It seems to build fine.

Currently, IR2Vec's vocabulary is updated for LLVM 17. AFAIU, there are not much changes in the IR of 17.x and 18.x. I think IR2Vec with LLVM 18 should work.

Please let me know if it helps. Would be happy to look into this further if the issue persists.

svkeerthy commented 6 months ago

Hi @amirjamez, Is the issue solved?

amirjamez commented 6 months ago

@svkeerthy Seems like the issue stems from our internal downstream changes. I can confirm 17.0.6 from llvm trunk (github) builds just fine. Thanks!