← index #17547PR #15669
Off-topic · high · value 0.092
QUERY · ISSUE

mpy-cross: Assertion failed when compiling tests/basics/exception_chain.py.

openby agattiopened 2025-06-22updated 2025-12-23
bug

Port, board and/or hardware

Unix on Linux/amd64

MicroPython version

MicroPython v1.26.0-preview.261.gbcc8d4ee1.dirty on 2025-06-22; linux [GCC 15.1.1] version

Reproduction

  1. Build mpy-cross with no special flags (make -C mpy-cross clean && make -C mpy-cross)
  2. Compile tests/basics/exception_chain.py into native code (arch does not matter) with mpy-cross -X emit=native -march=debug tests/basics/exception_chain.py
  3. mpy-cross will crash.

Expected behaviour

Compiling tests/basics/exception_chain.py should not crash mpy-cross.

Observed behaviour

mpy-cross crashes with:

mpy-cross: ../py/emitnative.c:2947: emit_native_raise_varargs: Assertion `n_args == 1' failed.`

Additional Information

If having a multi-arg exception is not supported for native code compilation, then an error message should be printed rather than crashing the compiler.

Code of Conduct

Yes, I agree

CANDIDATE · PULL REQUEST

tests/run-tests.py: Automatically detect native arch and mpy-cross flag.

mergedby dpgeorgeopened 2024-08-16updated 2024-09-04
tests

Summary

Now that some ports support multiple architectures (eg esp32 has both Xtensa and RISC-V CPUs) it's no longer possible to set mpy-cross flags based on the target, eg ./run-tests.py --target esp32. Instead this commit makes it so the -march=xxx argument to mpy-cross is detected automatically via evaluation of sys.implementation._mpy.

Testing

Ran tests on the unix port, PYBv1.0 and Pico, using --via-mpy --emit native. The mpy-cross flags were correctly determined.

Trade-offs and Alternatives

Alternatives would be:

  • specify the MCU in the target, eg --target esp32c3, but that adds more complexity to run-tests.py
  • have a new argument, eg --arch risc-v, but again that adds extra complexity and a burden to the user

IMO automatic detection of the mpy-cross flags makes it easier all round to maintain and run the tests.

Keyboard

j / / n
next pair
k / / p
previous pair
1 / / h
show query pane
2 / / l
show candidate pane
c
copy suggested comment
r
toggle reasoning
g i
go to index
?
show this help
esc
close overlays

press ? or esc to close

copied