Document BPF C program limitations

This commit is contained in:
Michael Vines 2018-11-04 12:30:05 -08:00
parent 1d7722043f
commit ed09b2bdb8
No known key found for this signature in database
GPG Key ID: 33F4FDEC4E0E88BD
1 changed files with 31 additions and 1 deletions

View File

@ -21,7 +21,6 @@ $ sudo apt-get install -y clang-7
```
### macOS
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:
@ -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
```
## 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.