nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at devShellTools-shell 99 lines 2.7 kB view raw
1# Build steps adapted from https://github.com/fosslinux/live-bootstrap/blob/1bc4296091c51f53a5598050c8956d16e945b0f5/sysa/tcc-0.9.27/tcc-0.9.27.kaem 2# 3# SPDX-FileCopyrightText: 2021-22 fosslinux <fosslinux@aussies.space> 4# 5# SPDX-License-Identifier: GPL-3.0-or-later 6 7{ 8 lib, 9 fetchurl, 10 callPackage, 11 kaem, 12 tinycc-bootstrappable, 13}: 14let 15 inherit (callPackage ./common.nix { }) buildTinyccMes; 16 17 version = "unstable-2023-04-20"; 18 rev = "86f3d8e33105435946383aee52487b5ddf918140"; 19 20 tarball = fetchurl { 21 url = "https://repo.or.cz/tinycc.git/snapshot/${rev}.tar.gz"; 22 sha256 = "11idrvbwfgj1d03crv994mpbbbyg63j1k64lw1gjy7mkiifw2xap"; 23 }; 24 src = 25 (kaem.runCommand "tinycc-${version}-source" { } '' 26 ungz --file ${tarball} --output tinycc.tar 27 mkdir -p ''${out} 28 cd ''${out} 29 untar --file ''${NIX_BUILD_TOP}/tinycc.tar 30 31 # Patch 32 cd tinycc-${builtins.substring 0 7 rev} 33 # Static link by default 34 replace --file libtcc.c --output libtcc.c --match-on "s->ms_extensions = 1;" --replace-with "s->ms_extensions = 1; s->static_link = 1;" 35 '') 36 + "/tinycc-${builtins.substring 0 7 rev}"; 37 38 meta = with lib; { 39 description = "Small, fast, and embeddable C compiler and interpreter"; 40 homepage = "https://repo.or.cz/w/tinycc.git"; 41 license = licenses.lgpl21Only; 42 teams = [ teams.minimal-bootstrap ]; 43 platforms = [ "i686-linux" ]; 44 }; 45 46 tccdefs = kaem.runCommand "tccdefs-${version}" { } '' 47 mkdir ''${out} 48 ${tinycc-bootstrappable.compiler}/bin/tcc \ 49 -B ${tinycc-bootstrappable.libs}/lib \ 50 -DC2STR \ 51 -o c2str \ 52 ${src}/conftest.c 53 ./c2str ${src}/include/tccdefs.h ''${out}/tccdefs_.h 54 ''; 55 56 tinycc-mes-boot = buildTinyccMes { 57 pname = "tinycc-mes-boot"; 58 inherit src version meta; 59 prev = tinycc-bootstrappable; 60 buildOptions = [ 61 "-D HAVE_BITFIELD=1" 62 "-D HAVE_FLOAT=1" 63 "-D HAVE_LONG_LONG=1" 64 "-D HAVE_SETJMP=1" 65 "-D CONFIG_TCC_PREDEFS=1" 66 "-I ${tccdefs}" 67 "-D CONFIG_TCC_SEMLOCK=0" 68 ]; 69 libtccBuildOptions = [ 70 "-D HAVE_FLOAT=1" 71 "-D HAVE_LONG_LONG=1" 72 "-D CONFIG_TCC_PREDEFS=1" 73 "-I ${tccdefs}" 74 "-D CONFIG_TCC_SEMLOCK=0" 75 ]; 76 }; 77in 78buildTinyccMes { 79 pname = "tinycc-mes"; 80 inherit src version meta; 81 prev = tinycc-mes-boot; 82 buildOptions = [ 83 "-std=c99" 84 "-D HAVE_BITFIELD=1" 85 "-D HAVE_FLOAT=1" 86 "-D HAVE_LONG_LONG=1" 87 "-D HAVE_SETJMP=1" 88 "-D CONFIG_TCC_PREDEFS=1" 89 "-I ${tccdefs}" 90 "-D CONFIG_TCC_SEMLOCK=0" 91 ]; 92 libtccBuildOptions = [ 93 "-D HAVE_FLOAT=1" 94 "-D HAVE_LONG_LONG=1" 95 "-D CONFIG_TCC_PREDEFS=1" 96 "-I ${tccdefs}" 97 "-D CONFIG_TCC_SEMLOCK=0" 98 ]; 99}