Skip to content

Emscripten trampolines not quite right since #106219 #121700

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

Closed
hoodmane opened this issue Jul 13, 2024 · 0 comments
Closed

Emscripten trampolines not quite right since #106219 #121700

hoodmane opened this issue Jul 13, 2024 · 0 comments
Labels
type-bug An unexpected behavior, bug, or error

Comments

@hoodmane
Copy link
Contributor

hoodmane commented Jul 13, 2024

Bug report

Bug description:

pycore_emscripten_trampoline.h defines _PyCFunctionWithKeywords_TrampolineCall as a macro but pycore_object.h tries to declare it. This leads to a compile error. The fix is to delete the declaration from pycore_object.h.

--- a/Include/internal/pycore_object.h
+++ b/Include/internal/pycore_object.h
@@ -733,13 +733,7 @@ PyAPI_FUNC(PyObject*) _PyObject_GetState(PyObject *);
  * Third party code unintentionally rely on problematic fpcasts. The call
  * trampoline mitigates common occurrences of bad fpcasts on Emscripten.
  */
-#if defined(__EMSCRIPTEN__) && defined(PY_CALL_TRAMPOLINE)
-#define _PyCFunction_TrampolineCall(meth, self, args) \
-    _PyCFunctionWithKeywords_TrampolineCall( \
-        (*(PyCFunctionWithKeywords)(void(*)(void))(meth)), (self), (args), NULL)
-extern PyObject* _PyCFunctionWithKeywords_TrampolineCall(
-    PyCFunctionWithKeywords meth, PyObject *, PyObject *, PyObject *);
-#else
+#if !(defined(__EMSCRIPTEN__) && defined(PY_CALL_TRAMPOLINE))
 #define _PyCFunction_TrampolineCall(meth, self, args) \
     (meth)((self), (args))
 #define _PyCFunctionWithKeywords_TrampolineCall(meth, self, args, kw) \

CPython versions tested on:

CPython main branch

Operating systems tested on:

Other

Linked PRs

@hoodmane hoodmane added the type-bug An unexpected behavior, bug, or error label Jul 13, 2024
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Jul 14, 2024
encukou pushed a commit that referenced this issue Jul 14, 2024
@encukou encukou closed this as completed Jul 14, 2024
hoodmane added a commit to hoodmane/cpython that referenced this issue May 13, 2025
I found out about the `if` instruction which lets us have slightly
shorter code here.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

2 participants