xiehuc / llvm-prof

the mirror of llvm-prof extract from llvm release 3.3
Other
8 stars 3 forks source link

Can't build: undefined reference to `dladdr' #11

Open acornagl opened 7 years ago

acornagl commented 7 years ago

Hello, I'm trying to build the project but, unfortunately, I receive an error while linking.

Before to start the build process I setup the path to the LLVM installation and the following gcc/g++ variables (the ones I used to build LLVM):

export CC=/usr/bin/gcc-4.8 
export CXX=/usr/bin/g++-4.8

I modified also the `lib/CmakeLists.txt" file to solve a problem with the pthread compilation:

@@ -1,3 +1,7 @@
+set(THREADS_PREFER_PTHREAD_FLAG ON)
+find_package(Threads REQUIRED)
+
+
 set(SOURCES
   ValueUtils.cpp
   ValueProfiling.cpp
@@ -44,7 +48,7 @@ add_library(LLVMProfiling-static STATIC
        ${SOURCES}
        )
 target_link_libraries(LLVMProfiling-static
-       ${LLVM_LIBRARY}
+       ${LLVM_LIBRARY} Threads::Threads tinfo
        )
 set_target_properties(LLVMProfiling-static
        PROPERTIES
@@ -54,7 +58,7 @@ add_library(LLVMProfiling-shared SHARED
        ${SOURCES}
        )
 target_link_libraries(LLVMProfiling-shared
-       ${LLVM_LIBRARY}
+       ${LLVM_LIBRARY} Threads::Threads tinfo
        )
 set_target_properties(LLVMProfiling-shared
        PROPERTIES

The results of the cmake command is:

-- The C compiler identification is GNU 4.8.5
-- The CXX compiler identification is GNU 4.8.5
-- Check for working C compiler: /usr/bin/gcc-4.8
-- Check for working C compiler: /usr/bin/gcc-4.8 -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/g++-4.8
-- Check for working CXX compiler: /usr/bin/g++-4.8 -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found LLVM Version 3.5.2svn 
-- Could NOT find GTest (missinundefined reference to `dladdr'g:  GTEST_INCLUDE_DIR) 
-- Add /usr/local/lib/pkgconfig to $PKG_CONFIG_PATH environment variable to let pkg-config find llvm-prof.pc
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - not found
-- Check if compiler accepts -pthread
-- Check if compiler accepts -pthread - yes
-- Found Threads: TRUE  
-- Configuring done
-- Generating done
-- Build files have been written to: /local_disk/cornagli/llvm-prof/llvm-prof/build

Now, when the result of the make command is:

