-
Notifications
You must be signed in to change notification settings - Fork 49
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
No support for 32-bit? #27
Comments
The structs in the Linux uapi headers all take care to handle alignment correctly, but libbpf itself is not nearly as careful. For example, this struct... struct bpf_xdp_set_link_opts {
size_t sz;
int old_fd;
size_t :0;
}; 16 bytes on 64-bit: https://c.godbolt.org/z/nncsbM6sz Given that lots of software and distros are removing 32-bit support, I think it's fine. In case there are users out there who want 32-bit support, I'm going to rename this issue and leave it open. If you're a 32-bit user who comes across this, please leave a comment! |
I am not a 32 bit user. I just didn't want you to be sideswiped by possible issues for a change you made on my behalf (re: explicit defaults). |
@danobi thoughts on 32-bit support? |
I believe libbpf and libbpf-rs have special cases for 32 bit arches. I probably wouldn't spend a lot of effort on getting 32 bit support in but it'd be nice if it existed. |
Why not careful? Yes, size_t is 64-bit on 64-bit architecture and 32-bit on 32-bit architecture. You need to compile libbpf for your target bitness and everything works. So libbpf definitely is designed to work on 32-bit architectures, you can't just compile it once and run the same binary artifacts on both 32-bit and 64-bit architectures. |
Sure, that's fine in C, but having structs change size or alignment depending on word size (or even worse, compiler flags!) makes FFI much harder in all languages, not just Rust. |
Rust doesn't support conditional compilation depending on target architecture bitness? Or it's just too much trouble to generate two sets of bindings (one for 64-bit and another for 32-bit targets) and pick one of the at the compilation time? But I never done that, so not suggesting anything. On libbpf side we can't change things (and it's generally impossible to guarantee exact same struct memory layout with stuff like pointers in OPTS structs anyways, unless we unionize everything w/ u64 to ensure 64-bit alignment and appropriate padding). So not sure what else can be done here :( |
Basically. In an early version, I had the build script generate the bindings on users' machines at compile-time. Later, I switched to pregenerating the bindings, because it makes the library compile much faster. We have three options:
Agree, and I honestly prefer just dropping 32-bit support unless/until someone needs it. On that note, I'll mention it again – if you're reading this and you're a 32-bit user, please let me know! |
Yep, sounds good. But if we needed 32-bit badly, option #2 is the way to go, IMO.
|
Note: as of the current release, you can now generate bindings during build time using a new feature flag called
In the future, I plan on pre-generating bindings for Rust's tier 1 platforms. |
The new explicit padding is explicit for 64bit data alignment. Can eBPF used on 32bit machines?
I'm sorry, but I do not have a 32 bit machine to verify whether this is an issue or not.
The text was updated successfully, but these errors were encountered: