Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Undefined symbol #91

Closed
aiglematth opened this issue Jul 7, 2023 · 2 comments
Closed

Undefined symbol #91

aiglematth opened this issue Jul 7, 2023 · 2 comments

Comments

@aiglematth
Copy link

Hello !

To begin, thanks for your super repo !
I have some troubles with running the HelloWorld example pass... By following your tutorial I am doing this :

(orc) root[0]/r/testzone > cd llvm-tutor/
(orc) root[0]/r/t/llvm-tutor > export LLVM_DIR=/root/orchestra/root/lib64/llvm/llvm
(orc) root[0]/r/t/llvm-tutor > mkdir build
                               cd build
                               cmake -DLT_LLVM_INSTALL_DIR=$LLVM_DIR ../HelloWorld/
                               make
-- The C compiler identification is GNU 11.2.0
-- The CXX compiler identification is GNU 11.2.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /root/orchestra/root/link-only/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /root/orchestra/root/link-only/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found ZLIB: /root/orchestra/root/lib64/libz.so (found version "1.2.11")
-- Configuring done
-- Generating done
-- Build files have been written to: /root/testzone/llvm-tutor/build
[ 50%] Building CXX object CMakeFiles/HelloWorld.dir/HelloWorld.cpp.o
[100%] Linking CXX shared library libHelloWorld.so
[100%] Built target HelloWorld
(orc) root[0]/r/t/l/build > $LLVM_DIR/bin/clang -O1 -S -emit-llvm ../inputs/input_for_hello.c -o input_for_hello.ll
(orc) root[0]/r/t/l/build >
(orc) root[134]/r/t/l/build > $LLVM_DIR/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.
Expected<T> must be checked before access or destruction.
Unchecked Expected<T> contained error:
Could not load library './libHelloWorld.so': ./libHelloWorld.so: undefined symbol: _ZNK4llvm12FunctionPass17createPrinterPassERNS_11raw_ostreamERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.      Program arguments: /root/orchestra/root/lib64/llvm/llvm/bin/opt -load-pass-plugin ./libHelloWorld.so -passes=hello-world -disable-output input_for_hello.ll
 #0 0x00007f42457c4a5e llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /builds/gitlab/revng/orchestra/orchestra/sources/llvm-project/llvm/lib/Support/Unix/Signals.inc:570:13
 #1 0x00007f42457c2dc4 llvm::sys::RunSignalHandlers() /builds/gitlab/revng/orchestra/orchestra/sources/llvm-project/llvm/lib/Support/Signals.cpp:105:18
 #2 0x00007f42457c4fcd SignalHandler(int) /builds/gitlab/revng/orchestra/orchestra/sources/llvm-project/llvm/lib/Support/Unix/Signals.inc:415:1
 #3 0x00007f4245205520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #4 0x00007f4245259a7c __pthread_kill_implementation ./nptl/pthread_kill.c:44:76
 #5 0x00007f4245259a7c __pthread_kill_internal ./nptl/pthread_kill.c:78:10
 #6 0x00007f4245259a7c pthread_kill ./nptl/pthread_kill.c:89:10
 #7 0x00007f4245205476 gsignal ./signal/../sysdeps/posix/raise.c:27:6
 #8 0x00007f42451eb7f3 abort ./stdlib/abort.c:81:7
 #9 0x000055c33f5d4c11 llvm::raw_ostream::operator<<(llvm::StringRef) /builds/gitlab/revng/orchestra/orchestra/sources/llvm-project/llvm/include/llvm/Support/raw_ostream.h:220:7
