summaryrefslogtreecommitdiff
path: root/mpy-cross/main.c
diff options
context:
space:
mode:
authorAlessandro Gatti <a.gatti@frob.it>2025-09-23 22:52:44 +0200
committerAlessandro Gatti <a.gatti@frob.it>2025-10-24 18:30:55 +0200
commit64971f1a65aed54e6a1c041d069c2cb75f2dd64b (patch)
tree34c6b0b7db8424842b81a88681a565dc85768f67 /mpy-cross/main.c
parenta6bc1ccbe51e582d39c6bf7b484c75bfb662357b (diff)
py/persistentcode: Add architecture flags check for RV32 platforms.
This commit introduces the MPY architecture flags checking code specific for the RV32 target, currently checking for the only additional extension that is supported by the runtime: Zba. The warnings inside "mpy-cross" have also been removed since now there is a way to reject incompatible MPY files at runtime. Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
Diffstat (limited to 'mpy-cross/main.c')
-rw-r--r--mpy-cross/main.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/mpy-cross/main.c b/mpy-cross/main.c
index 0415eb664..246390383 100644
--- a/mpy-cross/main.c
+++ b/mpy-cross/main.c
@@ -94,6 +94,12 @@ static int compile_and_save(const char *file, const char *output_file, const cha
mp_compiled_module_t cm;
cm.context = m_new_obj(mp_module_context_t);
cm.arch_flags = 0;
+ #if MICROPY_EMIT_NATIVE && MICROPY_EMIT_RV32
+ if (mp_dynamic_compiler.native_arch == MP_NATIVE_ARCH_RV32IMC && mp_dynamic_compiler.backend_options != NULL) {
+ cm.arch_flags = ((asm_rv32_backend_options_t *)mp_dynamic_compiler.backend_options)->allowed_extensions;
+ }
+ #endif
+
mp_compile_to_raw_code(&parse_tree, source_name, false, &cm);
if ((output_file != NULL && strcmp(output_file, "-") == 0) ||
@@ -138,7 +144,7 @@ static int usage(char **argv) {
"-march=<arch> : set architecture for native emitter;\n"
" x86, x64, armv6, armv6m, armv7m, armv7em, armv7emsp,\n"
" armv7emdp, xtensa, xtensawin, rv32imc, rv64imc, host, debug\n"
- "-march-flags=<flags> : set architecture-specific flags (OUTPUT FILE MAY NOT WORK ON ALL TARGETS!)\n"
+ "-march-flags=<flags> : set architecture-specific flags\n"
" supported flags for rv32imc: zba\n"
"\n"
"Implementation specific options:\n", argv[0]
@@ -382,10 +388,6 @@ MP_NOINLINE int main_(int argc, char **argv) {
mp_printf(&mp_stderr_print, "unrecognised arch flags\n");
exit(1);
}
- mp_printf(&mp_stderr_print,
- "WARNING: Using architecture-specific flags may create a MPY file whose code won't run on all targets!\n"
- " Currently there are no checks in the module file loader for whether the chosen flags used to\n"
- " build the MPY file are compatible with the running target.\n\n");
}
#if MICROPY_EMIT_NATIVE