Skip to content

Instantly share code, notes, and snippets.

@phosphore
Created January 6, 2020 14:48
Show Gist options
  • Save phosphore/3bb7bfd11c15f3d71d4b743d6806384b to your computer and use it in GitHub Desktop.
Save phosphore/3bb7bfd11c15f3d71d4b743d6806384b to your computer and use it in GitHub Desktop.
#!/bin/bash
set -e
if [[ $EUID -ne 0 ]]; then
echo "Please run this script as root or sudo."
exit 1
fi
# Create a temporary to build tooling in.
BUILD_DIR=$(mktemp -d)
cd $BUILD_DIR
echo "Building in $BUILD_DIR."
# Install Extra Packages for Enterprise Linux (EPEL)
yum install -y epel-release
yum update -y
# Install development tools.
yum groupinstall -y "Development tools"
yum install -y elfutils-libelf-devel cmake3 git bison flex ncurses-devel
# Download and install LLVM and Clang. Build them with BPF target.
curl -LO http://releases.llvm.org/7.0.1/llvm-7.0.1.src.tar.xz
curl -LO http://releases.llvm.org/7.0.1/cfe-7.0.1.src.tar.xz
tar -xf cfe-7.0.1.src.tar.xz
tar -xf llvm-7.0.1.src.tar.xz
mkdir clang-build
mkdir llvm-build
cd llvm-build
cmake3 -G "Unix Makefiles" -DLLVM_TARGETS_TO_BUILD="BPF;X86" \
-DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr ../llvm-7.0.1.src
make
make install
cd ..
cd clang-build
cmake3 -G "Unix Makefiles" -DLLVM_TARGETS_TO_BUILD="BPF;X86" \
-DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr ../cfe-7.0.1.src
make
make install
cd ..
# Install BCC.
git clone https://github.com/iovisor/bcc.git
cd bcc && git checkout v0.11.0
mkdir bcc/build; cd bcc/build
cmake3 .. -DCMAKE_INSTALL_PREFIX=/usr
make
make install
# Install is done.
rm -fr $BUILD_DIR
echo "Install is complete, try running /usr/share/bcc/tools/execsnoop to verify install."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment