Build the Boehm collector and validate target atomics and live objects
@@ -0,0 +1,31 @@
1+defpkgbuild(gc,
2+ #:pkgname, "gc",
3+ #:pkgver, "8.2.8",
4+ #:pkgrel, 1,
5+ #:pkgdesc, "Boehm garbage collector for the native V runtime",
6+ #:arch, [#:x86-64, #:aarch64],
7+ #:url, "https://www.hboehm.info/gc/",
8+ #:license, "Boehm-GC",
9+ #:depends, ["musl"],
10+ #:makedepends, ["linux-headers"],
11+ #:source, ["https://github.com/ivmai/bdwgc/releases/download/v8.2.8/gc-8.2.8.tar.gz", "collect.c"],
12+ #:sha256sums, ["7649020621cb26325e1fb5c8742590d92fb48ce5c259b502faf7d9fb5dabb160",
13+ "892f568199042f60be4007f16b80295b956ce23e38cabb1d74d5a33eea6261f9"],
14+ #:build, fn() {
15+ ; Cross configure cannot execute this upstream probe itself.
16+ run("vinix-cc", "-DGC_BUILTIN_ATOMIC", "-Igc-8.2.8/include",
17+ "gc-8.2.8/tests/test_atomic_ops.c", "-o", "check-atomics")
18+ run("vinix-run", "./check-atomics")
19+ run("vinix-configure", "gc-8.2.8/configure", "--with-libatomic-ops=none",
20+ "--enable-threads=posix", "--disable-cplusplus")
21+ run("make")
22+ },
23+ #:check, fn() {
24+ run("vinix-cc", "-Igc-8.2.8/include", "collect.c", "-L.libs", "-lgc", "-o", "collect")
25+ run("vinix-run", "--library-path", ".libs", "./collect")
26+ },
27+ #:package, fn() {
28+ run("make", "install", string-append("DESTDIR=", pkgdir()))
29+ run("find", pkgdir(), "-name", "*.la", "-delete")
30+ run("install", "-Dm644", "gc-8.2.8/README.md", string-append(pkgdir(), "/usr/share/licenses/gc/README.md"))
31+ })
@@ -0,0 +1,28 @@
1+#include <gc.h>
2+#include <stddef.h>
3+
4+struct link {
5+ struct link *previous;
6+ size_t value;
7+};
8+
9+int main(void)
10+{
11+ GC_INIT();
12+ struct link *root = NULL;
13+ for (size_t i = 0; i < 8192; ++i) {
14+ struct link *next = GC_MALLOC(sizeof(*next));
15+ if (next == NULL)
16+ return 1;
17+ next->previous = root;
18+ next->value = i;
19+ root = next;
20+ }
21+ GC_gcollect();
22+ for (size_t count = 8192; count != 0; --count) {
23+ if (root == NULL || root->value != count - 1)
24+ return 2;
25+ root = root->previous;
26+ }
27+ return root != NULL;
28+}