1{
2 lib,
3 stdenv,
4 fetchurl,
5
6 # test suite depends on dejagnu which cannot be used during bootstrapping
7 # dejagnu also requires tcl which can't be built statically at the moment
8 doCheck ? !(stdenv.hostPlatform.isStatic),
9 dejagnu,
10 nix-update-script,
11 testers,
12}:
13
14stdenv.mkDerivation (finalAttrs: {
15 pname = "libffi";
16 version = "3.5.1";
17
18 src = fetchurl {
19 url =
20 with finalAttrs;
21 "https://github.com/libffi/libffi/releases/download/v${version}/${pname}-${version}.tar.gz";
22 hash = "sha256-+Z62imfH1Uhmt3Bq8kXoe6Bg1BmgYkdLRW07yNSr29E=";
23 };
24
25 # Note: this package is used for bootstrapping fetchurl, and thus
26 # cannot use fetchpatch! All mutable patches (generated by GitHub or
27 # cgit) that are needed here should be included directly in Nixpkgs as
28 # files.
29 patches = [
30 ];
31
32 strictDeps = true;
33 outputs = [
34 "out"
35 "dev"
36 "man"
37 "info"
38 ];
39
40 enableParallelBuilding = true;
41
42 configurePlatforms = [
43 "build"
44 "host"
45 ];
46
47 configureFlags = [
48 "--with-gcc-arch=generic" # no detection of -march= or -mtune=
49 "--enable-pax_emutramp"
50 ];
51
52 preCheck = ''
53 # The tests use -O0 which is not compatible with -D_FORTIFY_SOURCE.
54 NIX_HARDENING_ENABLE=''${NIX_HARDENING_ENABLE/fortify3/}
55 NIX_HARDENING_ENABLE=''${NIX_HARDENING_ENABLE/fortify/}
56 '';
57
58 dontStrip = stdenv.hostPlatform != stdenv.buildPlatform; # Don't run the native `strip' when cross-compiling.
59
60 inherit doCheck;
61
62 nativeCheckInputs = [ dejagnu ];
63
64 passthru = {
65 updateScript = nix-update-script { };
66 tests = {
67 pkg-config = testers.hasPkgConfigModules {
68 package = finalAttrs.finalPackage;
69 };
70 };
71 };
72
73 meta = with lib; {
74 description = "Foreign function call interface library";
75 longDescription = ''
76 The libffi library provides a portable, high level programming
77 interface to various calling conventions. This allows a
78 programmer to call any function specified by a call interface
79 description at run-time.
80
81 FFI stands for Foreign Function Interface. A foreign function
82 interface is the popular name for the interface that allows code
83 written in one language to call code written in another
84 language. The libffi library really only provides the lowest,
85 machine dependent layer of a fully featured foreign function
86 interface. A layer must exist above libffi that handles type
87 conversions for values passed between the two languages.
88 '';
89 homepage = "http://sourceware.org/libffi/";
90 license = licenses.mit;
91 maintainers = with maintainers; [ matthewbauer ];
92 platforms = platforms.all;
93 pkgConfigModules = [ "libffi" ];
94 };
95})