nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{ lib
2, stdenv
3, fetchFromRepoOrCz
4, perl
5, texinfo
6, which
7}:
8
9stdenv.mkDerivation rec {
10 pname = "tcc";
11 version = "0.9.27+date=2022-01-11";
12
13 src = fetchFromRepoOrCz {
14 repo = "tinycc";
15 rev = "4e0e9b8f210d69893b306d6b24d2dd615a22f246";
16 hash = "sha256-0BJ5wXsgDLBIvcbq+rL9UQC4NjLHCI9r6sUWF98APPg=";
17 };
18
19 nativeBuildInputs = [
20 perl
21 texinfo
22 which
23 ];
24
25 postPatch = ''
26 patchShebangs texi2pod.pl
27 '';
28
29 configureFlags = [
30 "--cc=$CC"
31 "--ar=$AR"
32 "--crtprefix=${lib.getLib stdenv.cc.libc}/lib"
33 "--sysincludepaths=${lib.getDev stdenv.cc.libc}/include:{B}/include"
34 "--libpaths=${lib.getLib stdenv.cc.libc}/lib"
35 # build cross compilers
36 "--enable-cross"
37 ] ++ lib.optionals stdenv.hostPlatform.isMusl [
38 "--config-musl"
39 ];
40
41 preConfigure = ''
42 echo ${version} > VERSION
43 configureFlagsArray+=("--elfinterp=$(< $NIX_CC/nix-support/dynamic-linker)")
44 '';
45
46 postFixup = ''
47 cat >libtcc.pc <<EOF
48 Name: libtcc
49 Description: Tiny C compiler backend
50 Version: ${version}
51 Libs: -L$out/lib -Wl,--rpath $out/lib -ltcc -ldl
52 Cflags: -I$out/include
53 EOF
54 install -Dt $out/lib/pkgconfig libtcc.pc -m 444
55 '';
56
57 outputs = [ "out" "info" "man" ];
58
59 doCheck = true;
60 checkTarget = "test";
61
62 meta = with lib; {
63 broken = stdenv.isDarwin;
64 homepage = "https://repo.or.cz/tinycc.git";
65 description = "Small, fast, and embeddable C compiler and interpreter";
66 longDescription = ''
67 TinyCC (aka TCC) is a small but hyper fast C compiler. Unlike other C
68 compilers, it is meant to be self-sufficient: you do not need an external
69 assembler or linker because TCC does that for you.
70
71 TCC compiles so fast that even for big projects Makefiles may not be
72 necessary.
73
74 TCC not only supports ANSI C, but also most of the new ISO C99 standard
75 and many GNU C extensions.
76
77 TCC can also be used to make C scripts, i.e. pieces of C source that you
78 run as a Perl or Python script. Compilation is so fast that your script
79 will be as fast as if it was an executable.
80
81 TCC can also automatically generate memory and bound checks while allowing
82 all C pointers operations. TCC can do these checks even if non patched
83 libraries are used.
84
85 With libtcc, you can use TCC as a backend for dynamic code generation.
86 '';
87 license = licenses.lgpl21Only;
88 maintainers = with maintainers; [ joachifm AndersonTorres ];
89 platforms = platforms.unix;
90 };
91}
92# TODO: more multiple outputs
93# TODO: self-compilation