me

/

vinix-ports Public
382 commits 0 issues 0 pull requests 1 contributor Discussions Projects Snippets LOC history Platform CI

Package the GNU runtimes and exercise AArch64 atomics in Vinix

diviocity committed 5 days ago · 9dc6de9af9e346da27b593c74109e3eb040897cd View patch
Unverified signature 2 files changed +106 -0
BOOTSTRAP.md +2 -0

@@ -44,6 +44,8 @@ The initial arm64 survey covered 22 distinct archive names. Thirteen contained a

4444

4545MPFR needs a cross-compiler with BID decimal support. On aarch64 the worker used the pinned Ubuntu GCC 14.2 cross-compiler as a build tool, Vinix musl headers and a static decimal support archive built from the GCC source used for the Vinix runtime. The compiler inputs and probe are recorded in `gnu/arm/decimal-compiler/receipts.sha256`. The signed MPFR 4.2.1-5 has SHA-256 `e44e82b8761f1bc286c48778be25d227d3081e116f19c68752815f683fabbf82` and retains all 697 published exports. Reproduce the check with `mpfr/decimal.c` and `mpfr/thread-state.c` linked against the signed SDK. The released kernel ran both fixtures and round-tripped decimal64 and decimal128 while keeping two threads' floating-point state separate. See `gnu/arm/logs/mpfr-decimal-131/receipts.sha256` and `gnu/arm/logs/numeric-decimal-guest-132/serial.log`, SHA-256 `4f5302374bc2f94137fd31ad6c3015fd95fe0282b6f87e7141d06a17edbb5820` and `0a16a54024c57e6751d814eb6f7ab9122aadd4322f145ca1409139dace70c894`.

4646

47+The aarch64 GNU runtime uses inline atomics so its shared libraries resolve against the packaged musl and unwinder. The recipe checks every library for 16 KiB load segments and unresolved outlined atomic helpers. A clean signed installation of `gcc-libs` 14.2.0-2 booted with the released kernel and ran the C++ exception, OpenMP and 128-bit atomic fixtures in `tests/toolchain`. The package digest is `796840770f4e2121e2923e727c5469270625b0e9832cea4504e97ea3149460a0`. See `gnu/arm/logs/runtime-guest-r115/serial.log`, SHA-256 `61e7f5b0b14295d3b2c1a6156388aa67f6ba21fccb1555ca8a484d410e260dcd`.

48+

4749The desktop metapackage requires musl 1.2.6-4 or later on arm64 and 1.2.6-2 or later on x86_64. The test-signed ARM 1.2.6-3 loader itself had 16 KiB load segments. Its GCC specs let the cross toolchain override that setting for a newly linked shared library. The expected ARM minimum excludes this SDK. The worker checked the architecture-specific version constraints with native vpac metadata in `foundation/release-musl-floor-02`, receipt SHA-256 `2d6886c3bc9fdc7ef38945d303c92cb3b877eba9d67c2fa25b49f46d73019e8a`.

4850

4951Run `python3 tests/exec-linkage.py x86_64 "$client" "$auditor" --proot "$(command -v proot)"` on an x86_64 worker to exercise the installed loader against each dynamic executable in an audited root. For a Vinix guest, use `--fixture "$work/linkage.sh"` and pass that script to the boot harness. Packaged musl 1.2.6 applies relocations before returning from `--list`. It resolved all 109 dynamic executables in the signed 106-package x86_64 root. Renaming the exported `OPENSSL_init_ssl` symbol in an isolated copy of libssl caused the loader to reject `/usr/bin/openssl` with status 127. See `foundation/exec-linkage-01`, receipt SHA-256 `cb2fdec09f4b9e7c873ec82d672af576e9e0c26484f9496744588323a01ed3a0`.

gcc-libs/PKGBUILD.vile new file +104 -0

@@ -0,0 +1,104 @@

1+; Build the target runtimes from GCC sources using the external bootstrap

2+; compiler. Only the versioned shared objects belong to this package.

3+host-arch := if memq(string->symbol("aarch64"), features()) { "aarch64" } else { "x86_64" }

4+selected := get-environment-variable("VPAC_TARGET_ARCH")

5+arch := if string?(selected) { selected } else { host-arch }

6+arm := string=?(arch, "aarch64")

7+libc := if arm { "musl>=1.2.6-4" } else { "musl" }

8+triplet := string-append(arch, "-linux-musl")

9+libs := list("libgcc_s.so.1", "libstdc++.so.6", "libatomic.so.1", "libgomp.so.1")

10+

11+defpkgbuild(gcc-libs,

12+ #:pkgname, "gcc-libs",

13+ #:pkgver, "14.2.0",

14+ #:pkgrel, if arm { 2 } else { 1 },

15+ #:pkgdesc, "GNU C and C++ shared runtime libraries for Vinix",

16+ #:arch, [#:x86-64, #:aarch64],

17+ #:url, "https://gcc.gnu.org/",

18+ #:license, ["GPL-3.0-or-later WITH GCC-exception-3.1"],

19+ #:depends, list(libc),

20+ #:provides, ["libgcc=14.2.0", "libstdc++=14.2.0", "libatomic=14.2.0", "libgomp=14.2.0"],

21+ #:makedepends, ["linux-headers", "gmp", "mpfr", "mpc", "zlib", "make"],

22+ #:source, ["https://distfiles.alpinelinux.org/distfiles/v3.21/gcc-14.2.0.tar.xz"],

23+ #:sha256sums, ["a7b39bc69cbf9e25826c5a60ab26477001f7c08d85cec04bc0e29cabed6f3cc9"],

24+ #:build, fn() {

25+ root := get-environment-variable("VPAC_MAKEPKG_ROOT")

26+ native := string=?(host-arch, arch)

27+ prefix := if native { "" } else { get-environment-variable("CROSS_COMPILE") }

28+ driver := string-append(srcdir(), "/driver-support")

29+ ; Alpine's bootstrap GCC unconditionally links -lssp_nonshared. Older

30+ ; Vinix SDKs lack the archive. Build its GCC implementation for the

31+ ; selected target without adding any external library search directory.

32+ driver-flags := if file-exists?(string-append(root, "/usr/lib/libssp_nonshared.a")) { "" } else {

33+ run("mkdir", "-p", driver)

34+ call-with-output-file(string-append(driver, "/config.h"), fn(port) { display("#define HAVE_HIDDEN_VISIBILITY 1\n", port) })

35+ object := string-append(driver, "/ssp-local.o")

36+ run("vinix-cc", "-O2", "-fPIC", "-fno-stack-protector", string-append("-I", driver), "-c", "gcc-14.2.0/libssp/ssp-local.c", "-o", object)

37+ run(string-append(prefix, "ar"), "rcs", string-append(driver, "/libssp_nonshared.a"), object)

38+ string-append("-L", driver)

39+ }

40+ build-option := if native { list(string-append("--build=", triplet)) } else { list() }

41+ target-flags := if arm { "-O2 -g0 -mno-outline-atomics" } else { "-O2 -g0" }

42+ target-tools := if native { list() } else {

43+ list("CC_FOR_BUILD=gcc", "CXX_FOR_BUILD=g++", "CFLAGS_FOR_BUILD=-O2 -g0", "CXXFLAGS_FOR_BUILD=-O2 -g0", "LDFLAGS_FOR_BUILD=",

44+ "AR_FOR_BUILD=ar", "RANLIB_FOR_BUILD=ranlib",

45+ string-append("AR=", prefix, "ar"), string-append("AS=", prefix, "as"),

46+ string-append("LD=", prefix, "ld"), string-append("NM=", prefix, "nm"),

47+ string-append("RANLIB=", prefix, "ranlib"), string-append("STRIP=", prefix, "strip"),

48+ string-append("AR_FOR_TARGET=", prefix, "ar"), string-append("AS_FOR_TARGET=", prefix, "as"),

49+ string-append("LD_FOR_TARGET=", prefix, "ld"), string-append("NM_FOR_TARGET=", prefix, "nm"),

50+ string-append("RANLIB_FOR_TARGET=", prefix, "ranlib"), string-append("STRIP_FOR_TARGET=", prefix, "strip"))

51+ }

52+ apply(run, append(list("env", "CC=vinix-cc", "CXX=vinix-c++", "CC_FOR_BUILD=gcc", "CXX_FOR_BUILD=g++",

53+ "CFLAGS=-O1 -g0", string-append("CFLAGS_FOR_TARGET=", target-flags), string-append("CXXFLAGS_FOR_TARGET=", target-flags)), target-tools,

54+ list("gcc-14.2.0/configure", "--prefix=/usr", "--libdir=/usr/lib"), build-option,

55+ list(string-append("--host=", triplet), string-append("--target=", triplet), "--enable-languages=c,c++",

56+ "--disable-bootstrap", "--with-sysroot=/", string-append("--with-build-sysroot=", root), "--with-native-system-header-dir=/usr/include",

57+ string-append("--with-gmp=", root, "/usr"), string-append("--with-mpfr=", root, "/usr"), string-append("--with-mpc=", root, "/usr"),

58+ "--with-system-zlib", "--without-isl", "--disable-multilib", "--disable-nls", "--disable-libstdcxx-pch", "--disable-libsanitizer",

59+ "--disable-libquadmath", "--disable-libcc1", "--enable-libatomic", "--enable-libgomp", "--enable-shared", "--enable-threads=posix")))

60+ apply(run, append(list("make"), target-tools, list("configure-gcc", "all-build-libiberty", "all-build-fixincludes",

61+ "all-libiberty", "all-libcpp", "all-libdecnumber", "all-libbacktrace")))

62+ ; GCC's fixed-header rules query the compiler's predefined macros and

63+ ; multilib list. The bootstrap driver can answer both for the target.

64+ apply(run, append(list("make", "-C", "gcc", "-o", "xgcc", "-o", "specs", "-o", "cc1", "GCC_FOR_TARGET=vinix-cc"),

65+ target-tools, list("GENERATOR_CFLAGS=-O2 -g0", "libgcc-support", "tm.h", "options.h", "insn-constants.h", "insn-modes.h", "insn-modes-inline.h")))

66+ target-make := append(list("make", "-o", "maybe-all-gcc", "-o", "all-gcc", "CC_FOR_TARGET=vinix-cc", "GCC_FOR_TARGET=vinix-cc",

67+ "CXX_FOR_TARGET=vinix-c++", "RAW_CXX_FOR_TARGET=vinix-c++"), target-tools)

68+ apply(run, append(target-make, list(string-append("LDFLAGS_FOR_TARGET=", driver-flags), "all-target-libgcc")))

69+ ; The stage-one musl specs normally select static compiler support.

70+ ; Link libstdc++ to the shared unwinder built in the preceding step.

71+ support := string-append(srcdir(), "/", triplet, "/libgcc")

72+ run("test", "-f", string-append(support, "/libgcc_s.so.1"))

73+ ; Libtool filters a bare shared-object argument from LDFLAGS. Passing it

74+ ; explicitly to ld keeps the new runtime's SONAME in libstdc++.so.6.

75+ link-flags := string-append("LDFLAGS_FOR_TARGET=", driver-flags, " -Wl,--no-as-needed,", support, "/libgcc_s.so.1,--as-needed -Wl,-rpath-link,",

76+ root, "/lib -Wl,-rpath-link,", root, "/usr/lib")

77+ ; Preserve the completed unwinder. Recursing into libgcc with its own

78+ ; shared object on the link line produces a self-dependent library.

79+ libraries := append(target-make, list("-o", "maybe-all-target-libgcc", "-o", "all-target-libgcc"))

80+ apply(run, append(libraries, list(link-flags, "all-target-libstdc++-v3")))

81+ apply(run, append(libraries, list(string-append("LDFLAGS_FOR_TARGET=", driver-flags), "all-target-libatomic", "all-target-libgomp")))

82+ },

83+ #:package, fn() {

84+ dest := string-append(pkgdir(), "/usr/lib")

85+ run("mkdir", "-p", dest)

86+ ; Copy only files linked by these four target build directories. The

87+ ; archive contains the versioned ELF and its SONAME, not seed libraries.

88+ for-each(fn(pattern) {

89+ for-each(fn(file) { run("cp", "-P", file, dest) }, glob(pattern))

90+ }, list(string-append(triplet, "/libgcc/libgcc_s.so.*"), string-append(triplet, "/libstdc++-v3/src/.libs/libstdc++.so.*"),

91+ string-append(triplet, "/libatomic/.libs/libatomic.so.*"), string-append(triplet, "/libgomp/.libs/libgomp.so.*")))

92+ for-each(fn(lib) { run("test", "-f", string-append(dest, "/", lib)) }, libs)

93+ run("sh", "-ec", "readelf -d \"$1\" | grep '(NEEDED)' | grep -F '[libgcc_s.so.1]'", "check-unwinder",

94+ string-append(dest, "/libstdc++.so.6"))

95+ if arm {

96+ for-each(fn(lib) {

97+ file := string-append(dest, "/", lib)

98+ run("vinix-elf-pages", arch, file)

99+ run("sh", "-ec", "readelf --wide --dyn-syms \"$1\" | awk '$7 == \"UND\" && $8 ~ /^__aarch64_(cas|swp|ldadd|ldclr|ldeor|ldset)/ { print $8; bad=1 } END { exit bad }'", "check-outlined-atomics", file)

100+ }, libs)

101+ }

102+ run("install", "-Dm644", "gcc-14.2.0/COPYING.RUNTIME", string-append(pkgdir(), "/usr/share/licenses/gcc-libs/COPYING.RUNTIME"))

103+ run("install", "-Dm644", "gcc-14.2.0/COPYING3", string-append(pkgdir(), "/usr/share/licenses/gcc-libs/COPYING3"))

104+ })