From c745c03839fab4b74c22057f26cc1a9223701f33 Mon Sep 17 00:00:00 2001 From: diviocity Date: Mon, 30 Nov 2026 01:55:12 +0100 Subject: [PATCH] Build the Boehm collector and validate target atomics and live objects --- gc/PKGBUILD.vile | 31 +++++++++++++++++++++++++++++++ gc/collect.c | 28 ++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+) create mode 100644 gc/PKGBUILD.vile create mode 100644 gc/collect.c diff --git a/gc/PKGBUILD.vile b/gc/PKGBUILD.vile new file mode 100644 index 0000000..9de54d0 --- /dev/null +++ b/gc/PKGBUILD.vile @@ -0,0 +1,31 @@ +defpkgbuild(gc, + #:pkgname, "gc", + #:pkgver, "8.2.8", + #:pkgrel, 1, + #:pkgdesc, "Boehm garbage collector for the native V runtime", + #:arch, [#:x86-64, #:aarch64], + #:url, "https://www.hboehm.info/gc/", + #:license, "Boehm-GC", + #:depends, ["musl"], + #:makedepends, ["linux-headers"], + #:source, ["https://github.com/ivmai/bdwgc/releases/download/v8.2.8/gc-8.2.8.tar.gz", "collect.c"], + #:sha256sums, ["7649020621cb26325e1fb5c8742590d92fb48ce5c259b502faf7d9fb5dabb160", + "892f568199042f60be4007f16b80295b956ce23e38cabb1d74d5a33eea6261f9"], + #:build, fn() { + ; Cross configure cannot execute this upstream probe itself. + run("vinix-cc", "-DGC_BUILTIN_ATOMIC", "-Igc-8.2.8/include", + "gc-8.2.8/tests/test_atomic_ops.c", "-o", "check-atomics") + run("vinix-run", "./check-atomics") + run("vinix-configure", "gc-8.2.8/configure", "--with-libatomic-ops=none", + "--enable-threads=posix", "--disable-cplusplus") + run("make") + }, + #:check, fn() { + run("vinix-cc", "-Igc-8.2.8/include", "collect.c", "-L.libs", "-lgc", "-o", "collect") + run("vinix-run", "--library-path", ".libs", "./collect") + }, + #:package, fn() { + run("make", "install", string-append("DESTDIR=", pkgdir())) + run("find", pkgdir(), "-name", "*.la", "-delete") + run("install", "-Dm644", "gc-8.2.8/README.md", string-append(pkgdir(), "/usr/share/licenses/gc/README.md")) + }) diff --git a/gc/collect.c b/gc/collect.c new file mode 100644 index 0000000..52902da --- /dev/null +++ b/gc/collect.c @@ -0,0 +1,28 @@ +#include +#include + +struct link { + struct link *previous; + size_t value; +}; + +int main(void) +{ + GC_INIT(); + struct link *root = NULL; + for (size_t i = 0; i < 8192; ++i) { + struct link *next = GC_MALLOC(sizeof(*next)); + if (next == NULL) + return 1; + next->previous = root; + next->value = i; + root = next; + } + GC_gcollect(); + for (size_t count = 8192; count != 0; --count) { + if (root == NULL || root->value != count - 1) + return 2; + root = root->previous; + } + return root != NULL; +} -- 2.56.1