eunomia-bpf / bpftime

Userspace eBPF runtime for Observability, Network & General Extensions Framework
https://eunomia.dev/bpftime/
MIT License
833 stars 78 forks source link

[FEATURE] Make examples depending on libbpf able to build on macos #306

Open hp77-creator opened 5 months ago

hp77-creator commented 5 months ago

Is your feature request related to a problem? Please describe.

Right now, libbpf doesn't compile on macOS because of some headers which are not present. This issue is to add those headers or maybe their alternatives to the project and make bpftime work with libbpf on macOS. **Describe the solution you'd like**

libbpf should work with bpftime on macOS. identify all the headers and syscalls that are being used and replace it with hooks to make them work.

Provide usage examples

After this feature is incoporated, bpftime will be able to work on macOS without LIBBPF flag disabled.

hp77-creator commented 5 months ago

relates to #145

Officeyutong commented 5 months ago

A better title: Make examples depending on libbpf able to build on macos

libbpf itself can't work on macos obviously, but if we may get it able to be built on macos by providing mocked implementation of linux-specified functions that libbpf needs. These mocked implementations could be just empty functions. They don't need to really work, since they'll be overriden by function implementations provided by syscall-server. We provide these functions just to trick the linker.

If we were able to build examples of bpftime on macos, we'll be able to test them on macos with bpftime.

hp77-creator commented 4 months ago

@Officeyutong , I am planning to close this one before frida, working on this atm.

Officeyutong commented 4 months ago

@Officeyutong , I am planning to close this one before frida, working on this atm.

ok

hp77-creator commented 4 months ago

@Officeyutong I observe that 'bpftime_frida_uprobe_attach_tests' fail in '--config RelWithDebInfo' and pass in '--config Debug' when using CMake to build tests and whole 'bpftime'.

Officeyutong commented 4 months ago

@Officeyutong I observe that 'bpftime_frida_uprobe_attach_tests' fail in '--config RelWithDebInfo' and pass in '--config Debug' when using CMake to build tests and whole 'bpftime'.

Let me have a look at compile messages

hp77-creator commented 4 months ago

@Officeyutong Do you mean the output of make commands? I tried running make build-wo-libbpf with slight change in config option and then ran the tests. Do you want to see the output of the same. I am not building tests separately as such. I can try that if you mean that

Officeyutong commented 4 months ago

Referenc

I mean CMake output when building bpftime_frida_uprobe_attach_tests with RelWithDebInfo. It is not expected to fail