Slim down of libbcc.so
- Dominant language
- C
- Stars
- 22.7k
- Forks
- 4.1k
- Avg merge
- 10d 4h
- Merged PRs (30d)
- 3
Description
For Android usecases, I am trying to bring down the size of libbcc.so. Currently it is at 55MB.
Disassembling it, I see that there are a lot of references to the x86 LLVM backend. This seems a bit useless since libbcc.so will only generate eBPF backend machine code.
I built my own LLVM without the x86 backend and only with eBPF backend.
```
git clone http://llvm.org/git/llvm.git
cd llvm/tools; git clone http://llvm.org/git/clang.git
cd ..; mkdir -p build/install; cd build
cmake -G "Unix Makefiles" -DLLVM_TARGETS_TO_BUILD="BPF" \
-DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$PWD/install ..
make
make install
export PATH=$PWD/install/bin:$PATH
```
Now I am trying to build BCC with that LLVM I just built using:
```
rm -rf build && mkdir -p build && cd build
cmake .. -DCMAKE_INSTALL_PREFIX=./install -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++
make -j90 VERBOSE=1
make install
```
However that fails because the "clang" I built obviously doesn't have the x86 backend so it cannot compile BCC itself.
What I want is to use the "stock" LLVM in my distro to build BCC, however for libbcc itself, I want it to link to the LLVM I just built with only the eBPF backend. So basically that looks like:
```
LLVM libs with only BPF backend BCC Sources
| /
| /
Compile/Link with LLVM compiler with x86 backend (in distro)
|
Compact libbcc.so with only eBPF backend
```
This seems a bit tricky, but I'll keep poking. Any thoughts / guidance on how I can accomplish this @drzaeus77 @yonghong-song ?
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the shown CMake configuration and LLVM_TARGETS_TO_BUILD=BPF setup; the issue names no source files or tests. Trace how BCC is compiled with the distro compiler and how libbcc.so links LLVM, then verify that BCC still builds while libbcc.so uses only the BPF backend and is smaller.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, c, cmake, cpp
- Domain
- build-system, mobile-dev, performance
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100