本文主要解决centos7 4.18内核系统eBPF编译环境搭建
关于如何在centos7安装4.18内核,这个网上有大把教程,不再赘述
centos7 默认clang llvm版本较低,不识别-target=bpf命令,因此需要对clang进行升级
编译llvm,需要gcc至少为 5.1版本,centos默认安装的是 gcc 4.8.5。
yum install centos-release-scl
yum install devtoolset-7
当前登陆session生效
scl enable devtoolset-7
bash source /opt/rh/devtoolset-7/enable
echo "source /opt/rh/devtoolset-7/enable" >> ~/.bash_profile
source /opt/rh/devtoolset-7/enable
https://github.com/Kitware/CMake/releases/download/v3.14.0/cmake-3.14.0.tar.gz
tar -zxvf cmake-3.14.0.tar.gz
cd cmake-3.14.0
./bootstrap
make
make install
git clone https://github.com/llvm/llvm-project.git
cd llvm-project
git checkout origin/release/9.x
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_RTTI=ON -DLLVM_ENABLE_PROJECTS="clang;libcxx;libcxxabi" -G "Unix Makefiles" ../llvm
make
make install
安装libelf zlib
yum install -y elfutils-libelf-devel
安装libbpf
git clone https://github.com/libbpf/libbpf
cd libbpf/src
make
make install
至此,环境搭建完成,愉快的Coding
Comments
Be the first one to comment on this page!