Code Monkey home page Code Monkey logo

Comments (9)

chenhengqi avatar chenhengqi commented on July 25, 2024

I have some small questions.

  1. Do we need a symbolic link in src/bpf to vmlinux.h ?
  2. How does rust example link against libbpf ?

from libbpf-bootstrap.

anakryiko avatar anakryiko commented on July 25, 2024

I like it overall, but I'd leave libbpf submodule at the top level still. It is not used from Rust, but I feel like it's a good idea to keep it at top level, because some other language might come up that will build libbpf from sources (e.g., Go + Cgo). In in general, it's libbpf-bootstrap, so libbpf should be more apparent ;)

As for Makefile in each example subdir. It's trivial to have a simlar makefile that will delegate to upper level Makefile for build and clean up, so yeah, cd examples/c/bootstrap && make should just work, IMO.

from libbpf-bootstrap.

danobi avatar danobi commented on July 25, 2024

@chenhengqi

Do we need a symbolic link in src/bpf to vmlinux.h ?

Yeah, we could. Or we could just have src/bpf/xdp.bpf.c do #include "../../../vmlinux/vmlinux.h".

How does rust example link against libbpf ?

libbpf-rs depends on libbpf-sys. libbpf-sys vendors (submodule) a specific libbpf version and builds/links to it at compile time: https://github.com/alexforster/libbpf-sys/blob/3c1c21e45c7ea74f6d0fe18ab99624d9ee14fc96/build.rs#L13-L23

from libbpf-bootstrap.

danobi avatar danobi commented on July 25, 2024

I like it overall, but I'd leave libbpf submodule at the top level still. It is not used from Rust, but I feel like it's a good idea to keep it at top level, because some other language might come up that will build libbpf from sources (e.g., Go + Cgo). In in general, it's libbpf-bootstrap, so libbpf should be more apparent ;)

Sure, sounds good.

As for Makefile in each example subdir. It's trivial to have a simlar makefile that will delegate to upper level Makefile for build and clean up, so yeah, cd examples/c/bootstrap && make should just work, IMO.

Ok, I'll look into that

I'll update the issue summary

from libbpf-bootstrap.

waruqi avatar waruqi commented on July 25, 2024

The kprobe program depends on vmlinux.h. If I want to compile the android bpf program, do I need to generate the vmlinux.h file corresponding to the android system? How should I organize them?

└── vmlinux
    ├── vmlinux_508.h
    └── vmlinux.h -> vmlinux_508.h

Or this?

- vmlinux
  - linux/vmlinux.h
  - android/vmlinux.h

from libbpf-bootstrap.

danobi avatar danobi commented on July 25, 2024

Maybe:

└── vmlinux
    ├── Makefile
    ├── xmake.lua
    ├── vmlinux_508.h
    └── vmlinux.h -> vmlinux_508.h

and then depending on if you use make or xmake vmlinux_508.h and vmlinux.h is overwritten. And if you retarget xmake to android, vmlinux* gets overwritten

from libbpf-bootstrap.

anakryiko avatar anakryiko commented on July 25, 2024

No overwriting, please. See iovisor/bcc#3265 for how we dealt with it in libbpf-tools. Do you think that's feasible here as well?

from libbpf-bootstrap.

waruqi avatar waruqi commented on July 25, 2024

So only one vmlinux.h can support linux and android at same time? It seems great!

from libbpf-bootstrap.

anakryiko avatar anakryiko commented on July 25, 2024

Yes, it's just a source of type definitions, nothing more. And you don't even need vmlinux.h, you can define all the types on your own and mark them with __attribute__((preserve_access_index)) to make them CO-RE-compatible.

from libbpf-bootstrap.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.