summaryrefslogtreecommitdiffstatshomepage
path: root/tools/mpy_ld.py
diff options
context:
space:
mode:
authorJim Mussared <jim.mussared@gmail.com>2022-09-17 23:57:12 +1000
committerDamien George <damien@micropython.org>2022-09-19 23:19:55 +1000
commitd94141e1473aebae0d3c63aeaa8397651ad6fa01 (patch)
tree3bd11ca1a9475836a0812d1eac617a11997ebecb /tools/mpy_ld.py
parentb41aaaa8a918a6645ebc6bfa4483bd17286f9263 (diff)
downloadmicropython-d94141e1473aebae0d3c63aeaa8397651ad6fa01.tar.gz
micropython-d94141e1473aebae0d3c63aeaa8397651ad6fa01.zip
py/persistentcode: Introduce .mpy sub-version.
The intent is to allow us to make breaking changes to the native ABI (e.g. changes to dynruntime.h) without needing the bytecode version to increment. With this commit the two bits previously used for the feature flags (but now unused as of .mpy version 6) encode a sub-version. A bytecode-only .mpy file can be loaded as long as MPY_VERSION matches, but a native .mpy (i.e. one with an arch set) must also match MPY_SUB_VERSION. This allows 3 additional updates to the native ABI per bytecode revision. The sub-version is set to 1 because the previous commits that changed the layout of mp_obj_type_t have changed the native ABI. Signed-off-by: Jim Mussared <jim.mussared@gmail.com> Signed-off-by: Damien George <damien@micropython.org>
Diffstat (limited to 'tools/mpy_ld.py')
-rwxr-xr-xtools/mpy_ld.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/tools/mpy_ld.py b/tools/mpy_ld.py
index 09ea90dcd1..05e70709ad 100755
--- a/tools/mpy_ld.py
+++ b/tools/mpy_ld.py
@@ -36,6 +36,7 @@ import makeqstrdata as qstrutil
# MicroPython constants
MPY_VERSION = 6
+MPY_SUB_VERSION = 1
MP_CODE_BYTECODE = 2
MP_CODE_NATIVE_VIPER = 4
MP_NATIVE_ARCH_X86 = 1
@@ -917,7 +918,11 @@ def build_mpy(env, entry_offset, fmpy, native_qstr_vals, native_qstr_objs):
out.open(fmpy)
# MPY: header
- out.write_bytes(bytearray([ord("M"), MPY_VERSION, env.arch.mpy_feature, MP_SMALL_INT_BITS]))
+ out.write_bytes(
+ bytearray(
+ [ord("M"), MPY_VERSION, env.arch.mpy_feature | MPY_SUB_VERSION, MP_SMALL_INT_BITS]
+ )
+ )
# MPY: n_qstr
out.write_uint(1 + len(native_qstr_vals))