This commit is contained in:
2026-08-18 02:10:54 -04:00
parent 6ad165160e
commit e65dcbb790
5 changed files with 114 additions and 24 deletions
+25 -16
View File
@@ -1,18 +1,20 @@
/*
* tcc — Tiny C Compiler. The fast, tiny, self-hosting C compiler.
*
* Built with the stable 0.9.27 release plus the glibc-2.34 patch
* (bcheck.c's __malloc_hook was removed from glibc; the bounds checker
* is disabled on glibc >= 2.34, where the API no longer exists).
* The patch lives in the repo: patches/tcc-0.9.27-glibc-2.34.patch.
* Built from the MOB branch (0.9.28rc, commit d9d02c56 — the same
* snapshot Alpine ships): the 0.9.27 release segfaults when compiling on
* modern glibc/kernel (verified — even hello world crashed), while mob
* carries the codegen and glibc-2.34 fixes (__malloc_hook is already
* handled, so no patch is needed). Pinned commit = reproducible.
* Hosted on Alpine's stable archive (dev.alpinelinux.org).
*
* The check phase verifies self-hosting: tcc compiles its own compiler
* and the result runs.
* The check phase proves self-hosting: tcc compiles its own compiler
* (-B. points at the uninstalled include dir) and the result runs.
*/
package "tcc" {
const version = "0.9.27"
const source = "https://download.savannah.nongnu.org/releases/tinycc/tcc-${version}.tar.bz2"
sha256 = "de23af78fca90ce32dff2dd45b3432b2334740bb9bb7b05bf60fdbfc396ceb9c"
const version = "0.9.28rc"
const source = "https://dev.alpinelinux.org/archive/tcc/tcc-d9d02c56401e43be43760b63f7d82f771a7ed1f6.tar.gz"
sha256 = "b25f68a46930549553f6d679106d99d5a00b4d8f39a178baaeae6a50018e37ae"
license = "LGPL-2.1-or-later"
provides = ["tcc", "cc"]
@@ -22,12 +24,9 @@ package "tcc" {
]
prepare {
curl -L -O ${source}
echo "de23af78fca90ce32dff2dd45b3432b2334740bb9bb7b05bf60fdbfc396ceb9c tcc-${version}.tar.bz2" | sha256sum -c -
tar xf tcc-${version}.tar.bz2 --strip-components=1
curl -L -O https://files.spectoria.dev/kappa-packages/patches/tcc-0.9.27-glibc-2.34.patch
echo "d5c2b6865cd4f80c646ffc85a0fe53e15e3a1877e0a8d29556d01742e5094d6e tcc-0.9.27-glibc-2.34.patch" | sha256sum -c -
patch -p1 < tcc-0.9.27-glibc-2.34.patch
curl -L -o tcc-${version}.tar.gz ${source}
echo "b25f68a46930549553f6d679106d99d5a00b4d8f39a178baaeae6a50018e37ae tcc-${version}.tar.gz" | sha256sum -c -
tar xf tcc-${version}.tar.gz --strip-components=1
}
build {
@@ -36,11 +35,21 @@ package "tcc" {
}
check {
./tcc -o tcc-selfhost tcc.c -I. -DONE_SOURCE -lm -ldl
./tcc -B. -o tcc-selfhost tcc.c -I. -DONE_SOURCE -lm -ldl
./tcc-selfhost -v
}
// The store is not a standard /usr tree, but tcc bakes absolute paths
// (configure --prefix). A tiny wrapper injects -B<self>/../lib/tcc so
// the plain `tcc` invocation finds its includes and runtime from any
// store location. $@ is deliberately unquoted (word-split; tcc args
// are paths/flags).
install {
make DESTDIR=${destdir} install
mv ${destdir}/usr/bin/tcc ${destdir}/usr/bin/tcc.real
echo '#!/bin/sh' > ${destdir}/usr/bin/tcc
echo 'DIR=$(dirname $(readlink -f $0))' >> ${destdir}/usr/bin/tcc
echo 'exec $DIR/tcc.real -B$DIR/../lib/tcc $@' >> ${destdir}/usr/bin/tcc
chmod 755 ${destdir}/usr/bin/tcc
}
}