8000 py/persistentcode.h: Split the native and bytecode ABI version. by jimmo · Pull Request #9303 · micropython/micropython · GitHub
[go: up one dir, main page]

Skip to content

py/persistentcode.h: Split the native and bytecode ABI version. #9303

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed

Conversation

jimmo
Copy link
Member
@jimmo jimmo commented Sep 14, 2022

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, there's now a supported bytecode .mpy version and a native .mpy version.

When generating an .mpy, if it has any native code then it gets the native version, otherwise the bytecode version.

When loading an .mpy, if it has native code, then it must match the native version exactly. If it has only bytecode, then any version between the current bytecode version and native version will be loaded.

e.g. MicroPython v1.19 will load any future bytecode .mpy until we increment MPY_VERSION_BYTECODE, but will only load v6 native mpy files.

The main driver for this is #8813 however I think this is generally useful. There have been cases where we haven't added a useful feature to dynruntime.h because we don't want to break bytecode compatibility.

This work was funded through GitHub Sponsors.

@jimmo
Copy link
Member Author
jimmo commented Sep 14, 2022

One note on this is that sys.implementation._mpy will return the native version. I think this makes sense -- if someone is troubleshooting a build failure then the ideal case is they get a mpy-cross that generates exactly what their build is expecting.

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, there's now a supported bytecode .mpy version and a
native .mpy version.

When generating an .mpy, if it has any native code then it gets the native
version, otherwise the bytecode version.

When loading an .mpy, if it has native code, then it must match the native
version exactly. If it has only bytecode, then any version between the
current bytecode version and native version will be loaded.

e.g. MicroPython v1.19 will load any future bytecode .mpy until we
increment `MPY_VERSION_BYTECODE`, but will only load v6 native mpy files.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
@jimmo
Copy link
Member Author
jimmo commented Sep 17, 2022

See #9341 for a different approach with a "sub version".

@dpgeorge
Copy link
Member

Closed in favour of #9341.

@dpgeorge dpgeorge closed this Sep 19, 2022
tannewt added a commit to tannewt/circuitpython that referenced this pull request Jun 10, 2024
picow: turn off CIRCUITPY_USB_HOST and CIRCUITPY_PICODVI
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0