Scanning dependencies of target llvm-prof
[ 75%] Building CXX object src/CMakeFiles/llvm-prof.dir/llvm-prof.cpp.o
[ 76%] Building CXX object src/CMakeFiles/llvm-prof.dir/printer.cpp.o
[ 78%] Building CXX object src/CMakeFiles/llvm-prof.dir/passes.cpp.o
[ 80%] Linking CXX executable llvm-prof
/local_disk/cornagli/llvmTracer/llvm3.5Auto/lib/libLLVMSupport.a(Signals.cpp.o): In function `llvm::sys::PrintStackTrace(_IO_FILE*)':
Signals.cpp:(.text._ZN4llvm3sys15PrintStackTraceEP8_IO_FILE+0x5c): undefined reference to `dladdr'
Signals.cpp:(.text._ZN4llvm3sys15PrintStackTraceEP8_IO_FILE+0xe8): undefined reference to `dladdr'
../lib/libLLVMProfiling.so: undefined reference to `llvm::Statistic::RegisterStatistic()'
../lib/libLLVMProfiling.so: undefined reference to `llvm::LoopInfo::ID'
../lib/libLLVMProfiling.so: undefined reference to `llvm::LoopInfoBase<llvm::BasicBlock, llvm::Loop>::getLoopFor(llvm::BasicBlock const*) const'
../lib/libLLVMProfiling.so: undefined reference to `llvm::LoopInfoBase<llvm::BasicBlock, llvm::Loop>::isLoopHeader(llvm::BasicBlock*) const'
../lib/libLLVMProfiling.so: undefined reference to `llvm::LoopBase<llvm::BasicBlock, llvm::Loop>::contains(llvm::BasicBlock const*) const'
../lib/libLLVMProfiling.so: undefined reference to `llvm::SplitCriticalEdge(llvm::TerminatorInst*, unsigned int, llvm::Pass*, bool, bool, bool)'
../lib/libLLVMProfiling.so: undefined reference to `llvm::LoopBase<llvm::BasicBlock, llvm::Loop>::getLoopLatch() const'
../lib/libLLVMProfiling.so: undefined reference to `llvm::LoopBase<llvm::BasicBlock, llvm::Loop>::getExitEdges(llvm::SmallVectorImpl<std::pair<llvm::BasicBlock const*, llvm::BasicBlock const*> >&) const'
collect2: error: ld returned 1 exit status
src/CMakeFiles/llvm-prof.dir/build.make:147: recipe for target 'src/llvm-prof' failed
make[2]: *** [src/llvm-prof] Error 1
CMakeFiles/Makefile2:201: recipe for target 'src/CMakeFiles/llvm-prof.dir/all' failed
make[1]: *** [src/CMakeFiles/llvm-prof.dir/all] Error 2
Makefile:127: recipe for target 'all' failed
make: *** [all] Error 2

Any idea about what I am doing wrong or how can I solve the problem?

Thanks!

xiehuc commented 7 years ago

i test it on LLVM 3.4 and 3.5.

since LLVM has come to 4.0 the code small differ with 3.5

so it can not build out.

if you need. you could try llvm 3.5 version. or try to modify code directly.

在 2017年8月11日,下午6:47,acornagl notifications@github.com 写道:

Hello, I'm trying to build the project but, unfortunately, I receive an error while linking.

Before to start the build process I setup the path to the LLVM installation and the following gcc/g++ variables (the ones I used to build LLVM):

export CC=/usr/bin/gcc-4.8 export CXX=/usr/bin/g++-4.8 I modified also the `lib/CmakeLists.txt" file to solve a problem with the pthread compilation:

