8000 Build embed with C modules isn't working · Issue #15654 · micropython/micropython · GitHub
[go: up one dir, main page]

Skip to content

Build embed with C modules isn't working #15654

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

Open
volodymyr-zvarun-globallogic opened this issue Aug 13, 2024 · 4 comments
Open

Build embed with C modules isn't working #15654

volodymyr-zvarun-globallogic opened this issue Aug 13, 2024 · 4 comments
Labels
enhancement Feature requests, new feature implementations port-embed

Comments

@volodymyr-zvarun-globallogic
Copy link
volodymyr-zvarun-globallogic commented Aug 13, 2024

Port, board and/or hardware

embed

MicroPython version

MicroPython v1.22.2 on 2024-08-13; linux [GCC 4.2.1] version

Reproduction

  1. Modify examples/embedding/main.c by adding import cexample into second example
  2. From examples/embedding run
make -f micropython_embed.mk USER_C_MODULES=<micropython_path>/examples/usercmodule
make
  1. Run embed binary

Expected behaviour

Expected to start without errors

Observed behaviour

Traceback (most recent call last):
  File "<stdin>", in <module>
ImportError: module not found

Additional Information

No, I've provided everything above.

Code of Conduct

Yes, I agree

@jonnor
Copy link
Contributor
jonnor commented Sep 1, 2024

This could be a failure either at build time or a module loading time. Do you see the module being built?
Do a clean and check the build log with make V=1

@Gadgetoid
Copy link
8000
Contributor
Gadgetoid commented Sep 2, 2024

If I try to build using the same instructions I get the error:

../usercmodule/cppexample/examplemodule.h:2:10: fatal error: 'py/runtime.h' file not found
#include "py/runtime.h"

If the USER_C_MODULES path is invalid it will just fail silently. Fwiw I was using:

make -f micropython_embed.mk USER_C_MODULES=../usercmodule

If I mangle CFLAGS and CXXFLAGS until things build, I end up with:

Undefined symbols for architecture arm64:
  "_cppexample_user_cmodule", referenced from:
      _mp_builtin_module_table in objmodule.o
  "_example_package_user_cmodule", referenced from:
      _mp_builtin_module_table in objmodule.o
  "_example_user_cmodule", referenced from:
      _mp_builtin_module_table in objmodule.o

Presumably the included .mk is building the user modules, but they aren't being added to the target.

@Gadgetoid
Copy link
Contributor

With these changes I got C/C++ modules working... in a limited capacity. It's clear the embed port makes no effort to support these whatsoever since presumably you'd handle C functionality in your application code anyway. But since ulab is a (very good) C module, and might conceivably be wanted in MicroPython's embed port... this could make sense.

(ノ◕ヮ◕)ノ*:・゚✧. master...pimoroni:micropython:feature/embed_c_modules

@dpgeorge
Copy link
Member
dpgeorge commented Sep 3, 2024

The embed port is very new and still needs work to add more features. See eg #11430.

@jonnor jonnor added enhancement Feature requests, new feature implementations port-embed and removed bug labels Mar 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Feature requests, new feature implementations port-embed
Projects
None yet
Development

No branches or pull requests

4 participants
0