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

pythonPackages.cffi: include patch to fix clang error #322614

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
diff --git a/src/cffi/recompiler.py b/src/cffi/recompiler.py
index 4167bc05..ac6c163e 100644
--- a/src/cffi/recompiler.py
+++ b/src/cffi/recompiler.py
@@ -953,7 +953,7 @@ def _struct_ctx(self, tp, cname, approxname, named_ptr=None):
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)
Login with GitHub

This file was deleted.

38 changes: 16 additions & 22 deletions pkgs/development/python-modules/cffi/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
pycparser,
pythonAtLeast,
}:

if isPyPy then
null
else
Expand All @@ -25,27 +24,22 @@ else
hash = "sha256-vLPvQ+WGZbvaL7GYaY/K5ndkg+DEpjGqVkeAbCXgLMA=";
};

patches =
[
#
# Trusts the libffi library inside of nixpkgs on Apple devices.
#
# Based on some analysis I did:
#
# https://groups.google.com/g/python-cffi/c/xU0Usa8dvhk
#
# I believe that libffi already contains the code from Apple's fork that is
# deemed safe to trust in cffi.
#
./darwin-use-libffi-closures.diff
]
++ lib.optionals (stdenv.cc.isClang && lib.versionAtLeast (lib.getVersion stdenv.cc) "13") [
# -Wnull-pointer-subtraction is enabled with -Wextra. Suppress it to allow the following tests
# to run and pass when cffi is built with newer versions of clang:
# - testing/cffi1/test_verify1.py::test_enum_usage
# - testing/cffi1/test_verify1.py::test_named_pointer_as_argument
./clang-pointer-substraction-warning.diff
];
patches = [
#
# Trusts the libffi library inside of nixpkgs on Apple devices.
#
# Based on some analysis I did:
#
# https://groups.google.com/g/python-cffi/c/xU0Usa8dvhk
#
# I believe that libffi already contains the code from Apple's fork that is
# deemed safe to trust in cffi.
#
./darwin-use-libffi-closures.diff
# https://github.com/python-cffi/cffi/commit/39bdab23615a83c1001ed822f974ae52020201ba
# Needed on newer Clang versions.
./avoid-null-pointer-subtraction-error.diff
];

postPatch = lib.optionalString stdenv.isDarwin ''
# Remove setup.py impurities
Expand Down