| 1 | ; Alpine 3.21 binutils source and patches, producing native Vinix ELF tools. |
| 2 | defpkgbuild(binutils, |
| 3 | #:pkgname, "binutils", |
| 4 | #:pkgver, "2.43.1", |
| 5 | #:pkgrel, 2, |
| 6 | #:pkgdesc, "GNU assembler, linker, and binary utilities for Vinix", |
| 7 | #:arch, [#:x86-64, #:aarch64], |
| 8 | #:url, "https://www.gnu.org/software/binutils/", |
| 9 | #:license, ["GPL-2.0-or-later", "LGPL-2.1-or-later", "BSD-3-Clause"], |
| 10 | #:depends, ["musl", "zlib"], |
| 11 | #:source, ["https://distfiles.alpinelinux.org/distfiles/v3.21/binutils-2.43.1.tar.xz", |
| 12 | "https://raw.githubusercontent.com/alpinelinux/aports/a7de3e63cc8015474a4feadd8bb7c0ecc097b1fa/main/binutils/0001-Revert-PR25882-.gnu.attributes-are-not-checked-for-s.patch", |
| 13 | "https://raw.githubusercontent.com/alpinelinux/aports/a7de3e63cc8015474a4feadd8bb7c0ecc097b1fa/main/binutils/binutils-ld-fix-static-linking.patch", |
| 14 | "https://raw.githubusercontent.com/alpinelinux/aports/a7de3e63cc8015474a4feadd8bb7c0ecc097b1fa/main/binutils/CVE-2025-0840.patch", |
| 15 | "https://raw.githubusercontent.com/alpinelinux/aports/a7de3e63cc8015474a4feadd8bb7c0ecc097b1fa/main/binutils/CVE-2025-1153.patch", |
| 16 | "https://raw.githubusercontent.com/alpinelinux/aports/a7de3e63cc8015474a4feadd8bb7c0ecc097b1fa/main/binutils/CVE-2025-3198.patch"], |
| 17 | #:sha256sums, ["13f74202a3c4c51118b797a39ea4200d3f6cfbe224da6d1d95bb938480132dfd", |
| 18 | "faba7b07cf02de228fa383bcaca339f8e7b70dec10ee3a5e08af5a8b82bc2ae6", |
| 19 | "d5c5581d0ba04ef2e3690f6fb57435bf7ce343f2376fe972a2a693c5429eec9c", |
| 20 | "2ab7a15b40dc7da6b93da96d9ba28b65be89db3338d4481c056a4e98a6be7aa1", |
| 21 | "395450d49cc0059100d33622bc4e22f4c56f9313fd0c8a81c4facb6514536483", |
| 22 | "ffe8d968ef8bfc682421756d24ad465636a359bb0a10a66943647e726f780640"], |
| 23 | #:prepare, fn() { |
| 24 | for-each(fn(p) { run("patch", "--batch", "--fuzz=1", "-p1", "-d", "binutils-2.43.1", "-i", string-append("../", p)) }, |
| 25 | list("0001-Revert-PR25882-.gnu.attributes-are-not-checked-for-s.patch", |
| 26 | "binutils-ld-fix-static-linking.patch", "CVE-2025-0840.patch", "CVE-2025-1153.patch", "CVE-2025-3198.patch")) |
| 27 | }, |
| 28 | #:build, fn() { |
| 29 | prefix := get-environment-variable("CROSS_COMPILE") |
| 30 | tools := if string?(prefix) { prefix } else { "" } |
| 31 | ; When --target is omitted GNU configure uses --host, producing a |
| 32 | ; native assembler and linker for the requested Vinix architecture. |
| 33 | run("env", string-append("AR=", tools, "ar"), string-append("RANLIB=", tools, "ranlib"), string-append("NM=", tools, "nm"), |
| 34 | string-append("AS=", tools, "as"), string-append("LD=", tools, "ld"), "CC_FOR_BUILD=gcc", "CFLAGS=-O2 -std=gnu17", |
| 35 | "CXXCPP=vinix-cc -E -x c++", "PKG_CONFIG=false", "vinix-configure", "binutils-2.43.1/configure", |
| 36 | "--with-sysroot=/", "--with-system-zlib", "--without-zstd", "--disable-gold", |
| 37 | "--disable-gdb", "--disable-gprofng", "--disable-sim", "--disable-nls", "--disable-werror", |
| 38 | "--disable-multilib", "--disable-libctf", "--disable-shared", "--enable-deterministic-archives", |
| 39 | "--enable-new-dtags", "--enable-relro", "--enable-default-hash-style=gnu") |
| 40 | run("make") |
| 41 | }, |
| 42 | #:check, fn() { |
| 43 | for-each(fn(tool) { run("vinix-run", tool, "--version") }, list("gas/as-new", "ld/ld-new", "binutils/objdump")) |
| 44 | }, |
| 45 | #:package, fn() { |
| 46 | run("make", string-append("DESTDIR=", pkgdir()), "install") |
| 47 | run("rm", "-f", string-append(pkgdir(), "/usr/share/info/dir")) |
| 48 | for-each(fn(la) { run("rm", la) }, glob(string-append(pkgdir(), "/usr/lib/*.la"))) |
| 49 | run("install", "-Dm644", "binutils-2.43.1/COPYING3", string-append(pkgdir(), "/usr/share/licenses/binutils/COPYING3")) |
| 50 | }) |
| 51 | |