about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/libraries/libffi
diff options
context:
space:
mode:
authorAlyssa Ross <hi@alyssa.is>2022-12-06 19:57:55 +0000
committerAlyssa Ross <hi@alyssa.is>2023-02-08 13:48:30 +0000
commitbf3aadfdd39aa197e18bade671fab6726349ffa4 (patch)
tree698567af766ed441d757b57a7b21e68d4a342a2b /nixpkgs/pkgs/development/libraries/libffi
parentf4afc5a01d9539ce09e47494e679c51f80723d07 (diff)
parent99665eb45f58d959d2cb9e49ddb960c79d596f33 (diff)
downloadnixlib-bf3aadfdd39aa197e18bade671fab6726349ffa4.tar
nixlib-bf3aadfdd39aa197e18bade671fab6726349ffa4.tar.gz
nixlib-bf3aadfdd39aa197e18bade671fab6726349ffa4.tar.bz2
nixlib-bf3aadfdd39aa197e18bade671fab6726349ffa4.tar.lz
nixlib-bf3aadfdd39aa197e18bade671fab6726349ffa4.tar.xz
nixlib-bf3aadfdd39aa197e18bade671fab6726349ffa4.tar.zst
nixlib-bf3aadfdd39aa197e18bade671fab6726349ffa4.zip
Merge commit '99665eb45f58d959d2cb9e49ddb960c79d596f33'
Diffstat (limited to 'nixpkgs/pkgs/development/libraries/libffi')
-rw-r--r--nixpkgs/pkgs/development/libraries/libffi/3.3.nix64
-rw-r--r--nixpkgs/pkgs/development/libraries/libffi/default.nix22
-rw-r--r--nixpkgs/pkgs/development/libraries/libffi/libffi-powerpc64.patch23
3 files changed, 102 insertions, 7 deletions
diff --git a/nixpkgs/pkgs/development/libraries/libffi/3.3.nix b/nixpkgs/pkgs/development/libraries/libffi/3.3.nix
new file mode 100644
index 000000000000..a1e2ff8c5888
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/libffi/3.3.nix
@@ -0,0 +1,64 @@
+{ lib, stdenv, fetchurl, fetchpatch
+, autoreconfHook
+
+, doCheck ? true # test suite depends on dejagnu which cannot be used during bootstrapping
+, dejagnu
+}:
+
+stdenv.mkDerivation rec {
+  pname = "libffi";
+  version = "3.3";
+
+  src = fetchurl {
+    url = "https://github.com/libffi/libffi/releases/download/v${version}/${pname}-${version}.tar.gz";
+    hash = "sha256-cvunkicD3fp6Ao1ROsFahcjVTI1n9V+lpIAohdxlIFY=";
+  };
+
+  patches = [];
+
+  outputs = [ "out" "dev" "man" "info" ];
+
+  configureFlags = [
+    "--with-gcc-arch=generic" # no detection of -march= or -mtune=
+    "--enable-pax_emutramp"
+
+    # Causes issues in downstream packages which misuse ffi_closure_alloc
+    # Reenable once these issues are fixed and merged:
+    # https://gitlab.haskell.org/ghc/ghc/-/merge_requests/6155
+    # https://gitlab.gnome.org/GNOME/gobject-introspection/-/merge_requests/283
+    "--disable-exec-static-tramp"
+  ];
+
+  preCheck = ''
+    # The tests use -O0 which is not compatible with -D_FORTIFY_SOURCE.
+    NIX_HARDENING_ENABLE=''${NIX_HARDENING_ENABLE/fortify/}
+  '';
+
+  dontStrip = stdenv.hostPlatform != stdenv.buildPlatform; # Don't run the native `strip' when cross-compiling.
+
+  inherit doCheck;
+
+  checkInputs = [ dejagnu ];
+
+  meta = with lib; {
+    description = "A foreign function call interface library";
+    longDescription = ''
+      The libffi library provides a portable, high level programming
+      interface to various calling conventions.  This allows a
+      programmer to call any function specified by a call interface
+      description at run-time.
+
+      FFI stands for Foreign Function Interface.  A foreign function
+      interface is the popular name for the interface that allows code
+      written in one language to call code written in another
+      language.  The libffi library really only provides the lowest,
+      machine dependent layer of a fully featured foreign function
+      interface.  A layer must exist above libffi that handles type
+      conversions for values passed between the two languages.
+    '';
+    homepage = "http://sourceware.org/libffi/";
+    license = licenses.mit;
+    maintainers = with maintainers; [ armeenm ];
+    platforms = platforms.all;
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/libffi/default.nix b/nixpkgs/pkgs/development/libraries/libffi/default.nix
index 6a22d585fbc8..4c3e00150abf 100644
--- a/nixpkgs/pkgs/development/libraries/libffi/default.nix
+++ b/nixpkgs/pkgs/development/libraries/libffi/default.nix
@@ -1,15 +1,12 @@
 { lib, stdenv, fetchurl, fetchpatch
 , autoreconfHook
 
-, doCheck ? true # test suite depends on dejagnu which cannot be used during bootstrapping
+  # test suite depends on dejagnu which cannot be used during bootstrapping
+  # dejagnu also requires tcl which can't be built statically at the moment
+, doCheck ? !(stdenv.hostPlatform.isStatic)
 , dejagnu
 }:
 
-# Note: this package is used for bootstrapping fetchurl, and thus
-# cannot use fetchpatch! All mutable patches (generated by GitHub or
-# cgit) that are needed here should be included directly in Nixpkgs as
-# files.
-
 stdenv.mkDerivation rec {
   pname = "libffi";
   version = "3.4.2";
@@ -19,10 +16,21 @@ stdenv.mkDerivation rec {
     sha256 = "081nx7wpzds168jbr59m34n6s3lyiq6r8zggvqxvlslsc4hvf3sl";
   };
 
-  patches = [];
+  # Note: this package is used for bootstrapping fetchurl, and thus
+  # cannot use fetchpatch! All mutable patches (generated by GitHub or
+  # cgit) that are needed here should be included directly in Nixpkgs as
+  # files.
+  patches = [
+    ./libffi-powerpc64.patch
+  ];
 
+  strictDeps = true;
   outputs = [ "out" "dev" "man" "info" ];
 
+  enableParallelBuilding = true;
+
+  configurePlatforms = [ "build" "host" ];
+
   configureFlags = [
     "--with-gcc-arch=generic" # no detection of -march= or -mtune=
     "--enable-pax_emutramp"
diff --git a/nixpkgs/pkgs/development/libraries/libffi/libffi-powerpc64.patch b/nixpkgs/pkgs/development/libraries/libffi/libffi-powerpc64.patch
new file mode 100644
index 000000000000..5748ac084982
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/libffi/libffi-powerpc64.patch
@@ -0,0 +1,23 @@
+https://github.com/libffi/libffi/issues/668
+--- a/src/powerpc/linux64.S
++++ b/src/powerpc/linux64.S
+@@ -29,6 +29,8 @@
+ #include <fficonfig.h>
+ #include <ffi.h>
+ 
++	.machine altivec
++
+ #ifdef POWERPC64
+ 	.hidden	ffi_call_LINUX64
+ 	.globl	ffi_call_LINUX64
+--- a/src/powerpc/linux64_closure.S
++++ b/src/powerpc/linux64_closure.S
+@@ -30,6 +30,8 @@
+ 
+ 	.file	"linux64_closure.S"
+ 
++	.machine altivec
++
+ #ifdef POWERPC64
+ 	FFI_HIDDEN (ffi_closure_LINUX64)
+ 	.globl  ffi_closure_LINUX64