-
-
Notifications
You must be signed in to change notification settings - Fork 844
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
Set PLATFORM_TRIPLET, include platform in so names, only load compatible so files #2299
Conversation
…ble so files For reasons that are a bit beyond me, `--host` and `PLATFORM_TRIPLET` seem to be independent, in particular we've had an empty `PLATFORM_TRIPLET`. This is unfortunate because `PLATFORM_TRIPLET` is used to generate the SOABI config variable which in turn is used to decide whether a .so file is a good match for loading. We'd like for linux Pythons not to try to import emscripten .so files (it raises `ImportError: some_file.so: invalid ELF header`). Similarly, we'd like to avoid attempting to load linux .so files in wasm. These platform tags are our friends. Anyways, this PR sets `PLATFORM_TRIPLET` and ensures that .so files built by pywasmcross are tagged with our SOABI tag. I moved the .so file renaming from pywasmcross to buildpkg just before running the post script. That is a better place to put it in case the package wants to look at the .so file after linking it. It might be surprised that we moved it. I also improved the error message if we try to `loadWebAssemblyModule` something that is actually say a Linux .so file and updated get_dynlibs to filter out .so files that have an incompatible abi tag.
In the future, we might consider updating the platform tag to include the emscripten version cf emscripten-core/emscripten#15917. |
Hmm, maybe we should add the wasm32-emscripten platform triplet to https://github.com/python/cpython/blob/4aea656d62860e78cd8384f2de375f0d4f1db579/configure.ac#L836 in CPython. WDYT @tiran? Also, is it expected that
Right, but ideally they shouldn't be in the wasm artifact anyway. And I think they aren't since we try to pre-load all .so at init? |
I tried that, for some reason it didn't set
Not sure, as far as I can tell
Yeah they aren't unless we mess up. We can leave off the double checking code if you prefer. There are wheels out there that have a bunch of .so files for several different architectures. Using something like that in the browser wouldn't be ideal for download size reasons, but if you are using it with node it would be perfectly reasonable. |
if $CPP $CPPFLAGS conftest.c >conftest.out 2>/dev/null; then
PLATFORM_TRIPLET=`grep -v '^#' conftest.out | grep -v '^ *$' | tr -d ' presumably the issue is that |
To make it more confusing a typical platform triplet has two, three, or even four elements. The three element syntax can either specify
I recommend that you use
AFAIK that check is only used for multiarch and has no affect on cross compilation. |
Ooops, I misunderstood the issue! I should have read the initial comment... If I understand you correctly you want to have |
Well it will solve our problem in a year when we switch to Python 3.11 =) For now, I think manually setting |
@tiran another question. Currently every patch version bump in emscripten is considered to be an ABI break: |
Thanks! This PR LGTM as a temporary solution. |
For reasons that are a bit beyond me,
--host
andPLATFORM_TRIPLET
seem to be independent, in particular we've had an empty
PLATFORM_TRIPLET
. This is unfortunate becausePLATFORM_TRIPLET
is used to generate the SOABI config variable which in turn is used
to decide whether a .so file is a good match for loading. We'd like
for linux Pythons not to try to import emscripten .so files (it
raises
ImportError: some_file.so: invalid ELF header
). Similarly,we'd like to avoid attempting to load linux .so files in wasm. These
platform tags are our friends.
Anyways, this PR sets
PLATFORM_TRIPLET
and ensures that .so filesbuilt by pywasmcross are tagged with our SOABI tag.
I moved the .so file renaming from pywasmcross to buildpkg just
before running the post script. That is a better place to put it in
case the package wants to look at the .so file after linking it. It
might be surprised that we moved it.
I also improved the error message if we try to
loadWebAssemblyModule
something that is actually say a Linux .so file and updated get_dynlibs
to filter out .so files that have an incompatible abi tag.