@@ -1,3 +1,7 @@ +set(THREADS_PREFER_PTHREAD_FLAG ON) +find_package(Threads REQUIRED) + + set(SOURCES ValueUtils.cpp ValueProfiling.cpp @@ -44,7 +48,7 @@ add_library(LLVMProfiling-static STATIC ${SOURCES} ) target_link_libraries(LLVMProfiling-static

  • ${LLVM_LIBRARY}
  • ${LLVM_LIBRARY} Threads::Threads tinfo ) set_target_properties(LLVMProfiling-static PROPERTIES @@ -54,7 +58,7 @@ add_library(LLVMProfiling-shared SHARED ${SOURCES} ) target_link_libraries(LLVMProfiling-shared
  • ${LLVM_LIBRARY}
  • ${LLVM_LIBRARY} Threads::Threads tinfo ) set_target_properties(LLVMProfiling-shared PROPERTIES The results of the cmake command is:

-- The C compiler identification is GNU 4.8.5 -- The CXX compiler identification is GNU 4.8.5 -- Check for working C compiler: /usr/bin/gcc-4.8 -- Check for working C compiler: /usr/bin/gcc-4.8 -- works -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Detecting C compile features -- Detecting C compile features - done -- Check for working CXX compiler: /usr/bin/g++-4.8 -- Check for working CXX compiler: /usr/bin/g++-4.8 -- works -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Detecting CXX compile features -- Detecting CXX compile features - done -- Found LLVM Version 3.5.2svn -- Could NOT find GTest (missinundefined reference to `dladdr'g: GTEST_INCLUDE_DIR) -- Add /usr/local/lib/pkgconfig to $PKG_CONFIG_PATH environment variable to let pkg-config find llvm-prof.pc -- Looking for pthread.h -- Looking for pthread.h - found -- Looking for pthread_create -- Looking for pthread_create - not found -- Check if compiler accepts -pthread -- Check if compiler accepts -pthread - yes -- Found Threads: TRUE
-- Configuring done -- Generating done -- Build files have been written to: /local_disk/cornagli/llvm-prof/llvm-prof/build Now, when the result of the make command is:

Scanning dependencies of target llvm-prof [ 75%] Building CXX object src/CMakeFiles/llvm-prof.dir/llvm-prof.cpp.o [ 76%] Building CXX object src/CMakeFiles/llvm-prof.dir/printer.cpp.o [ 78%] Building CXX object src/CMakeFiles/llvm-prof.dir/passes.cpp.o [ 80%] Linking CXX executable llvm-prof /local_disk/cornagli/llvmTracer/llvm3.5Auto/lib/libLLVMSupport.a(Signals.cpp.o): In function llvm::sys::PrintStackTrace(_IO_FILE*)': Signals.cpp:(.text._ZN4llvm3sys15PrintStackTraceEP8_IO_FILE+0x5c): undefined reference todladdr' Signals.cpp:(.text._ZN4llvm3sys15PrintStackTraceEP8_IO_FILE+0xe8): undefined reference to dladdr' ../lib/libLLVMProfiling.so: undefined reference tollvm::Statistic::RegisterStatistic()' ../lib/libLLVMProfiling.so: undefined reference to llvm::LoopInfo::ID' ../lib/libLLVMProfiling.so: undefined reference tollvm::LoopInfoBase<llvm::BasicBlock, llvm::Loop>::getLoopFor(llvm::BasicBlock const) const' ../lib/libLLVMProfiling.so: undefined reference to `llvm::LoopInfoBase<llvm::BasicBlock, llvm::Loop>::isLoopHeader(llvm::BasicBlock) const' ../lib/libLLVMProfiling.so: undefined reference to llvm::LoopBase<llvm::BasicBlock, llvm::Loop>::contains(llvm::BasicBlock const*) const' ../lib/libLLVMProfiling.so: undefined reference tollvm::SplitCriticalEdge(llvm::TerminatorInst, unsigned int, llvm::Pass, bool, bool, bool)' ../lib/libLLVMProfiling.so: undefined reference to llvm::LoopBase<llvm::BasicBlock, llvm::Loop>::getLoopLatch() const' ../lib/libLLVMProfiling.so: undefined reference tollvm::LoopBase<llvm::BasicBlock, llvm::Loop>::getExitEdges(llvm::SmallVectorImpl<std::pair<llvm::BasicBlock const, llvm::BasicBlock const> >&) const' collect2: error: ld returned 1 exit status src/CMakeFiles/llvm-prof.dir/build.make:147: recipe for target 'src/llvm-prof' failed make[2]: [src/llvm-prof] Error 1 CMakeFiles/Makefile2:201: recipe for target 'src/CMakeFiles/llvm-prof.dir/all' failed make[1]: [src/CMakeFiles/llvm-prof.dir/all] Error 2 Makefile:127: recipe for target 'all' failed make: *** [all] Error 2 Any idea about what I am doing wrong or how can I solve the problem?

Thanks!

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/xiehuc/llvm-prof/issues/11, or mute the thread https://github.com/notifications/unsubscribe-auth/AAi55p5U1namVusXU_5gl3RbEpn6u1QPks5sXDErgaJpZM4O0gRc.

acornagl commented 7 years ago

I'm currently using LLVM version 3.5.2. Do you expect that this version should work?

xiehuc commented 7 years ago

OK,i could try fix compile this weekend。

2017年8月11日 +0800 PM7:54 acornagl notifications@github.com,写道:

I'm currently using LLVM version 3.5.2. Do you expect that this version should work? — You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

acornagl commented 7 years ago

Thank you very much!

xiehuc commented 7 years ago

plus,did you use LLVM_RECOMMEND_VERSION compile option?

use ccmake ..

you could see detail

2017年8月11日 +0800 PM7:58 acornagl ,写道:

Thank you very much! — You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

acornagl commented 7 years ago

Yes but it didn' help( cmake LLVM_RECOMMEND_VERSION=3.5.2 ..).

I also modified, by hand, the auto-generated build/src/CMakeFiles/llvm-prof.dir/link.txt file by adding the -ldl flag:

/usr/bin/g++-4.8      CMakeFiles/llvm-prof.dir/llvm-prof.cpp.o CMakeFiles/llvm-prof.dir/printer.cpp.o CMakeFiles/llvm-prof.dir/passes.cpp.o  -o llvm-prof  -L/local_disk/cornagli/llvmTracer/llvm3.5Auto/lib -rdynamic -lLLVMAnalysis -lLLVMTarget -lLLVMMC -lLLVMBitReader -lLLVMCore -lLLVMSupport ../lib/libLLVMProfiling.so -pthread -ltinfo -ldl -Wl,-rpath,/local_disk/cornagli/llvmTracer/llvm3.5Auto/lib:/local_disk/cornagli/llvm-prof/llvm-prof/build/lib: 

Now the error showed by the make command is:

[ 36%] Built target LLVMProfiling-static
[ 73%] Built target LLVMProfiling-shared
[ 75%] Linking CXX executable llvm-prof
../lib/libLLVMProfiling.so: undefined reference to `llvm::Statistic::RegisterStatistic()'
../lib/libLLVMProfiling.so: undefined reference to `llvm::LoopInfo::ID'
../lib/libLLVMProfiling.so: undefined reference to `llvm::LoopInfoBase<llvm::BasicBlock, llvm::Loop>::getLoopFor(llvm::BasicBlock const*) const'
../lib/libLLVMProfiling.so: undefined reference to `llvm::LoopInfoBase<llvm::BasicBlock, llvm::Loop>::isLoopHeader(llvm::BasicBlock*) const'
../lib/libLLVMProfiling.so: undefined reference to `llvm::LoopBase<llvm::BasicBlock, llvm::Loop>::contains(llvm::BasicBlock const*) const'
../lib/libLLVMProfiling.so: undefined reference to `llvm::SplitCriticalEdge(llvm::TerminatorInst*, unsigned int, llvm::Pass*, bool, bool, bool)'
../lib/libLLVMProfiling.so: undefined reference to `llvm::LoopBase<llvm::BasicBlock, llvm::Loop>::getLoopLatch() const'
../lib/libLLVMProfiling.so: undefined reference to `llvm::LoopBase<llvm::BasicBlock, llvm::Loop>::getExitEdges(llvm::SmallVectorImpl<std::pair<llvm::BasicBlock const*, llvm::BasicBlock const*> >&) const'
collect2: error: ld returned 1 exit status
src/CMakeFiles/llvm-prof.dir/build.make:147: recipe for target 'src/llvm-prof' failed
make[2]: *** [src/llvm-prof] Error 1
CMakeFiles/Makefile2:201: recipe for target 'src/CMakeFiles/llvm-prof.dir/all' failed
make[1]: *** [src/CMakeFiles/llvm-prof.dir/all] Error 2
Makefile:127: recipe for target 'all' failed
make: *** [all] Error 2
xiehuc commented 7 years ago

cmake .. -DLLVM_RECOMMEND_VERSION=3.5

you set VERSION is for lookup llvm-config-3.5

so, there are not llvm-config-3.5.2 at all.

xiehuc commented 7 years ago

tested ubuntu 16.04.2 just minutes ago

xiehuc@virtualbox:~/llvm/llvm-prof-master/build$ ls lib/ CMakeFiles cmake_install.cmake datatype datatype.h libLLVMProfiling.a libLLVMProfiling.so Makefile