summaryrefslogtreecommitdiff
path: root/py/persistentcode.c
diff options
context:
space:
mode:
Diffstat (limited to 'py/persistentcode.c')
-rw-r--r--py/persistentcode.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/py/persistentcode.c b/py/persistentcode.c
index 6ec0717f9..7d71cfd98 100644
--- a/py/persistentcode.c
+++ b/py/persistentcode.c
@@ -471,7 +471,7 @@ void mp_raw_code_load(mp_reader_t *reader, mp_compiled_module_t *cm) {
|| header[3] > MP_SMALL_INT_BITS) {
mp_raise_ValueError(MP_ERROR_TEXT("incompatible .mpy file"));
}
- if (MPY_FEATURE_DECODE_ARCH(header[2]) != MP_NATIVE_ARCH_NONE) {
+ if (arch != MP_NATIVE_ARCH_NONE) {
if (!MPY_FEATURE_ARCH_TEST(arch)) {
if (MPY_FEATURE_ARCH_TEST(MP_NATIVE_ARCH_NONE)) {
// On supported ports this can be resolved by enabling feature, eg
@@ -483,6 +483,12 @@ void mp_raw_code_load(mp_reader_t *reader, mp_compiled_module_t *cm) {
}
}
+ size_t arch_flags = 0;
+ if (MPY_FEATURE_ARCH_FLAGS_TEST(header[2])) {
+ (void)arch_flags;
+ mp_raise_ValueError(MP_ERROR_TEXT("incompatible .mpy file"));
+ }
+
size_t n_qstr = read_uint(reader);
size_t n_obj = read_uint(reader);
mp_module_context_alloc_tables(cm->context, n_qstr, n_obj);
@@ -504,6 +510,7 @@ void mp_raw_code_load(mp_reader_t *reader, mp_compiled_module_t *cm) {
cm->has_native = MPY_FEATURE_DECODE_ARCH(header[2]) != MP_NATIVE_ARCH_NONE;
cm->n_qstr = n_qstr;
cm->n_obj = n_obj;
+ cm->arch_flags = arch_flags;
#endif
// Deregister exception handler and close the reader.
@@ -672,7 +679,7 @@ void mp_raw_code_save(mp_compiled_module_t *cm, mp_print_t *print) {
byte header[4] = {
'M',
MPY_VERSION,
- cm->has_native ? MPY_FEATURE_ENCODE_SUB_VERSION(MPY_SUB_VERSION) | MPY_FEATURE_ENCODE_ARCH(MPY_FEATURE_ARCH_DYNAMIC) : 0,
+ (cm->arch_flags != 0 ? MPY_FEATURE_ARCH_FLAGS : 0) | (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
@@ -681,6 +688,10 @@ void mp_raw_code_save(mp_compiled_module_t *cm, mp_print_t *print) {
};
mp_print_bytes(print, header, sizeof(header));
+ if (cm->arch_flags) {
+ mp_print_uint(print, cm->arch_flags);
+ }
+
// Number of entries in constant table.
mp_print_uint(print, cm->n_qstr);
mp_print_uint(print, cm->n_obj);