Files
micropython/py/persistentcode.h
Alessandro Gatti 5ae928a2b4 py/persistentcode: Detect the target architecture from compiler defines.
This commit replaces the target architecture definition method, from
relying on defines in MicroPython's configuration, to using the host
compiler's environment definitions instead.

Before these changes the target type was inferred from which kind of
native emitter was enabled, since there can be only just one available
at all times and it has to be the correct one otherwise generated code
would crash the target.  However, with the introduction of RV64 there is
now a platform without an emitter, and thus RV64 targets would not be
able to report their platform via "sys.implementation._mpy".  The target
is reported only if the interpreter is configured to load external MPY
code.

Now a series of compile definitions are used to detect the target
platform the firmware image is compiled for, making the target
definition more accurate and much harder to force the interpreter to
report the wrong target architecture due to a misconfiguration.

Whilst this is probably not directly affecting user-facing code, some
infrastructure components like the testing framework and its associated
feature scripts rely on this feature to properly execute test runs.
This is also a concern for situations in which loading external binary
code is needed but all code generation functions have to be disabled.

Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
2025-12-26 10:00:02 +01:00

5.7 KiB