better readme

This commit is contained in:
dzaima 2021-12-10 22:49:04 +02:00
parent 3351f6b303
commit 1b878ccdb6
4 changed files with 42 additions and 16 deletions

View File

@ -1,18 +1,36 @@
Build & run (tl;dr: `make; rlwrap ./BQN`):
# A [BQN](https://github.com/mlochbaum/BQN) implementation in C
1. (optional) Run `./genRuntime path/to/mlochbaum/BQN`; Otherwise, the necessary precompiled bytecode will be retrieved from `remotes/origin/bytecode`
2. If wanted, customize settings in `src/h.h`
3. `make`
- Options: `make o3` (the default), `make debug` (more presets exist for more specific debugging)
- `make CC=gcc` can be used to compile with gcc. Otherwise, `clang` is used.
- Do `make clean` or `make t=[o3|debug|…] clean` beforehand to force recompile
- `make single-(o3|o3g|debug|c)` compile everything as a single translation unit and thus will compile slower, but allows specifying extra compiler arguments with `make f='…' single-…` and allows the compiler to optimize more
4. `./BQN` (or `rlwrap ./BQN` for a better REPL; see `./BQN --help` for more options)
## Running
Run tests with `./BQN mlochbaum/BQN/test/this.bqn` (add `-noerr` for a heapverify build).
1. `make`
- `make CC=gcc` if you don't have clang installed
- `make PIE=""` on ARM CPUs (incl. Android & M1)
- `make clean` if anything goes bad and you want a clean slate
2. `./BQN somefile.bqn` to execute a file, or `rlwrap ./BQN` for a REPL
Time REPL-executed safe prim tests: `./test.bqn mlochbaum/BQN -s prim > SP; time ./BQN<SP>/dev/null`
## Configuration options
Test precompiled expression: `./precompiled.bqn mlochbaum/BQN "$PATH" '2+2'`
- `some-other-bqn-implementation ./genRuntime path/to/mlochbaum/BQN` can be used to avoid pulling precompiled bytecode with git from `remotes/origin/bytecode`.
This creates the dummy file `src/gen/customRuntime` and will disable automated bytecode retrieval whenever it's updated.
`make clean-runtime` (or just `make-clean`) can be used to reset to the default state.
- Different build types:
- `make o3` - `-O3`, the default build
- `make o3n` - `-O3 -march=native`
- `make o3g` - `-g -O3`
- `make debug` - unoptimized debug build
- `make debug1` - debug build without parallel compilation. Useful if everything errors, and you don't want error messages of multiple threads to be written at the same time.
- `make heapverify` - verify that refcounting is done correctly
- `make t=some_type clean` - clean only the specific build
- `make o3n-singeli` - a Singeli build, currently only for CPUs supporting AVX2
- `make t=some_custom_type f='-O3 -DSOME_MACRO=whatever -some_other_cc_flag' c` - custom build
Macros that you may want to define are listed in `src/h.h`.
The `some_custom_type` is used as the key for caching/incremental compilation, so make sure to `make t=some_custom_type clean` if you want to change the flags without changing the `t=` value!!
- `make single-(o3|o3g|debug|c)` - compile everything as a single translation unit. Slower for optimized builds, but may allow some more optimizations
- ... and more; see `makefile`
- Tests can be run with `./BQN path/to/mlochbaum/BQN/test/this.bqn` (add `-noerr` if using `make heapverify`).
- Test precompiled expression: `some-other-bqn-impl ./precompiled.bqn path/to/mlochbaum/BQN "$PATH" '2+2'`
- [Some implementation docs](https://github.com/dzaima/CBQN/tree/master/src#readme)
## License
Any file without an explicit copyright message is copyright (c) 2021 dzaima, GNU GPLv3 - see LICENSE

View File

@ -25,6 +25,8 @@ debugn-singeli:
@${MAKE} singeli=1 t=debugn_si f="-g -DDEBUG -march=native" c
heapverifyn-singeli:
@${MAKE} singeli=1 t=heapverifyn_si f="-g -DDEBUG -DHEAP_VERIFY -march=native" c
rtverifyn-singeli:
@${MAKE} singeli=1 t=rtverifyn_si f="-O3 -DRT_VERIFY -DEEQUAL_NEGZERO -march=native" c

View File

@ -49,6 +49,11 @@
// #define ALL_R0 // use all of r0.bqn for runtime_0
// #define ALL_R1 // use all of r1.bqn for runtime
// #define JIT_START 2 // number of calls for when to start JITting (x86_64-only); default is 2, defined in vm.h
// -1: never JIT
// 0: JIT everything
// >0: JIT after n non-JIT invocations; max ¯1+2⋆16
// #define LOG_GC // log GC stats
// #define RT_PERF // time runtime primitives
// #define RT_VERIFY // compare native and runtime versions of primitives

View File

@ -27,13 +27,14 @@ B wf_identity(B x) {
#define RT_VERIFY_ARGS 1
#endif
B info_c1(B t, B x);
#define CHK(EXP,GOT,W,X) { if (!eequal(EXP,GOT)) { \
print(f); printf(": failed RT_VERIFY\n"); fflush(stdout); \
if (RT_VERIFY_ARGS) { \
if(!q_N(W)){printf("𝕨:"); print(W); putchar('\n'); fflush(stdout); } \
{ printf("𝕩:"); print(X); putchar('\n'); fflush(stdout); } \
{ printf("got:"); print(GOT); putchar('\n'); fflush(stdout); } \
{ printf("exp:"); print(EXP); putchar('\n'); fflush(stdout); } \
if(!q_N(W)){printf("𝕨:"); print(W); printf(" / "); printRaw(info_c1(bi_N, inc(W))); putchar('\n'); fflush(stdout); } \
{ printf("𝕩:"); print(X); printf(" / "); printRaw(info_c1(bi_N, inc(X))); putchar('\n'); fflush(stdout); } \
{ printf("got:"); print(GOT); printf(" / "); printRaw(info_c1(bi_N, inc(GOT))); putchar('\n'); fflush(stdout); } \
{ printf("exp:"); print(EXP); printf(" / "); printRaw(info_c1(bi_N, inc(EXP))); putchar('\n'); fflush(stdout); } \
} \
vm_pstLive(); exit(1); \
}}