From 14c1762e07efd1727e5e591d1e336e3f11c72dbb Mon Sep 17 00:00:00 2001 From: Alexandre Iooss Date: Sat, 5 Nov 2022 07:43:56 +0100 Subject: [PATCH 1/2] unicorn: 2.0.0-rc7 -> 2.0.1 --- pkgs/development/libraries/unicorn/default.nix | 7 +++++-- pkgs/development/python-modules/unicorn/default.nix | 3 +-- pkgs/top-level/all-packages.nix | 1 + 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/pkgs/development/libraries/unicorn/default.nix b/pkgs/development/libraries/unicorn/default.nix index e558bbbbb542..1d79baf645cc 100644 --- a/pkgs/development/libraries/unicorn/default.nix +++ b/pkgs/development/libraries/unicorn/default.nix @@ -4,22 +4,25 @@ , pkg-config , cmake , IOKit +, cctools }: stdenv.mkDerivation rec { pname = "unicorn"; - version = "2.0.0-rc7"; + version = "2.0.1"; src = fetchFromGitHub { owner = "unicorn-engine"; repo = pname; rev = version; - hash = "sha256-qlxtFCJBmouPuUEu8RduZM+rbOr52sGjdb8ZRHWmJ/w="; + hash = "sha256-D8kwrHo58zksVjB13VtzoVqmz++FRfJ4zI2CT+YeBVE="; }; nativeBuildInputs = [ cmake pkg-config + ] ++ lib.optionals stdenv.isDarwin [ + cctools ]; buildInputs = lib.optionals stdenv.isDarwin [ diff --git a/pkgs/development/python-modules/unicorn/default.nix b/pkgs/development/python-modules/unicorn/default.nix index 8a568a47c0e4..74780c7e0320 100644 --- a/pkgs/development/python-modules/unicorn/default.nix +++ b/pkgs/development/python-modules/unicorn/default.nix @@ -15,8 +15,7 @@ buildPythonPackage rec { sourceRoot = "source/bindings/python"; prePatch = '' - ln -s ${unicorn-emu}/lib/libunicorn${stdenv.targetPlatform.extensions.sharedLibrary} prebuilt/ - ln -s ${unicorn-emu}/lib/libunicorn.a prebuilt/ + ln -s ${unicorn-emu}/lib/libunicorn.* prebuilt/ ''; # needed on non-x86 linux diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index d08b09c37e3d..a85d6c9a96da 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -12694,6 +12694,7 @@ with pkgs; unicorn = callPackage ../development/libraries/unicorn { inherit (darwin.apple_sdk.frameworks) IOKit; + inherit (darwin) cctools; }; units = callPackage ../tools/misc/units { From 58ca173fd67eb2c70ad399d386e9374f68574672 Mon Sep 17 00:00:00 2001 From: Alexandre Iooss Date: Sat, 5 Nov 2022 09:39:06 +0100 Subject: [PATCH 2/2] unicorn: patch endian.h for aarch64-darwin --- .../development/libraries/unicorn/default.nix | 13 ++++++++++++ .../unicorn/tests_unit_endian_aarch64.patch | 20 +++++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 pkgs/development/libraries/unicorn/tests_unit_endian_aarch64.patch diff --git a/pkgs/development/libraries/unicorn/default.nix b/pkgs/development/libraries/unicorn/default.nix index 1d79baf645cc..88759c67e0ee 100644 --- a/pkgs/development/libraries/unicorn/default.nix +++ b/pkgs/development/libraries/unicorn/default.nix @@ -18,6 +18,12 @@ stdenv.mkDerivation rec { hash = "sha256-D8kwrHo58zksVjB13VtzoVqmz++FRfJ4zI2CT+YeBVE="; }; + patches = [ + # Fix compilation on aarch64-darwin + # See https://github.com/unicorn-engine/unicorn/issues/1730 + ./tests_unit_endian_aarch64.patch + ]; + nativeBuildInputs = [ cmake pkg-config @@ -29,6 +35,13 @@ stdenv.mkDerivation rec { IOKit ]; + cmakeFlags = lib.optionals (stdenv.isDarwin && stdenv.isAarch64) [ + # Some x86 tests are interrupted by signal 10 + "-DCMAKE_CTEST_ARGUMENTS=--exclude-regex;test_x86" + ]; + + doCheck = true; + meta = with lib; { description = "Lightweight multi-platform CPU emulator library"; homepage = "https://www.unicorn-engine.org"; diff --git a/pkgs/development/libraries/unicorn/tests_unit_endian_aarch64.patch b/pkgs/development/libraries/unicorn/tests_unit_endian_aarch64.patch new file mode 100644 index 000000000000..722f4c229e7e --- /dev/null +++ b/pkgs/development/libraries/unicorn/tests_unit_endian_aarch64.patch @@ -0,0 +1,20 @@ +diff --git a/tests/unit/endian.h b/tests/unit/endian.h +index 5bc86308..b455899e 100644 +--- a/tests/unit/endian.h ++++ b/tests/unit/endian.h +@@ -54,6 +54,7 @@ + || defined(_POWER) || defined(__powerpc__) \ + || defined(__ppc__) || defined(__hpux) || defined(__hppa) \ + || defined(_MIPSEB) || defined(_POWER) \ ++ || defined(__ARMEB__) || defined(__AARCH64EB__) \ + || defined(__s390__) + # define BOOST_BIG_ENDIAN + # define BOOST_BYTE_ORDER 4321 +@@ -63,6 +64,7 @@ + || defined(_M_ALPHA) || defined(__amd64) \ + || defined(__amd64__) || defined(_M_AMD64) \ + || defined(__x86_64) || defined(__x86_64__) \ ++ || defined(__ARMEL__) || defined(__AARCH64EL__) \ + || defined(_M_X64) || defined(__bfin__) + + # define BOOST_LITTLE_ENDIAN