2023-05-01 03:09:32 +00:00
|
|
|
# Build steps adapted from https://github.com/fosslinux/live-bootstrap/blob/1bc4296091c51f53a5598050c8956d16e945b0f5/sysa/tcc-0.9.27/tcc-0.9.27.kaem
|
|
|
|
#
|
|
|
|
# SPDX-FileCopyrightText: 2021-22 fosslinux <fosslinux@aussies.space>
|
|
|
|
#
|
|
|
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
|
|
|
|
{ lib
|
|
|
|
, fetchurl
|
|
|
|
, callPackage
|
2023-05-11 15:05:30 +00:00
|
|
|
, kaem
|
2023-05-01 03:09:32 +00:00
|
|
|
, tinycc-bootstrappable
|
|
|
|
}:
|
|
|
|
let
|
|
|
|
inherit (callPackage ./common.nix { }) buildTinyccMes;
|
|
|
|
|
|
|
|
version = "unstable-2023-04-20";
|
|
|
|
rev = "86f3d8e33105435946383aee52487b5ddf918140";
|
|
|
|
|
|
|
|
tarball = fetchurl {
|
|
|
|
url = "https://repo.or.cz/tinycc.git/snapshot/${rev}.tar.gz";
|
|
|
|
sha256 = "11idrvbwfgj1d03crv994mpbbbyg63j1k64lw1gjy7mkiifw2xap";
|
|
|
|
};
|
2023-05-11 15:05:30 +00:00
|
|
|
src = (kaem.runCommand "tinycc-${version}-source" {} ''
|
2023-05-01 03:09:32 +00:00
|
|
|
ungz --file ${tarball} --output tinycc.tar
|
|
|
|
mkdir -p ''${out}
|
|
|
|
cd ''${out}
|
|
|
|
untar --file ''${NIX_BUILD_TOP}/tinycc.tar
|
2023-05-24 01:58:37 +00:00
|
|
|
|
|
|
|
# Patch
|
|
|
|
cd tinycc-${builtins.substring 0 7 rev}
|
|
|
|
# Static link by default
|
|
|
|
replace --file libtcc.c --output libtcc.c --match-on "s->ms_extensions = 1;" --replace-with "s->ms_extensions = 1; s->static_link = 1;"
|
2023-05-01 03:09:32 +00:00
|
|
|
'') + "/tinycc-${builtins.substring 0 7 rev}";
|
|
|
|
|
|
|
|
meta = with lib; {
|
|
|
|
description = "Small, fast, and embeddable C compiler and interpreter";
|
|
|
|
homepage = "https://repo.or.cz/w/tinycc.git";
|
|
|
|
license = licenses.lgpl21Only;
|
2023-05-17 00:25:02 +00:00
|
|
|
maintainers = teams.minimal-bootstrap.members;
|
2023-05-01 03:09:32 +00:00
|
|
|
platforms = [ "i686-linux" ];
|
|
|
|
};
|
|
|
|
|
2023-05-11 15:05:30 +00:00
|
|
|
tccdefs = kaem.runCommand "tccdefs-${version}" {} ''
|
2023-05-01 03:09:32 +00:00
|
|
|
mkdir ''${out}
|
2023-05-14 18:51:46 +00:00
|
|
|
${tinycc-bootstrappable.compiler}/bin/tcc \
|
|
|
|
-B ${tinycc-bootstrappable.libs}/lib \
|
|
|
|
-DC2STR \
|
|
|
|
-o c2str \
|
|
|
|
${src}/conftest.c
|
2023-05-01 03:09:32 +00:00
|
|
|
./c2str ${src}/include/tccdefs.h ''${out}/tccdefs_.h
|
|
|
|
'';
|
|
|
|
|
|
|
|
tinycc-mes-boot = buildTinyccMes {
|
|
|
|
pname = "tinycc-mes-boot";
|
|
|
|
inherit src version meta;
|
|
|
|
prev = tinycc-bootstrappable;
|
|
|
|
buildOptions = [
|
|
|
|
"-D HAVE_BITFIELD=1"
|
|
|
|
"-D HAVE_FLOAT=1"
|
|
|
|
"-D HAVE_LONG_LONG=1"
|
|
|
|
"-D HAVE_SETJMP=1"
|
|
|
|
"-D CONFIG_TCC_PREDEFS=1"
|
|
|
|
"-I ${tccdefs}"
|
|
|
|
"-D CONFIG_TCC_SEMLOCK=0"
|
|
|
|
];
|
|
|
|
libtccBuildOptions = [
|
|
|
|
"-D HAVE_FLOAT=1"
|
|
|
|
"-D HAVE_LONG_LONG=1"
|
|
|
|
"-D CONFIG_TCC_PREDEFS=1"
|
|
|
|
"-I ${tccdefs}"
|
|
|
|
"-D CONFIG_TCC_SEMLOCK=0"
|
|
|
|
];
|
|
|
|
};
|
|
|
|
in
|
|
|
|
buildTinyccMes {
|
|
|
|
pname = "tinycc-mes";
|
|
|
|
inherit src version meta;
|
|
|
|
prev = tinycc-mes-boot;
|
|
|
|
buildOptions = [
|
|
|
|
"-std=c99"
|
|
|
|
"-D HAVE_BITFIELD=1"
|
|
|
|
"-D HAVE_FLOAT=1"
|
|
|
|
"-D HAVE_LONG_LONG=1"
|
|
|
|
"-D HAVE_SETJMP=1"
|
|
|
|
"-D CONFIG_TCC_PREDEFS=1"
|
|
|
|
"-I ${tccdefs}"
|
|
|
|
"-D CONFIG_TCC_SEMLOCK=0"
|
|
|
|
];
|
|
|
|
libtccBuildOptions = [
|
|
|
|
"-D HAVE_FLOAT=1"
|
|
|
|
"-D HAVE_LONG_LONG=1"
|
|
|
|
"-D CONFIG_TCC_PREDEFS=1"
|
|
|
|
"-I ${tccdefs}"
|
|
|
|
"-D CONFIG_TCC_SEMLOCK=0"
|
|
|
|
];
|
|
|
|
}
|