Skip to content

Commit 65d9e0f

Browse files
xvk-64cmuellner
andauthored
Update README with a short summary of the --with-cmodel configure option (#1414)
Update README.md to indicate core model option Signed-off-by: Valen <18544814+SpiccyMayonnaise@users.noreply.github.com> Signed-off-by: Christoph Müllner <christoph.muellner@vrull.eu> Co-authored-by: Christoph Müllner <christoph.muellner@vrull.eu>
1 parent 9a28c80 commit 65d9e0f

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ Then, simply run the following command:
5757

5858
You should now be able to use riscv64-unknown-elf-gcc and its cousins.
5959

60+
Note: If you're planning to use an external library that replaces part of newlib (for example `libgloss-htif`), [read the FAQ](#ensuring-code-model-consistency).
61+
6062
### Installation (Linux)
6163

6264
To build the Linux cross-compiler, pick an install path (that is writeable).
@@ -457,3 +459,13 @@ sources is among them. The flag `--enable-host-gcc` does exaclty that:
457459
* Initially a host GCC will be built
458460
* This host GCC is then used to build the cross compiler
459461
* The cross compiler will be built with `-Werror` to identify code issues
462+
463+
### FAQ
464+
#### Ensuring Code Model Consistency
465+
If parts of newlib are going to be replaced with an external library (such as with [libgloss-htif](https://github.com/ucb-bar/libgloss-htif) for Berkeley Host-Target Interface),
466+
you should take care to ensure that both newlib and the external library are built using the same code model. For more information about RISC-V code models,
467+
[read this SiFive blog article](https://www.sifive.com/blog/all-aboard-part-4-risc-v-code-models).
468+
469+
Errors that indicate a code model mismatch include "relocation overflow" or "relocation truncated" errors from the linker being unable to successfully relocate symbols in the executable.
470+
471+
By default, `riscv-gnu-toolchain` builds newlib with `-mcmodel=medlow`. You can use the alternative `medany` code model (as used in libgloss-htif) by passing `--with-cmodel=medany` to the configure script.

0 commit comments

Comments
 (0)