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