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