From b4236bea5ac8447ac82ab1a0985e18d63aaf6373 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=B6ren=20Tempel?= <soeren+git@soeren-tempel.net>
Date: Fri, 23 Oct 2020 19:02:20 +0200
Subject: [PATCH] community/openocd: Fix build with recent gcc

---
 community/openocd/APKBUILD        |  8 +++++---
 community/openocd/fix-build.patch | 15 +++++++++++++++
 2 files changed, 20 insertions(+), 3 deletions(-)
 create mode 100644 community/openocd/fix-build.patch

diff --git a/community/openocd/APKBUILD b/community/openocd/APKBUILD
index 81d78502109b..84cb35851c3e 100644
--- a/community/openocd/APKBUILD
+++ b/community/openocd/APKBUILD
@@ -2,14 +2,15 @@
 # Maintainer: Sören Tempel <soeren+alpine@soeren-tempel.net>
 pkgname=openocd
 pkgver=0.10.0
-pkgrel=4
+pkgrel=5
 pkgdesc="Free and Open On-Chip Debugging, In-System Programming and Boundary-Scan Testing"
 url="http://openocd.org/"
 arch="all"
 license="GPL-2.0-only,GPL-2.0-or-later,GPL-3.0-only"
 makedepends="libftdi1-dev libusb-dev hidapi-dev libtool"
 subpackages="$pkgname-dev $pkgname-doc"
-source="https://downloads.sourceforge.net/project/openocd/openocd/$pkgver/openocd-$pkgver.tar.bz2"
+source="https://downloads.sourceforge.net/project/openocd/openocd/$pkgver/openocd-$pkgver.tar.bz2
+	fix-build.patch"
 
 build() {
 	./configure \
@@ -34,4 +35,5 @@ package() {
 	make DESTDIR="$pkgdir" install
 }
 
-sha512sums="6c890c86c3339da49bd529e8674ca62bc7fce4a2a17798dcc5d70b4f7628b640d856651170a3f7e2e2a120989066e84d8439b56ff42ff2bd72446f9af0f28ba2  openocd-0.10.0.tar.bz2"
+sha512sums="6c890c86c3339da49bd529e8674ca62bc7fce4a2a17798dcc5d70b4f7628b640d856651170a3f7e2e2a120989066e84d8439b56ff42ff2bd72446f9af0f28ba2  openocd-0.10.0.tar.bz2
+f73aae2304d20ac0f5a9bb1db70705f555e3fec5e38fd97597c5b77ec114c7f8a8932d720e9c56e89dde88ea785da2d5fdc6adabc9b5bd1ed4109485cc2df867  fix-build.patch"
diff --git a/community/openocd/fix-build.patch b/community/openocd/fix-build.patch
new file mode 100644
index 000000000000..9fc9940ad5b5
--- /dev/null
+++ b/community/openocd/fix-build.patch
@@ -0,0 +1,15 @@
+This fixes multiple definitions of the bitbang_swd symbol and thereby
+prevents a build failure with recent GCC versions.
+
+diff -upr openocd-0.10.0.orig/src/jtag/drivers/bitbang.h openocd-0.10.0/src/jtag/drivers/bitbang.h
+--- openocd-0.10.0.orig/src/jtag/drivers/bitbang.h	2016-12-25 15:12:55.000000000 +0100
++++ openocd-0.10.0/src/jtag/drivers/bitbang.h	2020-10-22 19:01:07.914466540 +0200
+@@ -35,7 +35,7 @@ struct bitbang_interface {
+ 	void (*swdio_drive)(bool on);
+ };
+ 
+-const struct swd_driver bitbang_swd;
++extern const struct swd_driver bitbang_swd;
+ 
+ extern bool swd_mode;
+ 
-- 
GitLab