From e5587d45fb40f719a79d4711c7ba58e6277de79a Mon Sep 17 00:00:00 2001
From: Nathan Rennie-Waldock <nathan.renniewaldock@gmail.com>
Date: Wed, 21 Jun 2023 01:16:45 +0000
Subject: [PATCH] testing/crust: add Pine64 Plus

---
 testing/crust/APKBUILD            |  9 ++++---
 testing/crust/binutils-2.39.patch | 44 +++++++++++++++++++++++++++++++
 2 files changed, 50 insertions(+), 3 deletions(-)
 create mode 100644 testing/crust/binutils-2.39.patch

diff --git a/testing/crust/APKBUILD b/testing/crust/APKBUILD
index 4d5c2c0e80d6..d21ac800af22 100644
--- a/testing/crust/APKBUILD
+++ b/testing/crust/APKBUILD
@@ -2,15 +2,17 @@
 # Maintainer: Milan P. Stanić <mps@arvanta.net>
 pkgname=crust
 pkgver=0.5
-pkgrel=0
+pkgrel=1
 pkgdesc="libre SCP firmware for Allwinner sunxi SoCs"
 url="https://github.com/crust-firmware/crust"
 arch="aarch64" # only needed for sunxi ARM64 SOCs
 license="BSD-3-clause or GPL-2.0-only"
 options="!check" # no tests
 makedepends="gcc-or1k-elf binutils-or1k-elf dtc bison flex"
-source="https://github.com/crust-firmware/crust/archive/v$pkgver/crust-v$pkgver.tar.gz"
-_platforms="pinebook pinephone pinetab pine_h64"
+source="https://github.com/crust-firmware/crust/archive/v$pkgver/crust-v$pkgver.tar.gz
+	binutils-2.39.patch
+	"
+_platforms="pinebook pinephone pinetab pine_h64 pine64_plus"
 for platform in $_platforms
 do
 	subpackages="$subpackages $pkgname-$platform:_subpackage"
@@ -38,4 +40,5 @@ _subpackage() {
 
 sha512sums="
 1a3811053fd3a27285a1377888ab5b36e9363a2f5818f69966eb7f5214e571475a2a7865b9e1b68387940a9a7e9dc3841d2458544c155aecc5b9da041eb946ba  crust-v0.5.tar.gz
+cd24118ce079200716aa57467b1db83dfaeb637a865439eaefd027df760bf6f4a630df268baba02b571009236e36656a860396dd9c964d4e489a8ba99d4f744e  binutils-2.39.patch
 "
diff --git a/testing/crust/binutils-2.39.patch b/testing/crust/binutils-2.39.patch
new file mode 100644
index 000000000000..40c8c28158c5
--- /dev/null
+++ b/testing/crust/binutils-2.39.patch
@@ -0,0 +1,44 @@
+Patch-Source: https://github.com/crust-firmware/crust/commit/ade7ad311170b8a818741944d97489c887cd673f
+needed with new binutils (2.39+)
+--
+From ade7ad311170b8a818741944d97489c887cd673f Mon Sep 17 00:00:00 2001
+From: Nathan Rennie-Waldock <nathan.renniewaldock@gmail.com>
+Date: Sun, 15 Jan 2023 10:16:08 +0000
+Subject: [PATCH] Makefile: Fix build with binutils 2.39 and newer
+
+Conditionally pass --no-warn-rwx-segments to ld to silence an irrelevant
+warning about segment permissions.
+
+Fixes #207
+
+Signed-off-by: Nathan Rennie-Waldock <nathan.renniewaldock@gmail.com>
+[Samuel: simplifications; expanded commit message]
+Signed-off-by: Samuel Holland <samuel@sholland.org>
+---
+ Makefile | 6 +++++-
+ 1 file changed, 5 insertions(+), 1 deletion(-)
+
+diff --git a/Makefile b/Makefile
+index 2f6b707a..ae559947 100644
+--- a/Makefile
++++ b/Makefile
+@@ -16,6 +16,7 @@ HOSTCC		 = $(HOST_COMPILE)gcc
+ 
+ AR		 = $(CROSS_COMPILE)gcc-ar
+ CC		 = $(CROSS_COMPILE)gcc
++LD		 = $(shell $(CC) -print-prog-name=ld)
+ OBJCOPY		 = $(CROSS_COMPILE)objcopy
+ 
+ LEX		 = lex
+@@ -83,7 +84,10 @@ LDFLAGS		 = -nostdlib \
+ 		   -Wl,--fatal-warnings \
+ 		   -Wl,--gc-sections \
+ 		   -Wl,--no-dynamic-linker \
+-		   -Wl,--no-undefined
++		   -Wl,--no-undefined \
++		   $(call ld-option,--no-warn-rwx-segments)
++
++ld-option	 = $(shell $(LD) -v $1 >/dev/null 2>&1 && printf '%s' '-Wl,$1')
+ 
+ ###############################################################################
+ 
-- 
GitLab