Files
2026-08-18 02:10:54 -04:00

56 lines
2.1 KiB
Plaintext

/*
* tcc — Tiny C Compiler. The fast, tiny, self-hosting C compiler.
*
* 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 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.28rc"
const source = "https://dev.alpinelinux.org/archive/tcc/tcc-d9d02c56401e43be43760b63f7d82f771a7ed1f6.tar.gz"
sha256 = "b25f68a46930549553f6d679106d99d5a00b4d8f39a178baaeae6a50018e37ae"
license = "LGPL-2.1-or-later"
provides = ["tcc", "cc"]
depends = [
{ name = "make" },
]
prepare {
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 {
./configure --prefix=${prefix}
make -j${jobs}
}
check {
./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
}
}