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