Document BPF C program limitations
This commit is contained in:
parent
1d7722043f
commit
ed09b2bdb8
|
@ -21,7 +21,6 @@ $ sudo apt-get install -y clang-7
|
||||||
```
|
```
|
||||||
|
|
||||||
### macOS
|
### macOS
|
||||||
|
|
||||||
The following depends on Homebrew, instructions on how to install Homebrew are at https://brew.sh
|
The following depends on Homebrew, instructions on how to install Homebrew are at https://brew.sh
|
||||||
|
|
||||||
Once Homebrew is installed, ensure the latest llvm is installed:
|
Once Homebrew is installed, ensure the latest llvm is installed:
|
||||||
|
@ -31,3 +30,34 @@ $ brew install llvm # <- should output “Warning: llvm 7.0.0 is already instal
|
||||||
$ brew --prefix llvm # <- should output “/usr/local/opt/llvm”
|
$ brew --prefix llvm # <- should output “/usr/local/opt/llvm”
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Development
|
||||||
|
|
||||||
|
### Quick start
|
||||||
|
To get started create a `makefile` containing:
|
||||||
|
```make
|
||||||
|
include path/to/bpf.mk
|
||||||
|
```
|
||||||
|
and `src/program.c` containing:
|
||||||
|
```c
|
||||||
|
#include <solana_sdk.h>
|
||||||
|
|
||||||
|
bool entrypoint(const uint8_t *input) {
|
||||||
|
SolKeyedAccounts ka[1];
|
||||||
|
uint8_t *data;
|
||||||
|
uint64_t data_len;
|
||||||
|
|
||||||
|
if (!sol_deserialize(buf, ka, SOL_ARRAY_SIZE(ka), NULL, &data, &data_len)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
print_params(1, ka, data, data_len);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Then run `make` to build `out/program.o`.
|
||||||
|
Run `make help` for more details.
|
||||||
|
|
||||||
|
### Limitations
|
||||||
|
* Programs must be fully contained within a single .c file
|
||||||
|
* No libc is available but `solana_sdk.h` provides a minimal set of
|
||||||
|
primitives.
|
||||||
|
|
Loading…
Reference in New Issue