Skip to content

cffi: disable tests on aarch64-darwin#152166

Merged
vcunat merged 1 commit intoNixOS:masterfrom
bobrik:ivan/aarch64-darwin-py-cffi-no-tests
Dec 26, 2021
Merged

cffi: disable tests on aarch64-darwin#152166
vcunat merged 1 commit intoNixOS:masterfrom
bobrik:ivan/aarch64-darwin-py-cffi-no-tests

Conversation

@bobrik
Copy link
Contributor

@bobrik bobrik commented Dec 26, 2021

Motivation for this change

The tests were disabled on Darwin prior to 54b5495, which probably fixed them for x86_64-darwin, but not for aarch64-darwin.

This was merged in #126411, which landed in the most recent staging-next: #148396. The evaluation after that merge doesn't look too good:

image

Spot checking a few packages points at cffi, so I think it's fair to merge this straight into the master branch.

cc @vcunat, @jonringer, @toonn

Things done
  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandbox = true set in nix.conf? (See Nix manual)
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 22.05 Release Notes (or backporting 21.11 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
    • (Release notes changes) Ran nixos/doc/manual/md-to-db.sh to update generated release notes
  • Fits CONTRIBUTING.md.

@github-actions github-actions bot added the 6.topic: python Python is a high-level, general-purpose programming language. label Dec 26, 2021
@bobrik bobrik mentioned this pull request Dec 26, 2021
13 tasks
The tests were disabled on Darwin prior to 54b5495, which probably
fixed them for x86_64-darwin, but not for aarch64-darwin.
@bobrik bobrik force-pushed the ivan/aarch64-darwin-py-cffi-no-tests branch from 8d9216c to 18fcfb9 Compare December 26, 2021 01:22
doCheck = !stdenv.hostPlatform.isMusl;
# Lots of tests fail on aarch64-darwin due to "Cannot allocate write+execute memory":
# * https://cffi.readthedocs.io/en/latest/using.html#callbacks
doCheck = !stdenv.hostPlatform.isMusl && !(stdenv.isDarwin && stdenv.isAarch64);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did some debugging on this issue. It's caused by nixpkg's build of libffi not being code-signed for this. I was able to work around this by linking cffi against libffi from the apple sdk. Here's my patch, it might be helpful (only tested on aarch64). emilytrau@56c8491

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(sorry i found this in august, been slacking on the pull request 😅)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@angustrau I'm still getting errors with your patch:

_________________________ ERROR collecting c/test_c.py _________________________
ImportError while importing test module '/private/tmp/nix-build-python3.9-cffi-1.15.0.drv-0/cffi-1.15.0/c/test_c.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
/nix/store/wcmyw7rvadybk5cdcdd7xghwbzk2p44w-python3-3.9.9/lib/python3.9/importlib/__init__.py:127: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
c/test_c.py:8: in <module>
    from _cffi_backend import *
E   ImportError: dlopen(/nix/store/5f5a625s680i4hll3jd0sx11m3qyvs3i-python3.9-cffi-1.15.0/lib/python3.9/site-packages/_cffi_backend.cpython-39-darwin.so, 0x0002): symbol not found in flat namespace '_ffi_prep_closure'
_____________ ERROR collecting testing/cffi1/test_parse_c_type.py ______________
testing/cffi1/test_parse_c_type.py:74: in <module>
    def fetch_constant_five(p):
cffi/api.py:396: in callback_decorator_wrap
    return self._backend.callback(cdecl, python_callable,
E   MemoryError: Cannot allocate write+execute memory for ffi.callback(). You might be running on a system that prevents this. For more information, see https://cffi.readthedocs.io/en/latest/using.html#callbacks

The first error does not happen without your patch.

Copy link
Member

@vcunat vcunat Dec 26, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I merged for now, as the tests weren't ran anyway until this staging-next iteration and this platform is idle on Hydra. If you find a better fix, it can be added later.

@ofborg ofborg bot added 6.topic: darwin Running or building packages on Darwin 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux. labels Dec 26, 2021
@vcunat
Copy link
Member

vcunat commented Dec 26, 2021

@ofborg build python39Packages.cffi

@vcunat vcunat merged commit fd0df9f into NixOS:master Dec 26, 2021
@bobrik bobrik deleted the ivan/aarch64-darwin-py-cffi-no-tests branch December 26, 2021 18:37
@bobrik
Copy link
Contributor Author

bobrik commented Dec 28, 2021

Looks good, most of the packages after the staging-next merge recovered:

image

@toonn
Copy link
Contributor

toonn commented Dec 28, 2021

@bobrik, thank you for taking care of my mess!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

6.topic: darwin Running or building packages on Darwin 6.topic: python Python is a high-level, general-purpose programming language. 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants