summaryrefslogtreecommitdiff
path: root/py/persistentcode.c
diff options
context:
space:
mode:
authorJim Mussared <jim.mussared@gmail.com>2022-10-20 13:14:25 +1100
committerDamien George <damien@micropython.org>2022-10-25 14:57:04 +1100
commit1ba0e8ff96334af986d2b7d90f6d86af27595d28 (patch)
tree8ea411ccde26b4e45719cb5b6d8f4276b063eafa /py/persistentcode.c
parent5ee1cb27711d3747747db3ecd7b761c2a064addf (diff)
py/persistentcode: Only emit sub-version if generated code has native.
In order for v1.19.1 to load a .mpy, the formerly-feature-flags which are now used for the sub-version must be zero. The sub-version is only used to indicate a native version change, so it should be zero when emitting bytecode-only .mpy files. This work was funded through GitHub Sponsors. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
Diffstat (limited to 'py/persistentcode.c')
-rw-r--r--py/persistentcode.c7
1 files changed, 2 insertions, 5 deletions
diff --git a/py/persistentcode.c b/py/persistentcode.c
index 67c8f327f..5408f756c 100644
--- a/py/persistentcode.c
+++ b/py/persistentcode.c
@@ -591,21 +591,18 @@ void mp_raw_code_save(mp_compiled_module_t *cm, mp_print_t *print) {
// header contains:
// byte 'M'
// byte version
- // byte feature flags
+ // byte native arch (and sub-version if native)
// byte number of bits in a small int
byte header[4] = {
'M',
MPY_VERSION,
- MPY_FEATURE_ENCODE_SUB_VERSION(MPY_SUB_VERSION),
+ cm->has_native ? MPY_FEATURE_ENCODE_SUB_VERSION(MPY_SUB_VERSION) | MPY_FEATURE_ENCODE_ARCH(MPY_FEATURE_ARCH_DYNAMIC) : 0,
#if MICROPY_DYNAMIC_COMPILER
mp_dynamic_compiler.small_int_bits,
#else
MP_SMALL_INT_BITS,
#endif
};
- if (cm->has_native) {
- header[2] |= MPY_FEATURE_ENCODE_ARCH(MPY_FEATURE_ARCH_DYNAMIC);
- }
mp_print_bytes(print, header, sizeof(header));
// Number of entries in constant table.