-
-
Notifications
You must be signed in to change notification settings - Fork 30.4k
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
gh-120154: Fix Emscripten/WASI pattern in case statement for LDSHARED #120173
Conversation
Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the |
Suggested reviewers: @hoodmane @ryanking13 |
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.
I'm suspicious that the code guarded by this branch is wrong in either case with Emscripten. -shared
just prints a warning that it noticed you asked for a shared lib but it's ignoring you and making a static lib anyways.
LDSHARED
needs to be -sSIDE_MODULE=2
potentially with some symbol export control. By default only symbols with __attribute__((visibility("default")))
appear in the symbol table, or -Wl,--whole-archive
is available if you want to force absolutely everything to get exported, and there are several other options in between that are more complicated. I think PyAPI_FUNC
and PyAPI_DATA
put __attribute__((visibility("default")))
there, so defining LDSHARED
to be -sSIDE_MODULE=2
would probably be the right thing to do.
There's also a question whether you really would want to dynamically link the Python interpreter. Is the only case where this is used if we're building libpython3.xx.so
?
In any case, I don't think this PR makes things much different from Emscripten's point of view, so I'll approve.
Just for completeness, when running LDSHARED= /path/to/emsdk/upstream/emscripten/emcc $(PY_LDFLAGS)
BLDSHARED= /path/to/emsdk/upstream/emscripten/emcc $(PY_CORE_LDFLAGS) However if you run configure directly, e.g., in my case I am using the Emscripten toolchain via Bazel, LDSHARED= ld $(PY_LDFLAGS)
BLDSHARED= ld $(PY_CORE_LDFLAGS) This crashes during building the interpreter statically since the modules LDSHARED= /path/to/emsdk/upstream/emscripten/emcc -shared $(PY_LDFLAGS)
BLDSHARED= /path/to/emsdk/upstream/emscripten/emcc -shared $(PY_CORE_LDFLAGS) @hoodmane I suspect that the |
I tried to do this once and entirely failed. Good to hear that other people are getting it to work. |
I agree that
I will share it as a public repo once it is done. I think one of the challenges with Pyodide at the moment is that it is difficult to integrate into larger projects due to the multiple layers of Makefiles and flags/variables etc. |
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.
LGTM.
@@ -3417,7 +3417,7 @@ then | |||
LDCXXSHARED='$(CXX) -dynamiclib -F . -framework $(PYTHONFRAMEWORK)' | |||
BLDSHARED="$LDSHARED" | |||
;; | |||
Emscripten|WASI) | |||
Emscripten*|WASI*) |
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.
Oh right, we already have the same line above: Emscripten*|WASI*)
(line 3505).
…SHARED (pythonGH-120173) Fix Emscripten/WASI pattern in case statement for LDSHARED (cherry picked from commit 47816f4) Co-authored-by: Michael Allwright <[email protected]>
GH-120199 is a backport of this pull request to the 3.13 branch. |
Sorry, @allsey87 and @vstinner, I could not cleanly backport this to
|
@allsey87: The 3.13 backport #120199 fails because it says that [email protected] didn't sign the CLA. Would you mind to sign the CLA with this email address as well? |
@vstinner should I do that via https://www.python.org/psf/contrib/contrib-form/ or is there a better/more integrated way? |
It's the right form. |
…DSHARED (GH-120173) (#120199) Fix Emscripten/WASI pattern in case statement for LDSHARED (cherry picked from commit 47816f4) Co-authored-by: Michael Allwright <[email protected]>
GH-120204 is a backport of this pull request to the 3.12 branch. |
…SHARED (python#120173) Fix Emscripten/WASI pattern in case statement for LDSHARED (cherry picked from commit 47816f4)
…DSHARED… (#120204) gh-120154: Fix Emscripten/WASI pattern in case statement for LDSHARED (#120173) Fix Emscripten/WASI pattern in case statement for LDSHARED (cherry picked from commit 47816f4) Co-authored-by: Michael Allwright <[email protected]>
We have very limited resources so almost all of our build-system effort is aimed at making it easier for Python packages to support Pyodide. We would appreciate any help cleaning this up. On the other hand, I wouldn't love to see us use bazel since I wouldn't want to limit potential contributors to bazel experts. |
…SHARED (python#120173) Fix Emscripten/WASI pattern in case statement for LDSHARED
…SHARED (python#120173) Fix Emscripten/WASI pattern in case statement for LDSHARED
This fixes a small typo in the configure script for CPython with respect to WASI and Emscripten builds. The issue has only surfaced now since usually such builds are done via
emconfigure
which sets theLDSHARED
environment variable, bypassing the logic in the autoconf script.This should not impact Pyodide builds unless the
configure
is executed directly without theemconfigure
wrapper. Resolves #120154.