diff options
| author | Damien George <damien@micropython.org> | 2025-05-23 22:44:19 +1000 |
|---|---|---|
| committer | Damien George <damien@micropython.org> | 2025-06-04 12:06:12 +1000 |
| commit | e869dae31e19a283ff62f4a49125a9d97aacd499 (patch) | |
| tree | 8c189c9efbe15910ae36154aeaabd8bd953069d0 | |
| parent | 820485358d1f2a53a5fb019e571b13729ccb1158 (diff) | |
mpy-cross/main: Exit with error if arch not specified with emit=native.
Currently, mpy-cross will crash if called as:
mpy-cross -X emit=native foo.py
because it tries to use the native emitter with no target architecture set.
Fix that by checking that an architecture is set when `-X emit=native` or
`-X emit=viper` is used.
Signed-off-by: Damien George <damien@micropython.org>
| -rw-r--r-- | mpy-cross/main.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/mpy-cross/main.c b/mpy-cross/main.c index 7ab95149c..5375f38ac 100644 --- a/mpy-cross/main.c +++ b/mpy-cross/main.c @@ -350,6 +350,15 @@ MP_NOINLINE int main_(int argc, char **argv) { } } + #if MICROPY_EMIT_NATIVE + if ((MP_STATE_VM(default_emit_opt) == MP_EMIT_OPT_NATIVE_PYTHON + || MP_STATE_VM(default_emit_opt) == MP_EMIT_OPT_VIPER) + && mp_dynamic_compiler.native_arch == MP_NATIVE_ARCH_NONE) { + mp_printf(&mp_stderr_print, "arch not specified\n"); + exit(1); + } + #endif + if (input_file == NULL) { mp_printf(&mp_stderr_print, "no input file\n"); exit(1); |
