| .. | .. |
|---|
| 14 | 14 | Note that LLVM's tool 'llc' must support target 'bpf', list version |
|---|
| 15 | 15 | and supported targets with command: ``llc --version`` |
|---|
| 16 | 16 | |
|---|
| 17 | +Clean and configuration |
|---|
| 18 | +----------------------- |
|---|
| 19 | + |
|---|
| 20 | +It can be needed to clean tools, samples or kernel before trying new arch or |
|---|
| 21 | +after some changes (on demand):: |
|---|
| 22 | + |
|---|
| 23 | + make -C tools clean |
|---|
| 24 | + make -C samples/bpf clean |
|---|
| 25 | + make clean |
|---|
| 26 | + |
|---|
| 27 | +Configure kernel, defconfig for instance:: |
|---|
| 28 | + |
|---|
| 29 | + make defconfig |
|---|
| 30 | + |
|---|
| 17 | 31 | Kernel headers |
|---|
| 18 | 32 | -------------- |
|---|
| 19 | 33 | |
|---|
| .. | .. |
|---|
| 32 | 46 | For building the BPF samples, issue the below command from the kernel |
|---|
| 33 | 47 | top level directory:: |
|---|
| 34 | 48 | |
|---|
| 35 | | - make samples/bpf/ |
|---|
| 36 | | - |
|---|
| 37 | | -Do notice the "/" slash after the directory name. |
|---|
| 49 | + make M=samples/bpf |
|---|
| 38 | 50 | |
|---|
| 39 | 51 | It is also possible to call make from this directory. This will just |
|---|
| 40 | | -hide the the invocation of make as above with the appended "/". |
|---|
| 52 | +hide the invocation of make as above. |
|---|
| 41 | 53 | |
|---|
| 42 | 54 | Manually compiling LLVM with 'bpf' support |
|---|
| 43 | 55 | ------------------------------------------ |
|---|
| .. | .. |
|---|
| 63 | 75 | It is also possible to point make to the newly compiled 'llc' or |
|---|
| 64 | 76 | 'clang' command via redefining LLC or CLANG on the make command line:: |
|---|
| 65 | 77 | |
|---|
| 66 | | - make samples/bpf/ LLC=~/git/llvm/build/bin/llc CLANG=~/git/llvm/build/bin/clang |
|---|
| 78 | + make M=samples/bpf LLC=~/git/llvm/build/bin/llc CLANG=~/git/llvm/build/bin/clang |
|---|
| 67 | 79 | |
|---|
| 68 | 80 | Cross compiling samples |
|---|
| 69 | 81 | ----------------------- |
|---|
| 70 | 82 | In order to cross-compile, say for arm64 targets, export CROSS_COMPILE and ARCH |
|---|
| 71 | | -environment variables before calling make. This will direct make to build |
|---|
| 72 | | -samples for the cross target. |
|---|
| 83 | +environment variables before calling make. But do this before clean, |
|---|
| 84 | +cofiguration and header install steps described above. This will direct make to |
|---|
| 85 | +build samples for the cross target:: |
|---|
| 73 | 86 | |
|---|
| 74 | | -export ARCH=arm64 |
|---|
| 75 | | -export CROSS_COMPILE="aarch64-linux-gnu-" |
|---|
| 76 | | -make samples/bpf/ LLC=~/git/llvm/build/bin/llc CLANG=~/git/llvm/build/bin/clang |
|---|
| 87 | + export ARCH=arm64 |
|---|
| 88 | + export CROSS_COMPILE="aarch64-linux-gnu-" |
|---|
| 89 | + |
|---|
| 90 | +Headers can be also installed on RFS of target board if need to keep them in |
|---|
| 91 | +sync (not necessarily and it creates a local "usr/include" directory also):: |
|---|
| 92 | + |
|---|
| 93 | + make INSTALL_HDR_PATH=~/some_sysroot/usr headers_install |
|---|
| 94 | + |
|---|
| 95 | +Pointing LLC and CLANG is not necessarily if it's installed on HOST and have |
|---|
| 96 | +in its targets appropriate arm64 arch (usually it has several arches). |
|---|
| 97 | +Build samples:: |
|---|
| 98 | + |
|---|
| 99 | + make M=samples/bpf |
|---|
| 100 | + |
|---|
| 101 | +Or build samples with SYSROOT if some header or library is absent in toolchain, |
|---|
| 102 | +say libelf, providing address to file system containing headers and libs, |
|---|
| 103 | +can be RFS of target board:: |
|---|
| 104 | + |
|---|
| 105 | + make M=samples/bpf SYSROOT=~/some_sysroot |
|---|