@@ -103,7 +103,7 @@ QB_OPT_APPEND:append:qemuriscv32 = " -bios none"
# since medlow can only access addresses below 0x80000000 and RAM
# starts at 0x80000000 on RISC-V 64
# Keep RISC-V 32 using -mcmodel=medlow (symbols lie between -2GB:2GB)
-CFLAGS:append:qemuriscv64 = " -mcmodel=medany"
+TARGET_CFLAGS:append:qemuriscv64 = " -mcmodel=medany"
## Emulate image.bbclass
@@ -28,6 +28,14 @@ B = "${WORKDIR}/build"
## disable stdlib
TARGET_CC_ARCH:append = " -nostdlib"
+# Both the C library and the application should share the same mcmodel.
+# Use the medium-any code model for the RISC-V 64 bit implementation,
+# since medlow can only access addresses below 0x80000000 and RAM
+# starts at 0x80000000 on RISC-V 64
+# Keep RISC-V 32 using -mcmodel=medlow (symbols lie between -2GB:2GB)
+TARGET_CFLAGS:append:qemuriscv64 = " -mcmodel=medany"
+
+
EXTRA_OECONF = " \
--build=${BUILD_SYS} \
--target=${TARGET_SYS} \
It was previously discovered that mcmodel=medany should be used for RISCV64, however this was only being set for the applications themselves, but not for newlib, this meant that we ended up with C library that used a code model and an application that used another one which is not something we want. Pass mcmodel=medany when building newlib for RISCV64 as well. Also, s/CFLAGS/TARGET_CFLAGS to standarize across recipes, the variable expansion provides no functional difference at this point. Signed-off-by: Alejandro Enedino Hernandez Samaniego <alejandro@enedino.org> --- meta/classes-recipe/baremetal-image.bbclass | 2 +- meta/recipes-core/newlib/newlib.inc | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-)