mirror of
https://github.com/micropython/micropython.git
synced 2025-07-20 20:41:10 +02:00
examples/natmod/btree: Fix build on RV32 with Picolibc.
This commit fixes building the "btree" example natmod on RV32 when Picolibc is being used and uses thread-local storage for storing the errno variable. The fix is surprisingly simple: Picolibc allows overriding the function that will provide a pointer to the "errno" variable, and the btree natmod integration code already has all of this machinery set up as part of its library integration. Redirecting Picolibc to the already existing pointer provider function via a compile-time definition is enough to let the module compile and pass QEMU tests. This workaround will work on any Picolibc versions (Arm, RV32, Xtensa, etc.) even if TLS support was not enabled to begin with, and will effectively do nothing if the toolchain used will rely on Newlib to provide standard C library functions. Given that the btree module now builds and passes the relevant natmod tests, said module is now part of the QEMU port's natmod testing procedure, and CI now will build the btree module for RV32 as part to its checks. Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
This commit is contained in:
committed by
Damien George
parent
5f55f8d01a
commit
b63e528076
@@ -36,6 +36,9 @@ ifeq ($(ARCH),xtensa)
|
||||
MPY_EXTERN_SYM_FILE=$(MPY_DIR)/ports/esp8266/boards/eagle.rom.addr.v6.ld
|
||||
endif
|
||||
|
||||
# Use our own errno implementation if Picolibc is used
|
||||
CFLAGS += -D__PICOLIBC_ERRNO_FUNCTION=__errno
|
||||
|
||||
include $(MPY_DIR)/py/dynruntime.mk
|
||||
|
||||
# btree needs gnu99 defined
|
||||
|
@@ -191,12 +191,11 @@ test_full: $(BUILD)/firmware.elf
|
||||
cd $(TOP)/tests && ./run-tests.py $(RUN_TESTS_FULL_ARGS) --via-mpy
|
||||
cd $(TOP)/tests && ./run-tests.py $(RUN_TESTS_FULL_ARGS) --via-mpy --emit native
|
||||
|
||||
# "btree" currently does not build for rv32imc (Picolibc TLS incompatibility).
|
||||
.PHONY: test_natmod
|
||||
test_natmod: $(BUILD)/firmware.elf
|
||||
$(eval DIRNAME=ports/$(notdir $(CURDIR)))
|
||||
cd $(TOP)/tests && \
|
||||
for natmod in deflate framebuf heapq random_basic re; do \
|
||||
for natmod in btree deflate framebuf heapq random_basic re; do \
|
||||
./run-natmodtests.py -p -d execpty:"$(QEMU_SYSTEM) $(QEMU_ARGS) -serial pty -kernel ../$(DIRNAME)/$<" extmod/$$natmod*.py; \
|
||||
done
|
||||
|
||||
|
@@ -563,7 +563,7 @@ function ci_native_mpy_modules_build {
|
||||
else
|
||||
arch=$1
|
||||
fi
|
||||
for natmod in deflate features1 features3 features4 framebuf heapq random re
|
||||
for natmod in btree deflate features1 features3 features4 framebuf heapq random re
|
||||
do
|
||||
make -C examples/natmod/$natmod ARCH=$arch clean
|
||||
make -C examples/natmod/$natmod ARCH=$arch
|
||||
@@ -576,12 +576,6 @@ function ci_native_mpy_modules_build {
|
||||
else
|
||||
make -C examples/natmod/features2 ARCH=$arch
|
||||
fi
|
||||
|
||||
# btree requires thread local storage support on rv32imc.
|
||||
if [ $arch != "rv32imc" ]; then
|
||||
make -C examples/natmod/btree ARCH=$arch clean
|
||||
make -C examples/natmod/btree ARCH=$arch
|
||||
fi
|
||||
}
|
||||
|
||||
function ci_native_mpy_modules_32bit_build {
|
||||
|
Reference in New Issue
Block a user