-
-
Notifications
You must be signed in to change notification settings - Fork 67
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add libbpftime.a archive when BPFTIME_BUILD_STATIC_LIB option is provided #294
Conversation
@Officeyutong @yunwei37 |
Please add an example to demonstrate how to use the static library, such as a small program that dumps loaded programs from the shared memory. The program should use headers from bpftime, and links the static library you built. It's ok if this program was not built using CMake, since the main purpose that we release standalone static library is to make it more convenient for users who doesn't want to use CMake |
Okay @Officeyutong , I am working on that. |
I wrote one program, I only included "bpftime_shm.hpp" but I had to include - Configuring done (0.6s)
CMake Error at CMakeLists.txt:140 (add_custom_command):
Error evaluating generator expression:
$<TARGET_FILE:ubpf>
Target "ubpf" is not an executable or library. To compile the program, I had to write the following compilation command: g++ -o example main.cpp -I/home/fedora/codes/bpftime-hp/runtime/include/ -I/home/fedora/codes/bpftime-hp/vm/vm-core/compat/include -I/home/fedora/codes/bpftime-hp/vm/compat/include/ -L/home/fedora/.bpftime -lbpftime -lboost_system -lrt -lbpf -L/home/fedora/codes/bpftime-hp/build/vm/ubpf-vm/ubpf/lib -lubpf I am trying to add |
Because Besides, your static library should also contain dependencies like ubpf or spdlog. So a user who wants to use bpftime won't need to fetch these libraries by himself |
Yea, I saw, it is being added via ExternalProject, but still unlike |
|
I meant, I am able to add |
Maybe you can try to manually build ubpf in cmake if It's used, and add it to the static library? |
This is how bpftime links ubpf, you may link it in the same way bpftime/vm/ubpf-vm/CMakeLists.txt Line 18 in 307b16f
|
sure, I will see that, meanwhile I tried to run a program with just "spdlog/spdlog.h" header and linking
I am figuring its some error because headers are not added but even after including header with |
Symbols like
|
You also need to link the frida-gum library to Is it possible to call something like |
I will check that, sorry, haven't been able to implement @Officeyutong 's suggestions, I guess we can do that on a target for our function but will let you know for sure in some time, by tomorrow or day after tomorrow EOD. |
Tried adding both lib-ubpf and libfrida-gum and was getting following error:
i don't have much experience with |
Symbol You may use ............
dwarf_global.c.o:
0000000000000000 t dealloc_globals_chain
0000000000000000 t _dwarf_make_global_add_to_chain
U _frida__dwarf_check_string_valid
0000000000000000 T _frida_dwarf_CU_dieoffset_given_die
U _frida_dwarf_dealloc
U _frida__dwarf_error
U _frida__dwarf_error_string
U _frida__dwarf_get_alloc
0000000000000000 T _frida_dwarf_get_cu_die_offset_given_cu_header_offset
0000000000000000 T _frida_dwarf_get_cu_die_offset_given_cu_header_offset_b
...........
crc32.c.o:
0000000000000000 r crc_braid_table
0000000000000000 r crc_table
0000000000000000 t crc_word
0000000000000000 T _frida_crc32
............. |
I checked with |
I tried checking separately. |
A possible reason is that there are object files in the same name among different archives. If you unpack these archives containing object files with the same name, and put the unpacked files into a folder, some object files might be overridden by others. Please check archives you used for duplicated files names, if existed, just do a rename for these object files to avoid overridden |
Seems there are two |
well, I have taken care of two different files with my latest changes, you can comment out 'remove_directory' step and see in objs there are two files created. |
I was using these two:
|
Seems you may use
|
usr/bin/cmake --no-warn-unused-cli -DBPFTIME_ENABLE_LTO=NO -DBPFTIME_LLVM_JIT=NO -DBPFTIME_ENABLE_MPK=YES -DBPFTIME_ENABLE_UNIT_TESTING=YES -DBUILD_ATTACH_IMPL_EXAMPLE=YES -DENABLE_LLVM_SHARED=YES -DWASMEDGE_PLUGIN_WASM_BPF=YES -DBPFTIME_BUILD_STATIC_LIB=YES -DCMAKE_BUILD_TYPE:STRING=Debug -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE -DCMAKE_C_COMPILER:FILEPATH=/usr/bin/clang-15 -DCMAKE_CXX_COMPILER:FILEPATH=/usr/bin/clang++-15 -S/root/bpftime-hp -B/root/bpftime-hp/build -G Ninja Besides, I use |
is the |
|
ok, there is an issue, i might have messed up while trying to write code from my VM to actual repo, checking. |
With your recent suggestion the examples that I have added are working, @Officeyutong |
should we also include, libbpf in the archive, I see that it is also installed but the examples that I have added don't have that requirement. What do you suggest? @Officeyutong @yunwei37 |
I think it would be better to include libbpf |
Besides, it would be better to have a Makefile to build the examples you wrote |
I have added the changes, please review. @Officeyutong @yunwei37 |
Signed-off-by: Himanshu Pandey <24816726+hp77-creator@users.noreply.github.com>
272fb50
to
d07e7a8
Compare
Description
Fixes #232
Changes taken from #271
Type of change
How Has This Been Tested?
BPFTIME_BUILD_STATIC_LIB
Test Configuration:
Checklist