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

Failed to build debug version of SVF #180

Open
p2041 opened this issue Feb 23, 2020 · 7 comments
Open

Failed to build debug version of SVF #180

p2041 opened this issue Feb 23, 2020 · 7 comments

Comments

@p2041
Copy link

p2041 commented Feb 23, 2020

Hello

I try to compile the most recent version of SVF.
I followed the instructions in the following link
https://github.com/SVF-tools/SVF/wiki/Setup-Guide-in-Local-Physical-Machine

Only difference is I use LLVM + Clang 9.0 for Ubuntu 16.04 instead of 18.04 since my Ubuntu version is 16.04.
I tried to compile it with the "Debug" option. But, I got the following error messages.

[ 98%] Linking CXX executable ../../bin/wpa
[ 98%] Building CXX object lib/CMakeFiles/Svf.dir/WPA/AndersenWaveDiff.cpp.o
[ 98%] Linking CXX executable ../../bin/saber
../../lib/libLLVMSvf.a(SVFGBuilder.cpp.o): In function llvm::ForwardDominanceFrontierBase<llvm::BasicBlock>::ForwardDominanceFrontierBase()': ~/llvm/llvm-9.0.0/include/llvm/Analysis/DominanceFrontier.h:122: undefined reference to llvm::DominanceFrontierBase<llvm::BasicBlock, false>::DominanceFrontierBase()'
collect2: error: ld returned 1 exit status
tools/SABER/CMakeFiles/saber.dir/build.make:117: recipe for target 'bin/saber' failed
make[2]: *** [bin/saber] Error 1
CMakeFiles/Makefile2:598: recipe for target 'tools/SABER/CMakeFiles/saber.dir/all' failed
make[1]: *** [tools/SABER/CMakeFiles/saber.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
[ 98%] Building CXX object lib/CMakeFiles/Svf.dir/WPA/CSC.cpp.o
[ 99%] Building CXX object lib/CMakeFiles/Svf.dir/WPA/AndersenWaveDiffWithType.cpp.o
../../lib/libLLVMSvf.a(SVFGBuilder.cpp.o): In function llvm::ForwardDominanceFrontierBase<llvm::BasicBlock>::ForwardDominanceFrontierBase()': ~/llvm/llvm-9.0.0/include/llvm/Analysis/DominanceFrontier.h:122: undefined reference to llvm::DominanceFrontierBase<llvm::BasicBlock, false>::DominanceFrontierBase()'
collect2: error: ld returned 1 exit status
tools/WPA/CMakeFiles/wpa.dir/build.make:117: recipe for target 'bin/wpa' failed
make[2]: *** [bin/wpa] Error 1
CMakeFiles/Makefile2:654: recipe for target 'tools/WPA/CMakeFiles/wpa.dir/all' failed
make[1]: *** [tools/WPA/CMakeFiles/wpa.dir/all] Error 2

On the other hand, I succeeded in compiling "Release" version.
However, I want to use "Debug" version if possible.

Could you help me?

Note: cmake version: 3.13.3 which worked with SVF 1.7 stable version.

@nisarg-ujjainkar
Copy link

I used the following command to build the debug version and it works for me.

/usr/bin/cmake --build /path_to_SVF/build --config Debug --target all -- -j 6

@p2041
Copy link
Author

p2041 commented Feb 23, 2020

Dear @nisarg-ujjainkar
Thank you for your help.
Since your command showed error msg, I used "cmake --config Debug ../" instead in the "build" directory.
Then, I executed "make -j4" or "make -j6"
I succeeded in the compilation.
However, I think that is compiled as "debug mode".
For example, if I encounter errors w/ gdb, I cannot track the debug symbol as follows.

wpa: ~/SVF/lib/MemoryModel/PAGBuilder.cpp:900: virtual void PAGBuilder::handleExtCall(CallSite, const Function*): Assertion `fields.size() >= 4 && "_Rb_tree_node_base should have at least 4 fields.\n"' failed.

Program received signal SIGABRT, Aborted.
0x00007ffff6b41428 in __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:54
54 ../sysdeps/unix/sysv/linux/raise.c: No such file or directory.
(gdb) info stack
#0 0x00007ffff6b41428 in __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:54
#1 0x00007ffff6b4302a in __GI_abort () at abort.c:89
#2 0x00007ffff6b39bd7 in __assert_fail_base (fmt=,
assertion=assertion@entry=0xb77d88 "fields.size() >= 4 && "_Rb_tree_node_base should have at least 4 fields.\n"",
file=file@entry=0xb77ad0 "/SVF/lib/MemoryModel/PAGBuilder.cpp", line=line@entry=900,
function=function@entry=0xb789a0 <PAGBuilder::handleExtCall(llvm::CallSite, llvm::Function const*)::PRETTY_FUNCTION> "virtual void PAGBuilder::handleExtCall(CallSite, const Function*)") at assert.c:92
#3 0x00007ffff6b39c82 in __GI___assert_fail (
assertion=0xb77d88 "fields.size() >= 4 && "_Rb_tree_node_base should have at least 4 fields.\n"",
file=0xb77ad0 "
/SVF/lib/MemoryModel/PAGBuilder.cpp", line=900,
function=0xb789a0 <PAGBuilder::handleExtCall(llvm::CallSite, llvm::Function const*)::PRETTY_FUNCTION> "virtual void PAGBuilder::handleExtCall(CallSite, const Function*)") at assert.c:101
#4 0x0000000000500639 in PAGBuilder::handleExtCall(llvm::CallSite, llvm::Function const*) ()
#5 0x00000000010029e8 in ?? ()
#6 0x0000000001002998 in ?? ()
#7 0x0000000000f36130 in ?? ()
#8 0x00007fffffffdb30 in ?? ()
#9 0x0000000001002a9a in ?? ()
#10 0x0000003100000004 in ?? ()
#11 0x000000000fe60ee0 in ?? ()
#12 0x000000000fe60f08 in ?? ()
#13 0x000000000fe60f08 in ?? ()
#14 0x0000000000000000 in ?? ()

In the call stack from 5-14, it should show some function name.
However, I couldn't find it.
Anyhow thank you for your feedback.

@p2041
Copy link
Author

p2041 commented Feb 24, 2020

I solved this problem (although I don't know the reason. Maybe it is related to compiler issue).
In CMakeLists.txt file, I found that release version uses "-O3" but debug version uses "-O0".
So, I changed it to "-O1" and "-O3" for debug version compilation as follows:

if(CMAKE_BUILD_TYPE MATCHES "Debug")
#     set(CMAKE_CXX_FLAGS "-std=gnu++11 -O0 -fno-rtti")
      set(CMAKE_CXX_FLAGS "-std=gnu++11 -O1 -fno-rtti")
else()
      set(CMAKE_CXX_FLAGS "-std=gnu++11 -O3 -fno-rtti")
endif()

Then, it starts to be compiled.

I may need to use -O1 while I hope -O1 does not increase in debugging difficulty.
At this time, I don't close this issue. But, if developers want to close this issue, feel free to close it.

PS. My GCC is 5.4.

@yuleisui
Copy link
Collaborator

Will this pull request solve your problem? #186

@p2041
Copy link
Author

p2041 commented Feb 28, 2020

@yuleisui Unfortunately, no....

[ 98%] Linking CXX static library libLLVMSvf.a
[ 98%] Built target LLVMSvf
Scanning dependencies of target saber
[ 99%] Building CXX object tools/SABER/CMakeFiles/saber.dir/saber.cpp.o
Scanning dependencies of target wpa
[ 99%] Building CXX object tools/WPA/CMakeFiles/wpa.dir/wpa.cpp.o
[ 99%] Linking CXX static library libSvf.a
[ 99%] Built target Svf
[ 99%] Linking CXX executable ../../bin/saber
[100%] Linking CXX executable ../../bin/wpa
../../lib/libLLVMSvf.a(SVFGBuilder.cpp.o): In function llvm::ForwardDominanceFrontierBase<llvm::BasicBlock>::ForwardDominanceFrontierBase()': ~/llvm/llvm-9.0.0/include/llvm/Analysis/DominanceFrontier.h:122: undefined reference to llvm::DominanceFrontierBase<llvm::BasicBlock, false>::DominanceFrontierBase()'
collect2: error: ld returned 1 exit status
tools/SABER/CMakeFiles/saber.dir/build.make:117: recipe for target 'bin/saber' failed
make[2]: *** [bin/saber] Error 1
CMakeFiles/Makefile2:598: recipe for target 'tools/SABER/CMakeFiles/saber.dir/all' failed
make[1]: *** [tools/SABER/CMakeFiles/saber.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
../../lib/libLLVMSvf.a(SVFGBuilder.cpp.o): In function llvm::ForwardDominanceFrontierBase<llvm::BasicBlock>::ForwardDominanceFrontierBase()': ~/llvm/llvm-9.0.0/include/llvm/Analysis/DominanceFrontier.h:122: undefined reference to llvm::DominanceFrontierBase<llvm::BasicBlock, false>::DominanceFrontierBase()'
collect2: error: ld returned 1 exit status
tools/WPA/CMakeFiles/wpa.dir/build.make:117: recipe for target 'bin/wpa' failed
make[2]: *** [bin/wpa] Error 1
CMakeFiles/Makefile2:654: recipe for target 'tools/WPA/CMakeFiles/wpa.dir/all' failed
make[1]: *** [tools/WPA/CMakeFiles/wpa.dir/all] Error 2
Makefile:129: recipe for target 'all' failed
make: *** [all] Error 2

@yuleisui
Copy link
Collaborator

Would this be a GCC bug? what about compiling SVF using clang?

cmake -DCMAKE_CXX_COMPILER=your_path_to_clang/clang++ -DLLVM_DIR=$LLVM_HOME
make -j4

@p2041
Copy link
Author

p2041 commented Feb 28, 2020

@yuleisui It works with clang. For your reference, I used the following options for cmake.

cmake -D CMAKE_BUILD_TYPE:STRING=Debug -DCMAKE_CXX_COMPILER=/path_to_clang/clang++ -DLLVM_DIR=/path_to_llvm/llvm-9.0.0 ../

Then, with a high possibility, it could be ... GCC bug.?
As a reminder, I note that "Release" version can be compilable with GCC - not "Debug" version.

Note: Ubuntu 16.04 with GCC 5.4. I am also using LLVM 9.0 for Ubuntu 16.04.

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

3 participants