mpy-ld.py: preprocess c source before trying to find qstr-s
Currently, mpy-ld.py only directly search for MP_QSTR_* keywords in the source file declared in Makefile, in some situations, it will fail to find MP_QSTR_* keywords and make it fail to build:
- It's too ugly to put all my source code in only one file, so I put some code which uses
MP_QSTR_*in another file and includes it. MP_QSTR_*expression is constructed with a macro.
I think expanding users' includes and macros with something like pcpp may help.
py/dynruntime.h: Implement MP_OBJ_NEW_QSTR.
Because mpy_ld.py doesn't know the target object representation, it emits
instances of MP_OBJ_NEW_QSTR(MP_QSTR_Foo) as const string objects, rather
than qstrs. However this doesn't work for map keys (e.g. for a locals dict)
because the map has all_keys_are_qstrs flag is set (and also auto-complete
requires the map keys to be qstrs).
Instead, emit them as regular qstrs, and make a functioning MP_OBJ_NEW_QSTR
function available (via native_to_obj, also used for e.g. making
integers).
Remove the now-unused code from mpy_ld.py to generate the constant object
table.
As this is a native ABI change, bump the .mpy sub-version to 6.2.
This fixes the issue discovered here: https://github.com/micropython/micropython/pull/11648#discussion_r1289541157
This work was funded through GitHub Sponsors.