-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathREADME.backup
75 lines (54 loc) · 2.75 KB
/
README.backup
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# Building DPDK with clang LTO
This branch contains the changes required for building DPDK by using clang Link Time Optimization (LTO).
We added a new toolchain rule: `x86_64-native-linux-clanglto` that requires [LLD](https://lld.llvm.org/).
You have to first install LLVM 10.0 via [Install](https://bitbucket.org/nslab/llvm-project/src/master/llvm-clang.sh). And then make LLD the default linker:
```bash
cd /usr/bin
sudo cp ld.lld ./ld
```
**Click will be compiled without this step, but DPDK apps (e.g., testpmd) might not work.**
To build DPDK with LTO, run:
```bash
make install T=x86_64-native-linux-clanglto
```
## Changes
The changes are as follows:
- Define required variables in `mk/toolchain/clanglto/rte.vars.mk`.
```Makefile
CC = $(CROSS)clang
KERNELCC = $(CROSS)gcc
CPP = $(CROSS)cpp
# for now, we don't use as but nasm.
# AS = $(CROSS)as
AS = nasm
AR = $(CROSS)llvm-ar
LD = $(CROSS)ld.lld
OBJCOPY = $(CROSS)llvm-objcopy
OBJDUMP = $(CROSS)llvm-objdump
STRIP = $(CROSS)llvm-strip
READELF = $(CROSS)llvm-readelf
GCOV = $(CROSS)llvm-cov
RANLIB = $(CROSS)llvm-ranlib
LLC = $(CROSS)llc
TOOLCHAIN_CFLAGS = -flto
TOOLCHAIN_LDFLAGS = -flto -fuse-ld=lld -plugin-opt=save-temps
export CC AS AR LD OBJCOPY OBJDUMP STRIP READELF RANLIB LLC
```
- `KERNELCC` in `mk/toolchain/clanglto/rte.vars.mk` can also use `clang`, but to avoid errors, the following flags should be changed:
```
kernel/linux/igb_uio/Makefile -> Remove -Werror from MODULE_CLAGS += -Winline ...
kernel/linux/kni/Makefile -> Remove -Werror from MODULE_CLAGS += -Wall ...
```
- Change `ld` to `ld.lld` in `mk/internal/rte.compile-pre.mk`.
```Makefile
PMDINFO_LD = $(CROSS)ld.lld $(LDFLAGS) -r -o $@.o $@.pmd.o $@
```
- Added `buildtools/check-experimental-syms-lto.sh`. It uses `llvm-nm` rather than 'objdump' since the latter requires object files, while LTO generates LLVM IR bitcode.
- Change the input of `buildtools/pmdinfogen/pmdinfogen.c`. This program will dynamically find some info about the PMD drivers and generates `*.o.pmd.c` by parsing `*.o` which are object files.
LTO generate IR bitcode that cannot be parsed by `pmdinfogen`. Therefore, we have to use [llc](https://llvm.org/docs/CommandGuide/llc.html) to create the object files required by this app.
The following command creates an object file from an IR bit code. Check `mk/internal/rte.compile-pre.mk` for more details.
```bash
llc -filetype=obj $@ -o $@.o
```
Note: To use LTO, `binutils` and `llvm` might need to be built by following the guidelines in [llvm-tutorial](https://bitbucket.org/nslab/llvm-tutorial/src/master/) repo. You should use a stable `binutils` (e.g., 2.32).
Make sure that `/usr/lib/bfd-plugins` exists. Otherwise, make one and copy `libLTO.*` and `LLVMgold.so` in it.