iovisor / iovisor/bcc

Run time issue aganist Raspbian armv7l 32 bit running on pi3b+

Open
#2,402 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
C
Stars
22.7k
Forks
4.1k
Avg merge
10d 4h
Merged PRs (30d)
3

Description

I've successfully build and used bcc against the Ubuntu aarch64 image for raspberry pi 3b+, but when applying similar steps to Raspbian Stretch I hit run time errors with llvm printing `.syntax unified: unknown directive`.

I followed this mailing list thread https://lists.linuxfoundation.org/pipermail/iovisor-dev/2017-October/001118.html with changes applied on their fork here https://github.com/aszyndela/bcc and I was able to apply a patch that successfully built on 32 bit arm. I verified their changes matched my system and architecture, or changed where necessary.

```bash
git clone https://github.com/iovisor/bcc.git
cd bcc
cp ~/bcc-arm32.patch
git checkout e86e0643e1b826583ce78addc471e50d3e60ccd9
git apply bcc-arm32.patch
mkdir build && cd build
cmake .. -DCMAKE_INSTALL_PREFIX=/usr
make
sudo make install
```

Similarly, I build llvm+clang with the following setup.

```bash
git clone https://github.com/llvm/llvm-project.git
git checkout 591c793b48e487382c30e352c0c3b7ae60b45a87
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release -DLLVM_TARGET_ARCH=ARM -DLLVM_TARGETS_TO_BUILD='ARM;BPF' -DLLVM_ENABLE_PROJECTS=clang -DCMAKE_C_COMPILER_TARGET=armv7l-unknown-linux-gnueabihf -DCMAKE_ASM_COMPILER_TARGET=armv7l-linux-gnueabihf -DCMAKE_ASM_FLAGS="--target=armv7l-unknown-linux-gnueabihf" -DCMAKE_C_FLAGS="--target=armv7l-unknown-linux-gnueabihf" -G "Unix Makefiles" ../llvm

make
sudo make install
```

From the llvm docs, `.syntax unified: unknown directive` errors come from not giving clang a target or architecture. https://github.com/llvm/llvm-project/blob/master/llvm/docs/HowToCrossCompileBuiltinsOnArm.rst

I'm wondering if this is an error on bcc's part of not passing the correct targets/triple to clang/llvm, or if this is an architecture issue with the llvm build?

Using the do_sys_open bcc example, my clang invocation is

```bash
clang -cc1 -triple armv7-unknown-linux-gnueabihf -emit-llvm-bc -emit-llvm-uselists -disable-free -disable-llvm-verifier -discard-value-names -main-file-name main.c -mrelocation-model static -mthread-model posix -mdisable-fp-elim -fmath-errno -masm-verbose -mconstructor-aliases -fuse-init-array -target-cpu generic -target-abi aapcs-linux -mfloat-abi hard -fallow-half-arguments-and-returns -dwarf-column-info -debugger-tuning=gdb -coverage-notes-file /home/pi/linux/main.gcno -nostdsysteminc -nobuiltininc -resource-dir lib/clang/8.0.0 -isystem /virtual/lib/clang/include -include ./include/linux/kconfig.h -include /virtual/include/bcc/bpf.h -include /virtual/include/bcc/helpers.h -isystem /virtual/include -I /home/pi/trmo/src/python -D __BPF_TRACING__ -D __ASM_SYSREG_H -D __LINUX_ARM_ARCH__=7 -I /lib/modules/4.19.42-v7+/build/arch/arm/include -I /lib/modules/4.19.42-v7+/build/arch/arm/include/generated/uapi -I /lib/modules/4.19.42-v7+/build/arch/arm/include/generated -I /lib/modules/4.19.42-v7+/build/include -I /lib/modules/4.19.42-v7+/build/./arch/arm/include/uapi -I /lib/modules/4.19.42-v7+/build/arch/arm/include/generated/uapi -I /lib/modules/4.19.42-v7+/build/include/uapi -I /lib/modules/4.19.42-v7+/build/include/generated -I /lib/modules/4.19.42-v7+/build/include/generated/uapi -I ./arch/arm/include -I arch/arm/include/generated/uapi -I arch/arm/include/generated -I include -I ./arch/arm/include/uapi -I arch/arm/include/generated/uapi -I ./include/uapi -I include/generated/uapi -D __KERNEL__ -D __HAVE_BUILTIN_BSWAP16__ -D __HAVE_BUILTIN_BSWAP32__ -D __HAVE_BUILTIN_BSWAP64__ -O2 -Wno-deprecated-declarations -Wno-gnu-variable-sized-type-not-at-end -Wno-pragma-once-outside-header -Wno-address-of-packed-member -Wno-unknown-warning-option -Wno-unused-value -Wno-pointer-sign -fdebug-compilation-dir /home/pi/linux -ferror-limit 19 -fmessage-length 224 -fno-signed-char -fobjc-runtime=gcc -fdiagnostics-show-option -vectorize-loops -vectorize-slp -o main.bc -x c /virtual/main.c -faddrsig
```

Clang is able to successfully parse to assembly, but llvm cannot interpret the assembly due to it not knowing the architecture (either not given or not picked up from the host?).

Guidance on how to trouble shoot this would be appreciated.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.