#10 0x000055c33f5d4c11 llvm::raw_ostream::operator<<(char const*) /builds/gitlab/revng/orchestra/orchestra/sources/llvm-project/llvm/include/llvm/Support/raw_ostream.h:244:18
#11 0x000055c33f5d4c11 llvm::Expected<llvm::PassPlugin>::fatalUncheckedExpected() const /builds/gitlab/revng/orchestra/orchestra/sources/llvm-project/llvm/include/llvm/Support/Error.h:704:14
#12 0x000055c33f5d0d98 (/root/orchestra/root/lib64/llvm/llvm/bin/opt+0x2ad98)
#13 0x000055c33f5d2bfb std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>::__is_long[abi:v160001]() const /builds/gitlab/revng/orchestra/orchestra/root/lib64/llvm/clang-release/bin/../include/c++/v1/string:1682:16
#14 0x000055c33f5d2bfb std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>::~basic_string() /builds/gitlab/revng/orchestra/orchestra/root/lib64/llvm/clang-release/bin/../include/c++/v1/string:2361:9
#15 0x000055c33f5d2bfb llvm::cl::list<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, bool, llvm::cl::parser<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>>::handleOccurrence(unsigned int, llvm::StringRef, llvm::StringRef) /builds/gitlab/revng/orchestra/orchestra/sources/llvm-project/llvm/include/llvm/Support/CommandLine.h:1673:3
#16 0x00007f42456da45d ProvideOption(llvm::cl::Option*, llvm::StringRef, llvm::StringRef, int, char const* const*, int&) /builds/gitlab/revng/orchestra/orchestra/sources/llvm-project/llvm/lib/Support/CommandLine.cpp:708:1
#17 0x00007f42456de4ef (anonymous namespace)::CommandLineParser::ParseCommandLineOptions(int, char const* const*, llvm::StringRef, llvm::raw_ostream*, bool) /builds/gitlab/revng/orchestra/orchestra/sources/llvm-project/llvm/lib/Support/CommandLine.cpp:1714:23
#18 0x00007f42456de4ef llvm::cl::ParseCommandLineOptions(int, char const* const*, llvm::StringRef, llvm::raw_ostream*, char const*, bool) /builds/gitlab/revng/orchestra/orchestra/sources/llvm-project/llvm/lib/Support/CommandLine.cpp:1470:24
#19 0x000055c33f5ce47a main /builds/gitlab/revng/orchestra/orchestra/sources/llvm-project/llvm/tools/opt/opt.cpp:0:3
#20 0x00007f42451ecd90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16
#21 0x00007f42451ece40 call_init ./csu/../csu/libc-start.c:128:20
#22 0x00007f42451ece40 __libc_start_main ./csu/../csu/libc-start.c:379:5
#23 0x000055c33f5bf379 _start (/root/orchestra/root/lib64/llvm/llvm/bin/opt+0x19379)
fish: Job 1, '$LLVM_DIR/bin/opt -load-pass-pl…' terminated by signal SIGABRT (Abort)

I saw this problem in a stackoverflow post. It was an ABI match problem. The user had solve it by inserting the _GLIBCXX_USE_CXX11_ABI=0 compilation option...In my case doing that let me fall in another symbol problem :

(orc) root[0]/r/t/l/build > $LLVM_DIR/bin/opt -load-pass-plugin ./libHelloWorld.so -passes=hello-world -disable-output i
nput_for_hello.ll
Failed to load passes from './libHelloWorld.so'. Request ignored.
Expected<T> must be checked before access or destruction.
Unchecked Expected<T> contained error:
Could not load library './libHelloWorld.so': ./libHelloWorld.so: undefined symbol: _ZNK4llvm12FunctionPass17createPrinterPassERNS_11raw_ostreamERKSsPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.      Program arguments: /root/orchestra/root/lib64/llvm/llvm/bin/opt -load-pass-plugin ./libHelloWorld.so -passes=hello-world -disable-output input_for_hello.ll
 #0 0x00007fd15505ea5e llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /builds/gitlab/revng/orchestra/orchestra/sources/llvm-project/llvm/lib/Support/Unix/Signals.inc:570:13
 #1 0x00007fd15505cdc4 llvm::sys::RunSignalHandlers() /builds/gitlab/revng/orchestra/orchestra/sources/llvm-project/llvm/lib/Support/Signals.cpp:105:18
 #2 0x00007fd15505efcd SignalHandler(int) /builds/gitlab/revng/orchestra/orchestra/sources/llvm-project/llvm/lib/Support/Unix/Signals.inc:415:1
 #3 0x00007fd154a9f520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #4 0x00007fd154af3a7c __pthread_kill_implementation ./nptl/pthread_kill.c:44:76
 #5 0x00007fd154af3a7c __pthread_kill_internal ./nptl/pthread_kill.c:78:10
 #6 0x00007fd154af3a7c pthread_kill ./nptl/pthread_kill.c:89:10
 #7 0x00007fd154a9f476 gsignal ./signal/../sysdeps/posix/raise.c:27:6
 #8 0x00007fd154a857f3 abort ./stdlib/abort.c:81:7
 #9 0x000055e011ed3c11 llvm::raw_ostream::operator<<(llvm::StringRef) /builds/gitlab/revng/orchestra/orchestra/sources/llvm-project/llvm/include/llvm/Support/raw_ostream.h:220:7
