summaryrefslogtreecommitdiffstatshomepage
path: root/mpy-cross/main.c
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2019-08-23 11:20:50 +1000
committerDamien George <damien.p.george@gmail.com>2019-08-28 12:47:58 +1000
commitaf20c2ead3e9bb397fdf89e316aa78b56f165013 (patch)
tree99cc8c752d6347dc9f0d6dccb6e11384626bd278 /mpy-cross/main.c
parent8e3e05761e1143a2502c7eca07c1b22bac192c84 (diff)
downloadmicropython-af20c2ead3e9bb397fdf89e316aa78b56f165013.tar.gz
micropython-af20c2ead3e9bb397fdf89e316aa78b56f165013.zip
py: Add global default_emit_opt variable to make emit kind persistent.
mp_compile no longer takes an emit_opt argument, rather this setting is now provided by the global default_emit_opt variable. Now, when -X emit=native is passed as a command-line option, the emitter will be set for all compiled modules (included imports), not just the top-level script. In the future there could be a way to also set this variable from a script. Fixes issue #4267.
Diffstat (limited to 'mpy-cross/main.c')
-rw-r--r--mpy-cross/main.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/mpy-cross/main.c b/mpy-cross/main.c
index 6312a77469..afd24ca9f7 100644
--- a/mpy-cross/main.c
+++ b/mpy-cross/main.c
@@ -72,7 +72,7 @@ STATIC int compile_and_save(const char *file, const char *output_file, const cha
#endif
mp_parse_tree_t parse_tree = mp_parse(lex, MP_PARSE_FILE_INPUT);
- mp_raw_code_t *rc = mp_compile_to_raw_code(&parse_tree, source_name, emit_opt, false);
+ mp_raw_code_t *rc = mp_compile_to_raw_code(&parse_tree, source_name, false);
vstr_t vstr;
vstr_init(&vstr, 16);
@@ -196,6 +196,13 @@ MP_NOINLINE int main_(int argc, char **argv) {
mp_obj_list_init(mp_sys_path, 0);
mp_obj_list_init(mp_sys_argv, 0);
+ #if MICROPY_EMIT_NATIVE
+ // Set default emitter options
+ MP_STATE_VM(default_emit_opt) = emit_opt;
+ #else
+ (void)emit_opt;
+ #endif
+
// set default compiler configuration
mp_dynamic_compiler.small_int_bits = 31;
mp_dynamic_compiler.opt_cache_map_lookup_in_bytecode = 0;