-
Notifications
You must be signed in to change notification settings - Fork 795
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
Cross compile linking issue: cannot locate symbol "_Py_NoneStruct" #1077
Comments
Thanks for posting. This looks like a packaging issue, possibly in As they will have much better knowledge than I for diagnosing the buildozer config, I suggest reporting upstream there before I attempt any debugging here. |
I'll check that out, however I did have a similar issue when compiling the same project in termux I'm not sure if this constitutes a different issue, but it is the same target.
The target is |
After reading through the comments it seems what has fixed it was adding the editI've managed to get it working with the following configuration:
And it ONLY works with the Since this is a linking issue with extension-module would it be related to #1040 ? |
Thanks for the update! Perhaps not #1040 but definitely worth remembering in this area. Let's keep this issue open until we adjust build scripts accordingly. To figure out what's going on here - so it sounds to me like |
(I'm a bit confused because I thought the last python I'd seen where the library had the |
my guess is m is for minimal like in the python3-minimal debian package. |
Aha looks like it's showing if the ABI has pymalloc support. We can check it with sys.abiflags. However, it was definitely removed in 3.8: https://docs.python.org/3/whatsnew/3.8.html#build-and-c-api-changes We could fix build scripts to check this for Python 3.5-3.7. @Progdrasil, you're definitely cross compiling against Python 3.8 when you have this |
Thats really interesting because i am compiling against 3.8. and both the 'm' version and normal versions are available. Ive tried linking against both and only the 'm' version works at runtime. If i link against the normal version i get the I am curious to try compiling against 3.7 now. I'll update you when I have |
After exploring the python-for-android codebase it looks to me like they're generating this
|
Yes but that is used for local compilation, not cross compilation as I am doing. Instead you parse the header files and apply the major and minor version. Is there a way to get the configuration of the cross compiled version to see if it is being compiled as the |
Indeed, you're correct and I was thinking about this this morning too. Actually I think that the cross compilation header parsing is both broken and brittle; I'm thinking about whether we need to try a solution using If I were to kick off a PR to use bindgen to detect cross-compile info, would you be willing to help test it? (And maybe even help finish it off, depending on how much time I can find for it...?) |
Also I succeeded in compiling for 3.7 and running the |
Yeah I would be glad to help out! I can also help contribute to it as well |
Great! I'll try to either get notes or a rough implementation written up tomorrow or soon after. |
So I took a look at the Instead, I started looking at the
Also interesting to note that the name of the data file has that "m" abiflag again, so it might be possible to infer that from the name of the sysconfigdata script. Afraid I've got a lot of other things to focus on at the moment, so I'm not sure I have time to write the implementation right now. However, I'd be very willing to help design and review the implmentation if you want to take this on? If this is potentially nontrivial it could be worth factoring it out into a crate rather than inlining it all into pyo3's |
Sure I can start on this in my free time, might be able to do a bit tomorrow evening |
👍 many thanks, and no rush at all. Any time you're willing to spend helping out is much appreciated, and I'll try to put some time in where I can! Hopefully over time we'll be able to put together a good cross-compiling support for pyo3 😄 Oh, also, while searching documentation this morning I came across another tidbit which would also contribute to the linking issues you're experiencing: #1082. |
I'll keep that in mind with the cross compilation. |
Following the discussion in PyO3#1077 this change allows the compilation script to load the configurations from a _sysconfigdata_ file in the library directory. This file is also provided on target systems in the same directory. At least on Manjaro Linux. Which could remove the need to run a python script at compile time for compiling the the host. I've also addressed the linking need for android in PyO3#1082.
Following the discussion in PyO3#1077 this change allows the compilation script to load the configurations from a _sysconfigdata_ file in the library directory. This file is also provided on target systems in the same directory. At least on Manjaro Linux. Which could remove the need to run a python script at compile time for compiling the the host. I've also addressed the linking need for android in PyO3#1082.
Closed by #1095. (Thanks very much again for your hard work!) |
🐛 Bug Description
I need to cross compile a pyo3 library for android using kivy/buildozer. I've set the
LD_LIBRARY_PATH
,PYO3_CROSS_INCLUDE_DIR
andPYO3_CROSS_LIB_DIR
environment variables and am usingcargo ndk
for the build process and copying the.so
to the site_packages directory.Everything compiles correctly, unfortunately at runtime I get the message
cannot locate symbol "_Py_NoneStruct"
.🌍 Environment
rustc --version
): 1.45.0version = "0.x.y"
withgit = "https://github.com/PyO3/pyo3"
)?: yes💥 Reproducing
I have a repo for the minimal working example. The necessary commands are shown in the README.md
The text was updated successfully, but these errors were encountered: