jit: Enable JIT without "std" feature, but with global alloc
Add a new "alloc" feature that indicates that the crate importing rbpf has an implementation of the GlobalAlloc trait. Memory protection is ignored in the "no_std" environment.
Hi Nate, nice to hear from you :slightly_smiling_face: and thanks a lot for this work!
I haven't looked at the details yet, but have you looked at the work from https://github.com/qmonnet/rbpf/pull/125? The JIT should be available in no_std now (I see the README.md is outdated in that regard). Is your PR adding something else, or are you trying to achieve the same?
Yes I saw #125, but passing the library a pointer of bytes creates problems for my use case. Now I have to track those bytes when I don't want to. I would much rather implement GlobalAlloc. Core library crates that have strong use cases for running without "std" use the "alloc" feature coupled with a use of the core::alloc. Both the crossbeam-queue, and the futures-util implement no-std support thus. Definitely some documentation changes are in order regardless of the change. Thanks for taking the time :pray: !
In this case, the rbpf library cannot ensure that the memory has executable permissions. Developers need to ensure that the memory allocated by GlobalAlloc has executable permissions, which seems unreasonable and dangerous.
I cleaned up the commit which had some whitespace issues.
@Godones
In this case, the rbpf library cannot ensure that the memory has executable permissions. Developers need to ensure that the memory allocated by GlobalAlloc has executable permissions, which seems unreasonable and dangerous.
Only if they turn on the alloc feature, which is almost always in a kernel or/and embedded environment (which can't offer executable protection). This commit is specifically for this scenario.
We also need to adjust the CI runs, where we build with --all-features. Is there a way to make --all-features do all-features-but-actually-not-mutually-exclusive-ones in Rust/Cargo?
@qmonnet
Sorry for the late reply.
We also need to adjust the CI runs, where we build with --all-features. Is there a way to make --all-features do all-features-but-actually-not-mutually-exclusive-ones in Rust/Cargo?
I've broken this down so that the exclusivity is accounted for in the tests. I've added a warning to the README that informs developers that they will have to update the matrix in order to gain test coverage.
I've also added some basic build coverage for the alloc feature.