Skip to content
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

Python 3.13 support TODOs #77

Closed
5 tasks done
nitzmahone opened this issue May 20, 2024 · 8 comments · Fixed by #79
Closed
5 tasks done

Python 3.13 support TODOs #77

nitzmahone opened this issue May 20, 2024 · 8 comments · Fixed by #79
Assignees

Comments

@nitzmahone
Copy link
Member

nitzmahone commented May 20, 2024

Now that Python 3.13 has hit beta, we're overdue for at least a pre-release that supports it. Prerequisite to getting that out the door:

  • Implement dynamic GHA matrix to use a single workflow under the primary repo/org for all CI and release activity.
  • Implement support for GHA-hosted Apple Silicon runners.
  • Add aarch64 musllinux wheel builds.
  • Fix broken static linking of libffi in musllinux builds.
  • Determine how to handle test failures from null pointer subtraction errors in newer versions of clang (ignore those tests, disable the error, change the code?)
@nitzmahone nitzmahone self-assigned this May 20, 2024
@arigo
Copy link
Contributor

arigo commented May 21, 2024

re test failures from null pointer subtraction errors: I've got a quick hack that seems to work fine with MSVC, can you check if it does the trick on clang? The hack is:

index 4167bc05..ac6c163e 100644
--- a/src/cffi/recompiler.py
+++ b/src/cffi/recompiler.py
@@ -953,7 +953,7 @@ class Recompiler:
                 if cname is None or fbitsize >= 0:
                     offset = '(size_t)-1'
                 elif named_ptr is not None:
-                    offset = '((char *)&((%s)0)->%s) - (char *)0' % (
+                    offset = '((char *)&((%s)4096)->%s) - (char *)4096' % (
                         named_ptr.name, fldname)
                 else:
                     offset = 'offsetof(%s, %s)' % (tp.get_c_name(''), fldname)

It's not handling null pointers any more... and this expression is only used in a struct initialization, not in real code.

@arigo
Copy link
Contributor

arigo commented May 21, 2024

If it doesn't help, we can try to make the clang warning not be an error for the tests (like it would likely be in production):

index a7ac14d3..8dd93c16 100644
--- a/testing/cffi1/test_verify1.py
+++ b/testing/cffi1/test_verify1.py
@@ -729,7 +729,7 @@ def test_full_enum():
     assert [lib.EE1, lib.EE2, lib.EE3] == [0, 1, 2]

 def test_enum_usage():
-    ffi = FFI()
+    ffi = FFI_warnings_not_error()
     ffi.cdef("enum ee { EE1,EE2 }; typedef struct { enum ee x; } *sp;")
     lib = ffi.verify("enum ee { EE1,EE2 }; typedef struct { enum ee x; } *sp;")
     assert lib.EE2 == 1

@alan-isaac
Copy link

Apologies if this proves irrelevant; I'm just a user. Currently trying to pip install (Python 3.13.0b1, Win 11) fails with errors that include:
_cffi_backend.obj : error LNK2001: unresolved external symbol _PyErr_WriteUnraisableMsg

@nitzmahone
Copy link
Member Author

@alan-isaac Yeah, that's expected from released bits- assuming your box has the right tools already installed, you should be able to do pip install https://github.com/python-cffi/cffi/archive/refs/heads/main.tar.gz to build the extension from the 3.13-compatible bits we're preparing to release.

@nitzmahone
Copy link
Member Author

@arigo yep, changing the named pointer stuff in recompiler as you suggested to use matching non-zero offsets prevents the null pointer subtraction warnings/errors on the newer clang releases.

I've filed that as PR #78, since it's not just a test/build change.

Thanks!

@ofek
Copy link
Contributor

ofek commented May 23, 2024

For the static linking release criteria, this issue I opened a few weeks ago might provide useful context #75

@jaraco
Copy link

jaraco commented Jun 21, 2024

Are there plans to cut a release with these fixes? My system (Python 3.13b2 on macOS ARM) fails to install cffi. Building against github works around the problem.

I see now there is a pre-release, so passing --pre to pip is sufficient.

@sydney-runkle
Copy link

Also curious about this - working on adding support to pydantic for 3.13, and we need the fixes you've added as well :).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants