examples/natmod/btree: Fix build on RV32 with Picolibc. · sofarocean/micropython@b63e528 · GitHub
Skip to content

Commit b63e528

Browse files
agattidpgeorge
authored andcommitted
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>
1 parent 5f55f8d commit b63e528

3 files changed

Lines changed: 5 additions & 9 deletions

File tree

examples/natmod/btree/Makefile

Lines changed: 3 additions & 0 deletions

ports/qemu/Makefile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,12 +191,11 @@ test_full: $(BUILD)/firmware.elf
191191
cd $(TOP)/tests && ./run-tests.py $(RUN_TESTS_FULL_ARGS) --via-mpy
192192
cd $(TOP)/tests && ./run-tests.py $(RUN_TESTS_FULL_ARGS) --via-mpy --emit native
193193

194-
# "btree" currently does not build for rv32imc (Picolibc TLS incompatibility).
195194
.PHONY: test_natmod
196195
test_natmod: $(BUILD)/firmware.elf
197196
$(eval DIRNAME=ports/$(notdir $(CURDIR)))
198197
cd $(TOP)/tests && \
199-
for natmod in deflate framebuf heapq random_basic re; do \
198+
for natmod in btree deflate framebuf heapq random_basic re; do \
200199
./run-natmodtests.py -p -d execpty:"$(QEMU_SYSTEM) $(QEMU_ARGS) -serial pty -kernel ../$(DIRNAME)/$<" extmod/$$natmod*.py; \
201200
done
202201

tools/ci.sh

Lines changed: 1 addition & 7 deletions

0 commit comments

Comments
 (0)