4.2. Nuclei C Runtime Library for Nuclei Toolchain
4.2.1. Usage
For Nuclei GNU Toolchain(riscv64-unknown-elf-gcc) case:
riscv64-unknown-elf-gcc --specs=libncrt_small.specs -Wl,--start-group -lheapops_basic -lfileops_uart -Wl,--end-group
For Nuclei LLVM Toolchain(riscv64-unknown-elf-clang) case:
You can’t use –specs=libncrt_small.specs option, since it is not supported, gcc can also use following command just like clang.
riscv64-unknown-elf-clang -nodefaultlibs -isystem=/include/libncrt -Wl,--start-group -lncrt_small -lheapops_basic -lfileops_uart -Wl,--end-group
For details about libncrt, ‘heapops’ and ‘fileops’ variant, please read following documentation.
When using this method, please don’t link with -lm/lc_nano/-lgcc/-lc library to avoid potential linker error and code size increasement.
4.2.2. Varieties
4.2.2.1. Libncrt Library choice
GCC Specs |
Library |
|
---|---|---|
Fast |
libncrt_fast.specs |
libncrt_fast.a |
Balanced |
libncrt_balanced.specs |
libncrt_balanced.a |
Small |
libncrt_small.specs |
libncrt_small.a |
Nano |
libncrt_nano.specs |
libncrt_nano.a |
Pico |
libncrt_pico.specs |
libncrt_pico.a |
If you are not using gcc, and want to use libncrt small variant, you can pass -isystem=/include/libncrt during compile phase, and -nodefaultlibs -lncrt_small during link phase.
4.2.2.2. Optimization
Optimization |
|
---|---|
Fast |
Favor speed at the expense of size |
Balanced |
Balanced |
Small |
Favor size at the expense of speed |
Nano |
Favor size at the expense of speed |
Pico |
Favor size at the expense of speed |
4.2.2.3. Formatted I/O
int |
long |
long long |
float |
double |
wide character |
input character class |
Width and precision specification |
stdout formatting buffer (byte) |
|
---|---|---|---|---|---|---|---|---|---|
Fast |
yes |
yes |
yes |
yes |
yes |
yes |
yes |
yes |
64 |
Balanced |
yes |
yes |
yes |
yes |
yes |
yes |
yes |
yes |
64 |
Small |
yes |
yes |
yes |
yes |
yes |
yes |
yes |
yes |
64 |
Nano |
yes |
yes |
yes |
no |
no |
no |
no |
yes |
64 |
Pico |
yes |
no |
no |
no |
no |
no |
no |
no |
32 |
4.2.2.4. Algorithm
Scaled-integer Algorithm |
|
---|---|
Fast |
Algorithms use C-language floating-point arithmetic. |
Balanced |
Algorithms use C-language floating-point arithmetic. |
Small |
Algorithms use C-language floating-point arithmetic. |
Nano |
Algorithms use C-language floating-point arithmetic. |
Pico |
IEEE single-precision functions use scaled integer arithmetic if there is a scaled-integer implementation of the function. |
4.2.2.5. Extra fileops and heapops libraries used together with libncrt
Library Type |
Library description |
|
---|---|---|
fileops |
Using a UART for I/O, need to implement at least metal_tty_putc and metal_tty_getc |
|
fileops |
Using semihosting for I/O |
|
fileops |
Using SEGGER RTT for I/O |
|
-lheapops_basic |
heapops |
Using a basic heap implementation |
-lheapops_realtime |
heapops |
Using a real-time heap implementation |
-lheapops_minimal |
heapops |
Using a minimal heap implementation |