Skip to content

Fixes for native module support#6014

Closed
gamblor21 wants to merge 1 commit into
adafruit:mainfrom
gamblor21:native_modules_fix
Closed

Fixes for native module support#6014
gamblor21 wants to merge 1 commit into
adafruit:mainfrom
gamblor21:native_modules_fix

Conversation

@gamblor21
Copy link
Copy Markdown
Member

I did a proof of concept to get native modules to work in CP. There were a few changes required to get everything compiling properly and updated after all the MP merges. What is in this PR are basically bug fixes in code paths not ran during normal CP operation. They are not encountered unless the native mpy flag is enabled.

To enable the CIRCUITPY_ENABLE_MPY_NATIVE needs to be set to 1.

This change does not enable native modules in any build.

@tannewt tannewt requested a review from jepler February 11, 2022 17:32
Copy link
Copy Markdown

@jepler jepler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Part of this is right, and part I am unsure about; it seemed to cause problems for me.

Comment thread py/dynruntime.h
Comment on lines -143 to -145
}
mp_parent_t parent = mp_type_get_parent_slot(self_type);
if (parent != native_type) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is probably correct for us. It looks like this is an incorrect trace of my work to split type objects into a main part and an optional part; the 'parent' field ended up in the main part, but this code was to help adapt for the case that it was in the optional part.

Comment thread py/nativeglue.h
#if defined(__GNUC__)
NORETURN // Only certain compilers support no-return attributes in function pointer declarations
#endif
void (*raise_msg_str)(const mp_obj_type_t *exc_type, const char *msg);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does raising exceptions from a native module actually work with these changes? I expect that it doesn't, because there's no way for the string to be entered in the list of translations that is baked into the core, and the translate() function is not available to call from the dynamic runtime either.

@jepler
Copy link
Copy Markdown

jepler commented Feb 16, 2022

Closing in favor of #6028. Thanks again for starting this off!

@jepler jepler closed this Feb 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants