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