diff options
author | Damien George <damien.p.george@gmail.com> | 2019-08-23 11:20:50 +1000 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2019-08-28 12:47:58 +1000 |
commit | af20c2ead3e9bb397fdf89e316aa78b56f165013 (patch) | |
tree | 99cc8c752d6347dc9f0d6dccb6e11384626bd278 /py/runtime.c | |
parent | 8e3e05761e1143a2502c7eca07c1b22bac192c84 (diff) |
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 'py/runtime.c')
-rw-r--r-- | py/runtime.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/py/runtime.c b/py/runtime.c index 9e60eb626..d81321e86 100644 --- a/py/runtime.c +++ b/py/runtime.c @@ -88,6 +88,9 @@ void mp_init(void) { #if MICROPY_ENABLE_COMPILER // optimization disabled by default MP_STATE_VM(mp_optimise_value) = 0; + #if MICROPY_EMIT_NATIVE + MP_STATE_VM(default_emit_opt) = MP_EMIT_OPT_NONE; + #endif #endif // init global module dict @@ -1434,7 +1437,7 @@ mp_obj_t mp_parse_compile_execute(mp_lexer_t *lex, mp_parse_input_kind_t parse_i if (nlr_push(&nlr) == 0) { qstr source_name = lex->source_name; mp_parse_tree_t parse_tree = mp_parse(lex, parse_input_kind); - mp_obj_t module_fun = mp_compile(&parse_tree, source_name, MP_EMIT_OPT_NONE, false); + mp_obj_t module_fun = mp_compile(&parse_tree, source_name, false); mp_obj_t ret; if (MICROPY_PY_BUILTINS_COMPILE && globals == NULL) { |