iovisor / bcc

BCC - Tools for BPF-based Linux IO analysis, networking, monitoring, and more
Apache License 2.0
20.31k stars 3.85k forks source link

clang error: could not convert when build bcc with centos #1778

Closed suxiaobei1024 closed 6 years ago

suxiaobei1024 commented 6 years ago

I got a intresting issue when I build bcc. Firstly, I build llvm from source code. Finally there are some error when I build bcc.

What I done is:

========1. build llvm

Build LLVM and Clang development libs
git clone http://llvm.org/git/llvm.git
cd llvm/tools; git clone http://llvm.org/git/clang.git
cd ..; mkdir -p build/install; cd build
cmake -G "Unix Makefiles" -DLLVM_TARGETS_TO_BUILD="BPF;X86" \
  -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$PWD/install ..
make
make install
export PATH=$PWD/install/bin:$PATH

========2. bcc build requires
sudo yum  install -y bison cmake ethtool flex git iperf libstdc++-static \
  python-netaddr python-pip gcc gcc-c++ make zlib-devel \
  elfutils-libelf-devel
sudo yum install -y luajit luajit-devel  # for Lua support
sudo yum install -y \
  http://repo.iovisor.org/yum/extra/mageia/cauldron/x86_64/netperf-2.7.0-1.mga6.x86_64.rpm
sudo pip install pyroute2

=======3. build bcc
cd bcc
mkdir build 
cd build 

#cmake ..
-- Latest recognized Git tag is -128-NOTFOUND
-- Git HEAD is 2d120db7958f88d751d65ef28efd74395b1c9830
-- Revision is 128-NOTFOUND-2d120db7
-- Found LLVM: /root/ebcc/llvm/build/install/include 7.0.0svn
CMake Warning at tests/python/CMakeLists.txt:10 (message):
  Recommended test program 'netperf' not found

-- Configuring done
-- Generating done
-- Build files have been written to: /root/bcc/bcc/build

Error occurred:

#make
[  2%] Built target bpf-shared
[  3%] Building CXX object src/cc/frontends/clang/CMakeFiles/clang_frontend.dir/b_frontend_action.cc.o
/root/ebcc/ebcc/src/cc/frontends/clang/b_frontend_action.cc: In member function ‘clang::SourceRange ebpf::ProbeVisitor::expansionRange(clang::SourceRange)’:
/root/ebcc/ebcc/src/cc/frontends/clang/b_frontend_action.cc:267:58: error: could not convert ‘(&(&((ebpf::ProbeVisitor*)this)->ebpf::ProbeVisitor::rewriter_)->clang::Rewriter::getSourceMgr())->clang::SourceManager::getExpansionRange(range)’ from ‘clang::CharSourceRange’ to ‘clang::SourceRange’
   return rewriter_.getSourceMgr().getExpansionRange(range);
                                                          ^
/root/ebcc/ebcc/src/cc/frontends/clang/b_frontend_action.cc: In member function ‘clang::SourceRange ebpf::BTypeVisitor::expansionRange(clang::SourceRange)’:
/root/ebcc/ebcc/src/cc/frontends/clang/b_frontend_action.cc:657:58: error: could not convert ‘(&(&((ebpf::BTypeVisitor*)this)->ebpf::BTypeVisitor::rewriter_)->clang::Rewriter::getSourceMgr())->clang::SourceManager::getExpansionRange(range)’ from ‘clang::CharSourceRange’ to ‘clang::SourceRange’
   return rewriter_.getSourceMgr().getExpansionRange(range);
                                                          ^
/root/ebcc/ebcc/src/cc/frontends/clang/b_frontend_action.cc: In member function ‘clang::SourceRange ebpf::ProbeVisitor::expansionRange(clang::SourceRange)’:
/root/ebcc/ebcc/src/cc/frontends/clang/b_frontend_action.cc:268:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
/root/ebcc/ebcc/src/cc/frontends/clang/b_frontend_action.cc: In member function ‘clang::SourceRange ebpf::BTypeVisitor::expansionRange(clang::SourceRange)’:
/root/ebcc/ebcc/src/cc/frontends/clang/b_frontend_action.cc:658:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
make[2]: *** [src/cc/frontends/clang/CMakeFiles/clang_frontend.dir/b_frontend_action.cc.o] Error 1
make[1]: *** [src/cc/frontends/clang/CMakeFiles/clang_frontend.dir/all] Error 2
make: *** [all] Error 2
yonghong-song commented 6 years ago

Looks like you bcc code is old. The old bcc code may not compile with latest llvm trunk. You need to have latest bcc code.

palmtenor commented 6 years ago

@muahao Are you still able to repro the issue with BCC trunk?

suxiaobei1024 commented 6 years ago

@palmtenor

Maybe it's just related to my centos's environment, After these

#yum install -y bison cmake ethtool flex git iperf libstdc++-static python-netaddr python-pip gcc gcc-c++ make zlib-devel elfutils-libelf-devel ncurses-devel 

#yum install llvm cfe -y 

cann't reproduce it now.