{{ message }}
qemu: Enable support for C++ usermodules.#19110
Open
agatti wants to merge 7 commits intomicropython:masterfrom
Open
qemu: Enable support for C++ usermodules.#19110agatti wants to merge 7 commits intomicropython:masterfrom
agatti wants to merge 7 commits intomicropython:masterfrom
Conversation
|
Code size report: |
Member
dpgeorge
reviewed
Apr 21, 2026
projectgus
reviewed
Apr 22, 2026
This commit expands the linkerscript for i.MX6-series boards to let C++ code link with the interpreter core. The linkerscript now contains all necessary sections for C++ code that uses exceptions to be part of a user module inside the MicroPython image. Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
This commit expands the linkerscript for MPS2-series boards to let C++ code link with the interpreter core. The linkerscript now contains all necessary sections for C++ code that uses exceptions to be part of a user module inside the MicroPython image. Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
This commit expands the linkerscript for MPS3-series boards to let C++ code link with the interpreter core. The linkerscript now contains all necessary sections for C++ code that uses exceptions to be part of a user module inside the MicroPython image. Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
This commit expands the linkerscript for nRF51-series boards to let C++ code link with the interpreter core. The linkerscript now contains all necessary sections for C++ code that uses exceptions to be part of a user module inside the MicroPython image. Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
This commit expands the linkerscript for STM32-series boards to let C++ code link with the interpreter core. The linkerscript now contains all necessary sections for C++ code that uses exceptions to be part of a user module inside the MicroPython image. Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
This commit adds a naive implementation of the "abort" standard C library, that is needed by certain C++ runtimes let code link. Although the Arm toolchain used in the CI image does not need this, newer or different toolchains may actually need this (eg. the Arm EABI toolchain provided by Arch Linux). Given the limited scope of the QEMU port, the function simply spins forever. Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
This commit brings the QEMU port in line with other ports when it comes to making sure the port builds with a user module to be part of the main interpreter. To not impact too much on the build time, only the `MPS2_AN385` board does this as there'd be just too many targets to test, for not much gain. Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
3ad0fc8 to
9a6d32f
Compare
projectgus
approved these changes
Apr 23, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
This PR brings the QEMU port almost in line with the rest of the embedded targets as far as user module linking CI tests go. This is done just for one board (
MPS_AN385) to not impact too much on CI build times.To get there, however, a few issues with C++ code linking had to be sorted out. Unfortunately this only applies to Arm-based boards, since the toolchain provided by the Linux distribution in use by the CI image is incomplete as far as RISC-V goes (as in, only the C part of picolibc is provided).
Maybe when the CI image will be updated to Ubuntu 26.04 things would have improved on that front. On my Arch Linux machine
VIRT_RV32does not need any changes when built using GCC 15 provided by the Arch Linux folks themselves as theriscv64-elf-gccpackage, whilstVIRT_RV64needs some tweaking w.r.t. libgcc support. I'll leave the latter for later.Testing
All boards in question were built with GCC 13 provided by Ubuntu 24.04 adding the example C/C++ user module as part of the build. The same process was then attempted again but with GCC 14 provided by Arch Linux.
The
NETDUINO2board variant was built after manually merging #19099 - unfortunately it wouldn't save it from running out of RAM when built with GCC 14 though.Generative AI
I did not use generative AI tools when creating this PR.
I believe there's an opportunity here to refactor both Arm and RISC-V linkerscripts, since most sections are more or less the same across variants of the same architecture (or with very little differences that can be easily sorted out). Could be an interesting task for a first time contributor though!