eunomia-bpf / bpftime

Userspace eBPF runtime for fast Uprobe & Syscall hook & Extensions with LLVM JIT
https://eunomia.dev/bpftime/
MIT License
687 stars 68 forks source link

Make llvm-jit work with bpftrace #286

Closed Officeyutong closed 2 months ago

Officeyutong commented 2 months ago

The root cause of #270 is symbol conflict. Closes #270

There are also two solutions:

Problems if we use version script

I use a version script like

BPFTIME_SYSCALL_SERVER_LLVM {
    local: _ZN4llvm*;  
};

But if we run bpftrace, we will have:

root@mnfe-pve:~/bpftime# bpftime load bpftrace ./example/bpftrace/syscount.bt 
[2024-04-25 20:08:03.119] [info] [syscall_context.hpp:86] manager constructed
[2024-04-25 20:08:03.995] [info] [syscall_server_utils.cpp:24] Initialize syscall server
[2024-04-25 20:08:04][error][3770196] pkey_alloc failed
[2024-04-25 20:08:04][info][3770196] Global shm constructed. shm_open_type 0 for bpftime_maps_shm
[2024-04-25 20:08:04][info][3770196] Global shm initialized
[2024-04-25 20:08:04][info][3770196] Enabling helper groups ufunc, kernel, shm_map by default
[2024-04-25 20:08:04][info][3770196] bpftime-syscall-server started
/lib/modules/6.6.0/build/include/linux/kconfig.h:5:10: fatal error: sorry, this include generates a translation unit too large for Clang to process.
INFO [3770196]: Global shm destructed
[2024-04-25 20:08:04.083] [error] Program exited abnormally, code=1

An include file fails to parse.

Final

Linking LLVM dynamically works well, so we accept this method now. Further investigation of version-script method might be in the future

Reference: