nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{ lib, stdenv, fetchurl, fetchpatch
2, autoreconfHook
3
4, doCheck ? true # test suite depends on dejagnu which cannot be used during bootstrapping
5, dejagnu
6}:
7
8# Note: this package is used for bootstrapping fetchurl, and thus
9# cannot use fetchpatch! All mutable patches (generated by GitHub or
10# cgit) that are needed here should be included directly in Nixpkgs as
11# files.
12
13stdenv.mkDerivation rec {
14 pname = "libffi";
15 version = "3.4.2";
16
17 src = fetchurl {
18 url = "https://github.com/libffi/libffi/releases/download/v${version}/${pname}-${version}.tar.gz";
19 sha256 = "081nx7wpzds168jbr59m34n6s3lyiq6r8zggvqxvlslsc4hvf3sl";
20 };
21
22 patches = [];
23
24 outputs = [ "out" "dev" "man" "info" ];
25
26 configureFlags = [
27 "--with-gcc-arch=generic" # no detection of -march= or -mtune=
28 "--enable-pax_emutramp"
29
30 # Causes issues in downstream packages which misuse ffi_closure_alloc
31 # Reenable once these issues are fixed and merged:
32 # https://gitlab.haskell.org/ghc/ghc/-/merge_requests/6155
33 # https://gitlab.gnome.org/GNOME/gobject-introspection/-/merge_requests/283
34 "--disable-exec-static-tramp"
35 ];
36
37 preCheck = ''
38 # The tests use -O0 which is not compatible with -D_FORTIFY_SOURCE.
39 NIX_HARDENING_ENABLE=''${NIX_HARDENING_ENABLE/fortify/}
40 '';
41
42 dontStrip = stdenv.hostPlatform != stdenv.buildPlatform; # Don't run the native `strip' when cross-compiling.
43
44 inherit doCheck;
45
46 checkInputs = [ dejagnu ];
47
48 meta = with lib; {
49 description = "A foreign function call interface library";
50 longDescription = ''
51 The libffi library provides a portable, high level programming
52 interface to various calling conventions. This allows a
53 programmer to call any function specified by a call interface
54 description at run-time.
55
56 FFI stands for Foreign Function Interface. A foreign function
57 interface is the popular name for the interface that allows code
58 written in one language to call code written in another
59 language. The libffi library really only provides the lowest,
60 machine dependent layer of a fully featured foreign function
61 interface. A layer must exist above libffi that handles type
62 conversions for values passed between the two languages.
63 '';
64 homepage = "http://sourceware.org/libffi/";
65 license = licenses.mit;
66 maintainers = with maintainers; [ matthewbauer ];
67 platforms = platforms.all;
68 };
69}