Skip to content

Commit c08db1b

Browse files
SzymonKubicaqmonnet
authored andcommitted
Add no_std feature description to the README.
Added a new entry in the ToC for 'build features'. A description of the `no_std` feature was added there. Signed-off-by: SzymonKubica <[email protected]>
1 parent 86d2586 commit c08db1b

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ Rust (user-space) virtual machine for eBPF
1717
* [API](#api)
1818
* [Example uses](#example-uses)
1919
* [Building eBPF programs](#building-ebpf-programs)
20+
* [Build Features](#build-features)
2021
* [Feedback welcome!](#feedback-welcome)
2122
* [Questions / Answers](#questions--answers)
2223
* [Caveats](#caveats)
@@ -555,6 +556,30 @@ program.add(Source::Imm, Arch::X64).set_dst(1).set_imm(0x605).push()
555556
Again, please refer to [the source and related tests](src/insn_builder.rs) to
556557
get more information and examples on how to use it.
557558

559+
## Build features
560+
561+
### `no_std`
562+
563+
The `rbpf` crate has a Cargo feature named "std" that is enabled by default. To
564+
use `rbpf` in `no_std` environments this feature needs to be disabled. To do
565+
this, you need to modify your dependency on `rbpf` in Cargo.toml to disable the
566+
enabled-by-default features.
567+
568+
```toml
569+
[dependencies]
570+
rbpf = { version = "1.0", default-features = false }
571+
```
572+
573+
Note that when using this crate in `no_std` environments, the `jit` module
574+
isn't available. This is because it depends on functions provided by `libc`
575+
(`libc::posix_memalign()`, `libc::mprotect()`) which aren't available on
576+
`no_std`.
577+
578+
The `assembler` module is available, albeit with reduced debugging features. It
579+
depends on the `combine` crate providing parser combinators. Under `no_std`
580+
this crate only provides simple parsers which generate less descriptive error
581+
messages.
582+
558583
## Feedback welcome!
559584

560585
This is the author's first try at writing Rust code. He learned a lot in the

0 commit comments

Comments
 (0)