1# Installing BCC 2 3* [Kernel Configuration](#kernel-configuration) 4* [Packages](#packages) 5 - [Debian](#debian---binary) 6 - [Ubuntu](#ubuntu---binary) 7 - [Fedora](#fedora---binary) 8 - [Arch](#arch---binary) 9 - [Gentoo](#gentoo---portage) 10 - [openSUSE](#opensuse---binary) 11 - [RHEL](#rhel---binary) 12 - [Amazon Linux 1](#amazon-linux-1---binary) 13 - [Amazon Linux 2](#amazon-linux-2---binary) 14 - [Alpine](#alpine---binary) 15 - [WSL](#wslwindows-subsystem-for-linux---binary) 16* [Source](#source) 17 - [libbpf Submodule](#libbpf-submodule) 18 - [Debian](#debian---source) 19 - [Ubuntu](#ubuntu---source) 20 - [Fedora](#fedora---source) 21 - [openSUSE](#opensuse---source) 22 - [Centos](#centos---source) 23 - [Amazon Linux 1](#amazon-linux-1---source) 24 - [Amazon Linux 2](#amazon-linux-2---source) 25 - [Alpine](#alpine---source) 26 - [Arch](#arch---source) 27* [Older Instructions](#older-instructions) 28 29## Kernel Configuration 30 31In general, to use these features, a Linux kernel version 4.1 or newer is 32required. In addition, the kernel should have been compiled with the following 33flags set: 34 35``` 36CONFIG_BPF=y 37CONFIG_BPF_SYSCALL=y 38# [optional, for tc filters] 39CONFIG_NET_CLS_BPF=m 40# [optional, for tc actions] 41CONFIG_NET_ACT_BPF=m 42CONFIG_BPF_JIT=y 43# [for Linux kernel versions 4.1 through 4.6] 44CONFIG_HAVE_BPF_JIT=y 45# [for Linux kernel versions 4.7 and later] 46CONFIG_HAVE_EBPF_JIT=y 47# [optional, for kprobes] 48CONFIG_BPF_EVENTS=y 49# Need kernel headers through /sys/kernel/kheaders.tar.xz 50CONFIG_IKHEADERS=y 51``` 52 53There are a few optional kernel flags needed for running bcc networking examples on vanilla kernel: 54 55``` 56CONFIG_NET_SCH_SFQ=m 57CONFIG_NET_ACT_POLICE=m 58CONFIG_NET_ACT_GACT=m 59CONFIG_DUMMY=m 60CONFIG_VXLAN=m 61``` 62 63Kernel compile flags can usually be checked by looking at `/proc/config.gz` or 64`/boot/config-<kernel-version>`. 65 66# Packages 67 68## Debian - Binary 69 70`bcc` and its tools are available in the standard Debian main repository, from the source package [bpfcc](https://packages.debian.org/source/sid/bpfcc) under the names `bpfcc-tools`, `python3-bpfcc`, `libbpfcc` and `libbpfcc-dev`. 71 72To install: 73 74```bash 75echo deb http://cloudfront.debian.net/debian sid main >> /etc/apt/sources.list 76sudo apt-get install -y bpfcc-tools libbpfcc libbpfcc-dev linux-headers-$(uname -r) 77``` 78 79## Ubuntu - Binary 80 81Versions of bcc are available in the standard Ubuntu 82Universe repository, as well in iovisor's PPA. The Ubuntu packages have slightly different names: where iovisor 83packages use `bcc` in the name (e.g. `bcc-tools`), Ubuntu packages use `bpfcc` (e.g. 84`bpfcc-tools`). 85 86Currently, BCC packages for both the Ubuntu Universe, and the iovisor builds are outdated. This is a known and tracked in: 87- [Universe - Ubuntu Launchpad](https://bugs.launchpad.net/ubuntu/+source/bpfcc/+bug/1848137) 88- [iovisor - BCC GitHub Issues](https://github.com/iovisor/bcc/issues/2678) 89Currently, [building from source](#ubuntu---source) is currently the only way to get up to date packaged version of bcc. 90 91**Ubuntu Packages** 92Source packages and the binary packages produced from them can be 93found at [packages.ubuntu.com](https://packages.ubuntu.com/search?suite=default§ion=all&arch=any&keywords=bpfcc&searchon=sourcenames). 94 95```bash 96sudo apt-get install bpfcc-tools linux-headers-$(uname -r) 97``` 98 99The tools are installed in `/sbin` (`/usr/sbin` in Ubuntu 18.04) with a `-bpfcc` extension. Try running `sudo opensnoop-bpfcc`. 100 101**_Note_**: the Ubuntu packages have different names but the package contents, in most cases, conflict 102and as such _cannot_ be installed alongside upstream packages. Should one choose to use 103Ubuntu's packages instead of the upstream iovisor packages (or vice-versa), the 104conflicting packages will need to be removed. 105 106The iovisor packages _do_ declare they provide the Ubuntu packages and as such may be 107used to satisfy dependencies. For example, should one attempt to install package `foo` 108which declares a dependency on `libbpfcc` while the upstream `libbcc` package is installed, 109`foo` should install without trouble as `libbcc` declares that it provides `libbpfcc`. 110That said, one should always test such a configuration in case of version incompatibilities. 111 112**iovisor packages (Upstream Stable and Signed Packages)** 113 114```bash 115sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 4052245BD4284CDD 116echo "deb https://repo.iovisor.org/apt/$(lsb_release -cs) $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/iovisor.list 117sudo apt-get update 118sudo apt-get install bcc-tools libbcc-examples linux-headers-$(uname -r) 119``` 120(replace `xenial` with `artful` or `bionic` as appropriate). Tools will be installed under /usr/share/bcc/tools. 121 122**Upstream Nightly Packages** 123 124```bash 125echo "deb [trusted=yes] https://repo.iovisor.org/apt/xenial xenial-nightly main" | sudo tee /etc/apt/sources.list.d/iovisor.list 126sudo apt-get update 127sudo apt-get install bcc-tools libbcc-examples linux-headers-$(uname -r) 128``` 129(replace `xenial` with `artful` or `bionic` as appropriate) 130 131## Fedora - Binary 132 133### Fedora 30 and newer 134 135As of Fedora 30, bcc binaries are available in the standard repository. 136You can install them via 137 138```bash 139sudo dnf install bcc 140``` 141 142**Note**: if you keep getting `Failed to load program: Operation not permitted` when 143trying to run the `hello_world.py` example as root then you might need to lift 144the so-called kernel lockdown (cf. 145[FAQ](https://github.com/iovisor/bcc/blob/c00d10d4552f647491395e326d2e4400f3a0b6c5/FAQ.txt#L24), 146[background article](https://gehrcke.de/2019/09/running-an-ebpf-program-may-require-lifting-the-kernel-lockdown)). 147 148 149### Fedora 29 and older 150 151Ensure that you are running a 4.2+ kernel with `uname -r`. If not, install a 4.2+ kernel from 152http://alt.fedoraproject.org/pub/alt/rawhide-kernel-nodebug, for example: 153 154```bash 155sudo dnf config-manager --add-repo=http://alt.fedoraproject.org/pub/alt/rawhide-kernel-nodebug/fedora-rawhide-kernel-nodebug.repo 156sudo dnf update 157# reboot 158``` 159 160**Nightly Packages** 161 162Nightly bcc binary packages for Fedora 25, 26, 27, and 28 are hosted at 163`https://repo.iovisor.org/yum/nightly/f{25,26,27}`. 164 165To install: 166```bash 167echo -e '[iovisor]\nbaseurl=https://repo.iovisor.org/yum/nightly/f27/$basearch\nenabled=1\ngpgcheck=0' | sudo tee /etc/yum.repos.d/iovisor.repo 168sudo dnf install bcc-tools kernel-headers kernel-devel 169``` 170 171**Stable and Signed Packages** 172 173Stable bcc binary packages for Fedora 25, 26, 27, and 28 are hosted at 174`https://repo.iovisor.org/yum/main/f{25,26,27}`. 175 176```bash 177echo -e '[iovisor]\nbaseurl=https://repo.iovisor.org/yum/main/f27/$basearch\nenabled=1' | sudo tee /etc/yum.repos.d/iovisor.repo 178sudo dnf install bcc-tools kernel-devel-$(uname -r) kernel-headers-$(uname -r) 179``` 180 181## Arch - Binary 182 183bcc is available in the standard Arch repos, so it can be installed with the `pacman` command: 184``` 185# pacman -S bcc bcc-tools python-bcc 186``` 187 188## Gentoo - Portage 189 190First of all, upgrade the kernel of your choice to a recent version. For example: 191``` 192emerge sys-kernel/gentoo-sources 193``` 194Then, configure the kernel enabling the features you need. Please consider the following as a starting point: 195``` 196CONFIG_BPF=y 197CONFIG_BPF_SYSCALL=y 198CONFIG_NET_CLS_BPF=m 199CONFIG_NET_ACT_BPF=m 200CONFIG_BPF_JIT=y 201CONFIG_BPF_EVENTS=y 202``` 203Finally, you can install bcc with: 204``` 205emerge dev-util/bcc 206``` 207The appropriate dependencies (e.g., ```clang```, ```llvm``` with BPF backend) will be pulled automatically. 208 209## openSUSE - Binary 210 211For openSUSE Leap 42.2 (and later) and Tumbleweed, bcc is already included in the official repo. Just install 212the packages with zypper. 213 214```bash 215sudo zypper ref 216sudo zypper in bcc-tools bcc-examples 217``` 218 219## RHEL - Binary 220 221For RHEL 7.6, bcc is already included in the official yum repository as bcc-tools. As part of the install, the following dependencies are installed: bcc.x86_64 0:0.6.1-2.el7 ,llvm-private.x86_64 0:6.0.1-2.el7 ,python-bcc.x86_64 0:0.6.1-2.el7,python-netaddr.noarch 0:0.7.5-9.el7 222 223``` 224yum install bcc-tools 225``` 226 227## Amazon Linux 1 - Binary 228Use case 1. Install BCC for latest kernel available in repo: 229 Tested on Amazon Linux AMI release 2018.03 (kernel 4.14.88-72.73.amzn1.x86_64) 230``` 231sudo yum update kernel 232sudo yum install bcc 233sudo reboot 234``` 235 236Use case 2. Install BCC for your AMI's default kernel (no reboot required): 237 Tested on Amazon Linux AMI release 2018.03 (kernel 4.14.77-70.59.amzn1.x86_64) 238``` 239sudo yum install kernel-headers-$(uname -r | cut -d'.' -f1-5) 240sudo yum install kernel-devel-$(uname -r | cut -d'.' -f1-5) 241sudo yum install bcc 242``` 243 244## Amazon Linux 2 - Binary 245Use case 1. Install BCC for your AMI's default kernel (no reboot required): 246 Tested on Amazon Linux AMI release 2021.11 (kernel 5.10.75-79.358.amzn2.x86_64) 247``` 248sudo amazon-linux-extras install BCC 249``` 250 251## Alpine - Binary 252 253As of Alpine 3.11, bcc binaries are available in the community repository: 254 255``` 256sudo apk add bcc-tools bcc-doc 257``` 258 259The tools are installed in `/usr/share/bcc/tools`. 260 261**Python Compatibility** 262 263The binary packages include bindings for Python 3 only. The Python-based tools assume that a `python` binary is available at `/usr/bin/python`, but that may not be true on recent versions of Alpine. If you encounter errors like `<tool-name>: not found`, you can try creating a symlink to the Python 3.x binary like so: 264 265``` 266sudo ln -s $(which python3) /usr/bin/python 267``` 268 269**Containers** 270 271Alpine Linux is often used as a base system for containers. `bcc` can be used in such an environment by launching the container in privileged mode with kernel modules available through bind mounts: 272 273``` 274sudo docker run --rm -it --privileged \ 275 -v /lib/modules:/lib/modules:ro \ 276 -v /sys:/sys:ro \ 277 -v /usr/src:/usr/src:ro \ 278 alpine:3.12 279``` 280 281## WSL(Windows Subsystem for Linux) - Binary 282 283### Install dependencies 284The compiling depends on the headers and lib of linux kernel module which was not found in wsl distribution packages repo. We have to compile the kernel module manually. 285```bash 286apt-get install flex bison libssl-dev libelf-dev dwarves 287``` 288### Install packages 289 290First, you will need to checkout the WSL2 Linux kernel git repository: 291``` 292KERNEL_VERSION=$(uname -r | cut -d '-' -f 1) 293git clone --depth 1 https://github.com/microsoft/WSL2-Linux-Kernel.git -b linux-msft-wsl-$KERNEL_VERSION 294cd WSL2-Linux-Kernel 295``` 296 297Then compile and install: 298``` 299cp Microsoft/config-wsl .config 300make oldconfig && make prepare 301make scripts 302make modules 303sudo make modules_install 304```` 305 306After install the module you will need to change the name of the directory to remove the '+' at the end 307 308```` 309mv /lib/modules/$KERNEL_VERSION-microsoft-standard-WSL2+/ /lib/modules/$KERNEL_VERSION-microsoft-standard-WSL2 310```` 311 312Then you can install bcc tools package according your distribution. 313 314If you met some problems, try to 315``` 316sudo mount -t debugfs debugfs /sys/kernel/debug 317``` 318 319# Source 320 321## libbpf Submodule 322 323Since release v0.10.0, bcc starts to leverage libbpf repo (https://github.com/libbpf/libbpf) 324to provide wrapper functions to the kernel for bpf syscalls, uapi headers bpf.h/btf.h etc. 325Unfortunately, the default github release source code does not contain libbpf submodule 326source code and this will cause build issues. 327 328To alleviate this problem, starting at release v0.11.0, source code with corresponding 329libbpf submodule codes will be released as well. See https://github.com/iovisor/bcc/releases. 330 331## Debian - Source 332### sid 333#### Repositories 334 335`/etc/apt/sources.list` should include the `non-free` repository and look something like this: 336 337``` 338deb http://deb.debian.org/debian sid main contrib non-free 339deb-src http://deb.debian.org/debian sid main contrib non-free 340``` 341 342#### Install Build Dependencies 343``` 344# Before you begin 345apt-get update 346# According to https://packages.debian.org/source/sid/bpfcc, 347# BCC build dependencies: 348sudo apt-get install arping bison clang-format cmake dh-python \ 349 dpkg-dev pkg-kde-tools ethtool flex inetutils-ping iperf \ 350 libbpf-dev libclang-dev libclang-cpp-dev libedit-dev libelf-dev \ 351 libfl-dev libzip-dev linux-libc-dev llvm-dev libluajit-5.1-dev \ 352 luajit python3-netaddr python3-pyroute2 python3-setuptools python3 353``` 354 355#### Install and compile BCC 356``` 357git clone https://github.com/iovisor/bcc.git 358mkdir bcc/build; cd bcc/build 359cmake .. 360make 361sudo make install 362``` 363 364## Ubuntu - Source 365 366To build the toolchain from source, one needs: 367* LLVM 3.7.1 or newer, compiled with BPF support (default=on) 368* Clang, built from the same tree as LLVM 369* cmake (>=3.1), gcc (>=4.7), flex, bison 370* LuaJIT, if you want Lua support 371* Optional tools used in some examples: arping, netperf, and iperf 372 373### Install build dependencies 374``` 375# Trusty (14.04 LTS) and older 376VER=trusty 377echo "deb http://llvm.org/apt/$VER/ llvm-toolchain-$VER-3.7 main 378deb-src http://llvm.org/apt/$VER/ llvm-toolchain-$VER-3.7 main" | \ 379 sudo tee /etc/apt/sources.list.d/llvm.list 380wget -O - http://llvm.org/apt/llvm-snapshot.gpg.key | sudo apt-key add - 381sudo apt-get update 382 383# For Bionic (18.04 LTS) 384sudo apt-get -y install zip bison build-essential cmake flex git libedit-dev \ 385 libllvm6.0 llvm-6.0-dev libclang-6.0-dev python zlib1g-dev libelf-dev libfl-dev python3-setuptools \ 386 liblzma-dev arping netperf iperf 387 388# For Focal (20.04.1 LTS) 389sudo apt install -y zip bison build-essential cmake flex git libedit-dev \ 390 libllvm12 llvm-12-dev libclang-12-dev python zlib1g-dev libelf-dev libfl-dev python3-setuptools \ 391 liblzma-dev arping netperf iperf 392 393# For Hirsute (21.04) or Impish (21.10) 394sudo apt install -y zip bison build-essential cmake flex git libedit-dev \ 395 libllvm11 llvm-11-dev libclang-11-dev python3 zlib1g-dev libelf-dev libfl-dev python3-setuptools \ 396 liblzma-dev arping netperf iperf 397 398# For Jammy (22.04) 399sudo apt install -y zip bison build-essential cmake flex git libedit-dev \ 400 libllvm14 llvm-14-dev libclang-14-dev python3 zlib1g-dev libelf-dev libfl-dev python3-setuptools \ 401 liblzma-dev libdebuginfod-dev arping netperf iperf 402 403# For Lunar Lobster (23.04) 404sudo apt install -y zip bison build-essential cmake flex git libedit-dev \ 405 libllvm15 llvm-15-dev libclang-15-dev python3 zlib1g-dev libelf-dev libfl-dev python3-setuptools \ 406 liblzma-dev libdebuginfod-dev arping netperf iperf libpolly-15-dev 407 408# For other versions 409sudo apt-get -y install zip bison build-essential cmake flex git libedit-dev \ 410 libllvm3.7 llvm-3.7-dev libclang-3.7-dev python zlib1g-dev libelf-dev python3-setuptools \ 411 liblzma-dev arping netperf iperf 412 413# For Lua support 414sudo apt-get -y install luajit luajit-5.1-dev 415``` 416 417### Install and compile BCC 418 419``` 420git clone https://github.com/iovisor/bcc.git 421mkdir bcc/build; cd bcc/build 422cmake .. 423make 424sudo make install 425cmake -DPYTHON_CMD=python3 .. # build python3 binding 426pushd src/python/ 427make 428sudo make install 429popd 430``` 431 432## CentOS-8.5 - Source 433suppose you're running with root or add sudo first 434 435### Install build dependencies 436``` 437dnf install -y bison cmake ethtool flex git iperf3 libstdc++-devel python3-netaddr python3-pip gcc gcc-c++ make zlib-devel elfutils-libelf-devel 438# dnf install -y luajit luajit-devel ## if use luajit, will report some lua function(which in lua5.3) undefined problem 439dnf install -y clang clang-devel llvm llvm-devel llvm-static ncurses-devel 440dnf -y install netperf 441pip3 install pyroute2 442ln -s /usr/bin/python3 /usr/bin/python 443``` 444### Install and Compile bcc 445``` 446git clone https://github.com/iovisor/bcc.git 447 448mkdir bcc-build 449cd bcc-build/ 450 451## here llvm should always link shared library 452cmake ../bcc -DCMAKE_INSTALL_PREFIX=/usr -DENABLE_LLVM_SHARED=1 453make -j10 454make install 455 456``` 457after install, you may add bcc directory to your $PATH, which you can add to ~/.bashrc 458``` 459bcctools=/usr/share/bcc/tools 460bccexamples=/usr/share/bcc/examples 461export PATH=$bcctools:$bccexamples:$PATH 462``` 463### let path take effect 464``` 465source ~/.bashrc 466``` 467then run 468``` 469hello_world.py 470``` 471Or 472``` 473cd /usr/share/bcc/examples 474./hello_world.py 475./tracing/bitehist.py 476 477cd /usr/share/bcc/tools 478./bitesize 479 480``` 481 482## Fedora - Source 483 484### Install build dependencies 485 486``` 487sudo dnf install -y bison cmake ethtool flex git iperf libstdc++-static \ 488 python-netaddr python-pip gcc gcc-c++ make zlib-devel \ 489 elfutils-libelf-devel python-cachetools 490sudo dnf install -y luajit luajit-devel # for Lua support 491sudo dnf install -y \ 492 http://repo.iovisor.org/yum/extra/mageia/cauldron/x86_64/netperf-2.7.0-1.mga6.x86_64.rpm 493sudo pip install pyroute2 494``` 495 496### Install binary clang 497 498``` 499# FC22 500wget http://llvm.org/releases/3.7.1/clang+llvm-3.7.1-x86_64-fedora22.tar.xz 501sudo tar xf clang+llvm-3.7.1-x86_64-fedora22.tar.xz -C /usr/local --strip 1 502 503# FC23 504wget http://llvm.org/releases/3.9.0/clang+llvm-3.9.0-x86_64-fedora23.tar.xz 505sudo tar xf clang+llvm-3.9.0-x86_64-fedora23.tar.xz -C /usr/local --strip 1 506 507# FC24 and FC25 508sudo dnf install -y clang clang-devel llvm llvm-devel llvm-static ncurses-devel 509``` 510 511### Install and compile BCC 512``` 513git clone https://github.com/iovisor/bcc.git 514mkdir bcc/build; cd bcc/build 515cmake .. 516make 517sudo make install 518``` 519 520## openSUSE - Source 521 522### Install build dependencies 523 524``` 525sudo zypper in bison cmake flex gcc gcc-c++ git libelf-devel libstdc++-devel \ 526 llvm-devel clang-devel pkg-config python-devel python-setuptools python3-devel \ 527 python3-setuptools 528sudo zypper in luajit-devel # for lua support in openSUSE Leap 42.2 or later 529sudo zypper in lua51-luajit-devel # for lua support in openSUSE Tumbleweed 530``` 531 532### Install and compile BCC 533``` 534git clone https://github.com/iovisor/bcc.git 535mkdir bcc/build; cd bcc/build 536cmake -DLUAJIT_INCLUDE_DIR=`pkg-config --variable=includedir luajit` \ # for lua support 537 .. 538make 539sudo make install 540cmake -DPYTHON_CMD=python3 .. # build python3 binding 541pushd src/python/ 542make 543sudo make install 544popd 545``` 546 547## Centos - Source 548 549For Centos 7.6 only 550 551### Install build dependencies 552 553``` 554sudo yum install -y epel-release 555sudo yum update -y 556sudo yum groupinstall -y "Development tools" 557sudo yum install -y elfutils-libelf-devel cmake3 git bison flex ncurses-devel 558sudo yum install -y luajit luajit-devel # for Lua support 559``` 560 561### Install and compile LLVM 562 563You could compile LLVM from source code 564 565``` 566curl -LO https://github.com/llvm/llvm-project/releases/download/llvmorg-10.0.1/llvm-10.0.1.src.tar.xz 567curl -LO https://github.com/llvm/llvm-project/releases/download/llvmorg-10.0.1/clang-10.0.1.src.tar.xz 568tar -xf clang-10.0.1.src.tar.xz 569tar -xf llvm-10.0.1.src.tar.xz 570 571mkdir clang-build 572mkdir llvm-build 573 574cd llvm-build 575cmake3 -G "Unix Makefiles" -DLLVM_TARGETS_TO_BUILD="BPF;X86" \ 576 -DCMAKE_BUILD_TYPE=Release ../llvm-10.0.1.src 577make 578sudo make install 579 580cd ../clang-build 581cmake3 -G "Unix Makefiles" -DLLVM_TARGETS_TO_BUILD="BPF;X86" \ 582 -DCMAKE_BUILD_TYPE=Release ../clang-10.0.1.src 583make 584sudo make install 585cd .. 586``` 587 588or install from centos-release-scl 589 590``` 591yum install -y centos-release-scl 592yum-config-manager --enable rhel-server-rhscl-7-rpms 593yum install -y devtoolset-7 llvm-toolset-10 llvm-toolset-10-llvm-devel llvm-toolset-10-llvm-static llvm-toolset-10-clang-devel 594source scl_source enable devtoolset-7 llvm-toolset-10 595``` 596 597For permanently enable scl environment, please check https://access.redhat.com/solutions/527703. 598 599### Install and compile BCC 600 601``` 602git clone https://github.com/iovisor/bcc.git 603mkdir bcc/build; cd bcc/build 604cmake3 .. 605make 606sudo make install 607``` 608 609## Amazon Linux 1 - Source 610 611Tested on Amazon Linux AMI release 2018.03 (kernel 4.14.47-56.37.amzn1.x86_64) 612 613### Install packages required for building 614``` 615# enable epel to get iperf, luajit, luajit-devel, cmake3 (cmake3 is required to support c++11) 616sudo yum-config-manager --enable epel 617 618sudo yum install -y bison cmake3 ethtool flex git iperf libstdc++-static python-netaddr python-cachetools gcc gcc-c++ make zlib-devel elfutils-libelf-devel 619sudo yum install -y luajit luajit-devel 620sudo yum install -y http://repo.iovisor.org/yum/extra/mageia/cauldron/x86_64/netperf-2.7.0-1.mga6.x86_64.rpm 621sudo pip install pyroute2 622sudo yum install -y ncurses-devel 623``` 624 625### Install clang 3.7.1 pre-built binaries 626``` 627wget http://releases.llvm.org/3.7.1/clang+llvm-3.7.1-x86_64-fedora22.tar.xz 628tar xf clang* 629(cd clang* && sudo cp -R * /usr/local/) 630``` 631 632### Build bcc 633``` 634git clone https://github.com/iovisor/bcc.git 635pushd . 636mkdir bcc/build; cd bcc/build 637cmake3 .. 638time make 639sudo make install 640popd 641``` 642 643### Setup required to run the tools 644``` 645sudo yum -y install kernel-devel-$(uname -r) 646sudo mount -t debugfs debugfs /sys/kernel/debug 647``` 648 649### Test 650``` 651sudo /usr/share/bcc/tools/execsnoop 652``` 653 654## Amazon Linux 2 - Source 655 656``` 657# enable epel to get iperf, luajit, luajit-devel, cmake3 (cmake3 is required to support c++11) 658sudo yum-config-manager --enable epel 659 660sudo yum install -y bison cmake3 ethtool flex git iperf libstdc++-static python-netaddr python-cachetools gcc gcc-c++ make zlib-devel elfutils-libelf-devel 661sudo yum install -y luajit luajit-devel 662sudo yum install -y http://repo.iovisor.org/yum/extra/mageia/cauldron/x86_64/netperf-2.7.0-1.mga6.x86_64.rpm 663sudo pip install pyroute2 664sudo yum install -y ncurses-devel 665``` 666 667### Install clang 668``` 669yum install -y clang llvm llvm-devel llvm-static clang-devel clang-libs 670``` 671 672### Build bcc 673``` 674git clone https://github.com/iovisor/bcc.git 675pushd . 676mkdir bcc/build; cd bcc/build 677cmake3 .. 678time make 679sudo make install 680popd 681``` 682 683### Setup required to run the tools 684``` 685sudo yum -y install kernel-devel-$(uname -r) 686sudo mount -t debugfs debugfs /sys/kernel/debug 687``` 688 689### Test 690``` 691sudo /usr/share/bcc/tools/execsnoop 692``` 693 694## Alpine - Source 695 696### Install packages required for building 697 698``` 699sudo apk add tar git build-base iperf linux-headers llvm10-dev llvm10-static \ 700 clang-dev clang-static cmake python3 flex-dev bison luajit-dev elfutils-dev \ 701 zlib-dev 702``` 703 704### Build bcc 705 706``` 707git clone https://github.com/iovisor/bcc.git 708mkdir bcc/build; cd bcc/build 709# python2 can be substituted here, depending on your environment 710cmake -DPYTHON_CMD=python3 .. 711make && sudo make install 712 713# Optional, but needed if you don't have /usr/bin/python on your system 714ln -s $(which python3) /usr/bin/python 715``` 716 717### Test 718 719``` 720sudo /usr/share/bcc/tools/execsnoop 721``` 722 723## Arch - Source 724 725### Install dependencies 726 727``` 728pacman -S cmake clang llvm flex bison python 729``` 730 731### Build bcc 732 733``` 734git clone https://github.com/iovisor/bcc.git 735pushd . 736mkdir bcc/build 737cd bcc/build 738cmake .. -DPYTHON_CMD=python3 # for python3 support 739make -j$(nproc) 740sudo make install 741cd src/python 742make -j$(nproc) 743sudo make install 744popd 745``` 746 747# Older Instructions 748 749## Build LLVM and Clang development libs 750 751``` 752git clone https://github.com/llvm/llvm-project.git 753mkdir -p llvm-project/llvm/build/install 754cd llvm-project/llvm/build 755cmake -G "Ninja" -DLLVM_TARGETS_TO_BUILD="BPF;X86" \ 756 -DLLVM_ENABLE_PROJECTS="clang" \ 757 -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$PWD/install .. 758ninja && ninja install 759export PATH=$PWD/install/bin:$PATH 760``` 761