From e869dae31e19a283ff62f4a49125a9d97aacd499 Mon Sep 17 00:00:00 2001 From: Damien George Date: Fri, 23 May 2025 22:44:19 +1000 Subject: [PATCH] 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 --- mpy-cross/main.c | 9 +++++++++ 1 file changed, 9 insertions(+) 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);