| 1 | ; Alpine 3.21 binutils source and patches, producing native x86-64 ELF tools. |
| 2 | defpkgbuild(binutils, |
| 3 | #:pkgname, "binutils", |
| 4 | #:pkgver, "2.43.1", |
| 5 | #:pkgrel, 1, |
| 6 | #:pkgdesc, "GNU assembler, linker, and binary utilities for Vinix", |
| 7 | #:arch, [#:x86-64], |
| 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 | run("env", "CC=vinix-cc", "AR=ar", "RANLIB=ranlib", "NM=nm", "AS=as", "LD=ld", "CC_FOR_BUILD=gcc", "CFLAGS=-O2 -std=gnu17", "CXX=false", "CXXCPP=vinix-cc -E -x c++", "PKG_CONFIG=false", |
| 30 | "binutils-2.43.1/configure", "--prefix=/usr", "--build=x86_64-pc-linux-gnu", "--host=x86_64-linux-musl", |
| 31 | "--target=x86_64-linux-musl", "--with-sysroot=/", "--with-system-zlib", "--without-zstd", "--disable-gold", |
| 32 | "--disable-gdb", "--disable-gprofng", "--disable-sim", "--disable-nls", "--disable-werror", |
| 33 | "--disable-multilib", "--disable-libctf", "--disable-shared", "--enable-deterministic-archives", |
| 34 | "--enable-new-dtags", "--enable-relro", "--enable-default-hash-style=gnu") |
| 35 | run("make") |
| 36 | }, |
| 37 | #:check, fn() { |
| 38 | root := get-environment-variable("VPAC_MAKEPKG_ROOT") |
| 39 | for-each(fn(tool) { |
| 40 | run(string-append(root, "/lib/ld-musl-x86_64.so.1"), "--library-path", string-append(root, "/usr/lib"), tool, "--version") |
| 41 | }, list("gas/as-new", "ld/ld-new", "binutils/objdump")) |
| 42 | }, |
| 43 | #:package, fn() { |
| 44 | run("make", string-append("DESTDIR=", pkgdir()), "install") |
| 45 | run("rm", "-f", string-append(pkgdir(), "/usr/share/info/dir")) |
| 46 | for-each(fn(la) { run("rm", la) }, glob(string-append(pkgdir(), "/usr/lib/*.la"))) |
| 47 | run("install", "-Dm644", "binutils-2.43.1/COPYING3", string-append(pkgdir(), "/usr/share/licenses/binutils/COPYING3")) |
| 48 | }) |
| 49 | |