1{ stdenv, fetchFromRepoOrCz, perl, texinfo }:
2
3assert (stdenv.isGlibc);
4
5with stdenv.lib;
6
7let
8 date = "20160525";
9 version = "0.9.27pre-${date}";
10 rev = "1ca685f887310b5cbdc415cdfc3a578dbc8d82d8";
11 sha256 = "149s847jkg2zdmk09h0cp0q69m8kxxci441zyw8b08fy9b87ayd8";
12in
13
14stdenv.mkDerivation rec {
15 name = "tcc-${version}";
16
17 src = fetchFromRepoOrCz {
18 repo = "tinycc";
19 inherit rev;
20 inherit sha256;
21 };
22
23 outputs = [ "bin" "dev" "out" ];
24
25 nativeBuildInputs = [ perl texinfo ];
26
27 hardeningDisable = [ "fortify" ];
28
29 postPatch = ''
30 substituteInPlace "texi2pod.pl" \
31 --replace "/usr/bin/perl" "${perl}/bin/perl"
32 '';
33
34 preConfigure = ''
35 configureFlagsArray+=("--elfinterp=$(cat $NIX_CC/nix-support/dynamic-linker)")
36 configureFlagsArray+=("--crtprefix=${stdenv.glibc.out}/lib")
37 configureFlagsArray+=("--sysincludepaths=${stdenv.glibc.dev}/include:{B}/include")
38 configureFlagsArray+=("--libpaths=${stdenv.glibc.out}/lib")
39 '';
40
41 doCheck = true;
42 checkTarget = "test";
43
44 postFixup = ''
45 paxmark m $bin/bin/tcc
46 '';
47
48 meta = {
49 description = "Small, fast, and embeddable C compiler and interpreter";
50
51 longDescription = ''
52 TinyCC (aka TCC) is a small but hyper fast C compiler. Unlike
53 other C compilers, it is meant to be self-sufficient: you do not
54 need an external assembler or linker because TCC does that for
55 you.
56
57 TCC compiles so fast that even for big projects Makefiles may not
58 be necessary.
59
60 TCC not only supports ANSI C, but also most of the new ISO C99
61 standard and many GNU C extensions.
62
63 TCC can also be used to make C scripts, i.e. pieces of C source
64 that you run as a Perl or Python script. Compilation is so fast
65 that your script will be as fast as if it was an executable.
66
67 TCC can also automatically generate memory and bound checks while
68 allowing all C pointers operations. TCC can do these checks even
69 if non patched libraries are used.
70
71 With libtcc, you can use TCC as a backend for dynamic code
72 generation.
73 '';
74
75 homepage = http://www.tinycc.org/;
76 license = licenses.lgpl2Plus;
77
78 platforms = platforms.unix;
79 maintainers = [ maintainers.joachifm ];
80 };
81}