-
-
Notifications
You must be signed in to change notification settings - Fork 8.3k
py: Change makemoduledefs process so it uses output of qstr extraction. #8714
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
py: Change makemoduledefs process so it uses output of qstr extraction. #8714
Conversation
@@ -34,7 +34,11 @@ | |||
#include "py/runtime.h" | |||
#include "py/builtin.h" | |||
|
|||
#ifndef NO_QSTR | |||
// Only include module definitions when not doing qstr extraction, because the | |||
// qstr extraction stage also generates this module definition header file. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jimmo I'm not sure about this... now that moduledefs.h
is generated after qstr extraction, how do all the module qstr names actually get found?
It works though... I guess because qstr extraction sees all the MP_REGISTER_MODULE()
definitions now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This now works correctly after removing the 3rd arg of MP_REGISTER_MODULE()
.
@@ -421,7 +421,9 @@ typedef struct _mp_rom_obj_t { mp_const_obj_t o; } mp_rom_obj_t; | |||
// param obj_module: mp_obj_module_t instance | |||
// prarm enabled_define: used as `#if (enabled_define) around entry` | |||
|
|||
#ifndef NO_QSTR |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Due to this, qstr extraction will see MP_REGISTER_MODULE
and it's qstr contents.
But does that mean qstrs for module names will always be included, even if that module is disabled?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This has been fixed by removing the 3rd arg of MP_REGISTER_MODULE()
. This macro is now only included if the surrounding #if
/ #endif
wrapper (if it exists) is enabled.
Follow up to #8566. |
To solve my problems above, I think the best way forward is to just remove the 3rd argument to |
6e66288
to
48f1ae1
Compare
I've now pushed a commit which removes the 3rd argument to |
@stinos I need help converting the msvc build instructions. From the first commit here you should be able to see the (not too large) changes to the .mk and .cmake files. That should give a good desrciption of what needs to change. Basically |
Sure, here's a patch:
Passes all tests, doesn't generate modufledefs when source changed but 'QSTR not updated' or when 'Module registrations not updated', only when 'Module registrations updated', so looks ok. |
48f1ae1
to
9ab4075
Compare
Thank you very much! I incorporated that into the first commit. |
9ab4075
to
4dd8328
Compare
This cleans up the parsing of MP_REGISTER_MODULE() and generation of genhdr/moduledefs.h so that it uses the same process as compressed error string messages, using the output of qstr extraction. This makes sure all MP_REGISTER_MODULE()'s that are part of the build are correctly picked up. Previously the extraction would miss some (eg if you had a mod.c file in the board directory for an stm32 board). Build speed is more or less unchanged. Thanks to @stinos for the ports/windows/msvc/genhdr.targets changes. Signed-off-by: Damien George <damien@micropython.org>
It's no longer needed because this macro is now processed after preprocessing the source code via cpp (in the qstr extraction stage), which means unused MP_REGISTER_MODULE's are filtered out by the preprocessor. Signed-off-by: Damien George <damien@micropython.org>
4dd8328
to
efe23ac
Compare
This cleans up the parsing of
MP_REGISTER_MODULE()
and generation ofgenhdr/moduledefs.h
so that it uses the same process as compressed error string messages, using the output of qstr extraction.This makes sure all
MP_REGISTER_MODULE()
's that are part of the build are correctly picked up. Previously the extraction would miss some (eg if you had amod.c
file in the board directory for an stm32 board).Build speed seems more or less unchanged.