#10 0x000055e011ed3c11 llvm::raw_ostream::operator<<(char const*) /builds/gitlab/revng/orchestra/orchestra/sources/llvm-project/llvm/include/llvm/Support/raw_ostream.h:244:18
#11 0x000055e011ed3c11 llvm::Expected<llvm::PassPlugin>::fatalUncheckedExpected() const /builds/gitlab/revng/orchestra/orchestra/sources/llvm-project/llvm/include/llvm/Support/Error.h:704:14
#12 0x000055e011ecfd98 (/root/orchestra/root/lib64/llvm/llvm/bin/opt+0x2ad98)
#13 0x000055e011ed1bfb std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>::__is_long[abi:v160001]() const /builds/gitlab/revng/orchestra/orchestra/root/lib64/llvm/clang-release/bin/../include/c++/v1/string:1682:16
#14 0x000055e011ed1bfb std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>::~basic_string() /builds/gitlab/revng/orchestra/orchestra/root/lib64/llvm/clang-release/bin/../include/c++/v1/string:2361:9
#15 0x000055e011ed1bfb llvm::cl::list<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, bool, llvm::cl::parser<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>>::handleOccurrence(unsigned int, llvm::StringRef, llvm::StringRef) /builds/gitlab/revng/orchestra/orchestra/sources/llvm-project/llvm/include/llvm/Support/CommandLine.h:1673:3
#16 0x00007fd154f7445d ProvideOption(llvm::cl::Option*, llvm::StringRef, llvm::StringRef, int, char const* const*, int&) /builds/gitlab/revng/orchestra/orchestra/sources/llvm-project/llvm/lib/Support/CommandLine.cpp:708:1
#17 0x00007fd154f784ef (anonymous namespace)::CommandLineParser::ParseCommandLineOptions(int, char const* const*, llvm::StringRef, llvm::raw_ostream*, bool) /builds/gitlab/revng/orchestra/orchestra/sources/llvm-project/llvm/lib/Support/CommandLine.cpp:1714:23
#18 0x00007fd154f784ef llvm::cl::ParseCommandLineOptions(int, char const* const*, llvm::StringRef, llvm::raw_ostream*, char const*, bool) /builds/gitlab/revng/orchestra/orchestra/sources/llvm-project/llvm/lib/Support/CommandLine.cpp:1470:24
#19 0x000055e011ecd47a main /builds/gitlab/revng/orchestra/orchestra/sources/llvm-project/llvm/tools/opt/opt.cpp:0:3
#20 0x00007fd154a86d90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16
#21 0x00007fd154a86e40 call_init ./csu/../csu/libc-start.c:128:20
#22 0x00007fd154a86e40 __libc_start_main ./csu/../csu/libc-start.c:379:5
#23 0x000055e011ebe379 _start (/root/orchestra/root/lib64/llvm/llvm/bin/opt+0x19379)
fish: Job 1, '$LLVM_DIR/bin/opt -load-pass-pl…' terminated by signal SIGABRT (Abort)

Some other issues in other projects (sampsyo/llvm-pass-skeleton#12) give some solutions...which are not working for me.

My setup is :

(orc) root[0]/r/t/l/build > $LLVM_DIR/bin/opt --version
LLVM (http://llvm.org/):
  LLVM version 16.0.1
  Optimized build with assertions.
  Default target: x86_64-unknown-linux-gnu
  Host CPU: skylake

If you have any suggestions, I take 😄

Have a nice day.

@banach-space
Copy link
Owner

Thanks for reporting and sorry for not getting back to you earlier. It's been a rather busy period for me.

I don't see anything "obvious" in your example that would lead to a crash. I need to try to reproduce it and see what happens. Hoping to do so at some point this week 🤞🏻 .

@aiglematth
Copy link
Author

Thanks for reporting and sorry for not getting back to you earlier. It's been a rather busy period for me.

I don't see anything "obvious" in your example that would lead to a crash. I need to try to reproduce it and see what happens. Hoping to do so at some point this week 🤞🏻 .

Thanks ! I finally found the problem : I had two llvm versions which were conflicting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants