Subject: [alpine-aports] [PATCH 1/7] main/gcc: import patch from upstream fixing compilation issue on mips

From: Nils Andreas Svee <[email-masked]>
Date: Sun, 10 Dec 2017 01:18:08 +0100

---
 main/gcc/APKBUILD                             |  4 ++-
 main/gcc/fix-linux-header-use-in-libgcc.patch | 44 +++++++++++++++++++++++++++
 2 files changed, 47 insertions(+), 1 deletion(-)
 create mode 100644 main/gcc/fix-linux-header-use-in-libgcc.patch

diff --git a/main/gcc/APKBUILD b/main/gcc/APKBUILD
index 884feeb170..ea3b5b6a7d 100644
--- a/main/gcc/APKBUILD
+++ b/main/gcc/APKBUILD
@@ -185,6 +185,7 @@ source="ftp://gcc.gnu.org/pub/gcc/releases/gcc-${_pkgbase:-$pkgver}/gcc-${_pkgba
 	320-libffi-gnulinux.patch
 
 	fix-rs6000-pie.patch
+	fix-linux-header-use-in-libgcc.patch	
 	"
 
 # we build out-of-tree
@@ -625,4 +626,5 @@ fa44c8158111627aa0e91c43e7cc3aa38642c2041c96532dd4f0932dae4d6f92ea2850b683abcf10
 4b4a0ff306a8ef34ff6e3284fbfca869012164a47ba7cb099085c1dd03e6ca0cdd462f82710e08c9a02895adc7484e4c5eef17b5aa264cf5d978fe8ad78eea93  300-main-gcc-add-musl-s390x-dynamic-linker.patch
 385bc2fa50204f678964e5148c6170f572701dab920fbec8301f505bda34d182cde0adb7da042fee71719e12fb59f59181897f9b1bb4f4716ff59aad46ca1998  310-build-gcj-s390x.patch
 f4ef08454e28c8732db69115e4998ec153399e8d229dd27f923dbdcf57b68128a65640d026cc7f45b58ba8764ab1eb575d4eb6d6dfc550a87a183f8b94e76181  320-libffi-gnulinux.patch
-01c71cd5881fc07ea3b9b980697e89b3ca0fe98502958ceafc3fca18b2604c844e2f457feab711baf8e03f00a5383b0e38aac7eb954034e306f43d4a37f165ed  fix-rs6000-pie.patch"
+01c71cd5881fc07ea3b9b980697e89b3ca0fe98502958ceafc3fca18b2604c844e2f457feab711baf8e03f00a5383b0e38aac7eb954034e306f43d4a37f165ed  fix-rs6000-pie.patch
+34a818d5be67eb1f34e44a80b83c28a9b9c17d37fc9fac639f490d6bb5b53ebe3318140d09c236a17d7c98f5a7792ae3d6cefccda8067a5e942d6305b9d1f87c  fix-linux-header-use-in-libgcc.patch"
diff --git a/main/gcc/fix-linux-header-use-in-libgcc.patch b/main/gcc/fix-linux-header-use-in-libgcc.patch
new file mode 100644
index 0000000000..6dad1b2cad
--- /dev/null
+++ b/main/gcc/fix-linux-header-use-in-libgcc.patch
@@ -0,0 +1,44 @@
+From 9cd4503714c4e596818c4ea8e15905c249b7a319 Mon Sep 17 00:00:00 2001
+From: nsz <nsz@138bc75d-0d04-0410-961f-82ee72b054a4>
+Date: Thu, 25 Aug 2016 14:08:27 +0000
+Subject: [PATCH] [mips] Fix linux header use in libgcc
+
+libgcc/
+	* config/mips/linux-unwind.h: Use sys/syscall.h.
+
+
+
+git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@239759 138bc75d-0d04-0410-961f-82ee72b054a4
+---
+ libgcc/ChangeLog                  | 4 ++++
+ libgcc/config/mips/linux-unwind.h | 2 +-
+ 2 files changed, 5 insertions(+), 1 deletion(-)
+
+diff --git a/libgcc/ChangeLog b/libgcc/ChangeLog
+index b78c4b2..99bd2f1 100644
+--- a/libgcc/ChangeLog
++++ b/libgcc/ChangeLog
+@@ -1,3 +1,7 @@
++2016-08-25  Szabolcs Nagy  <[email-masked]>
++
++	* config/mips/linux-unwind.h: Use sys/syscall.h.
++
+ 2016-08-16  Joseph Myers  <[email-masked]>
+ 
+ 	PR libgcc/77265
+diff --git a/libgcc/config/mips/linux-unwind.h b/libgcc/config/mips/linux-unwind.h
+index bf12de5..4035c121 100644
+--- a/libgcc/config/mips/linux-unwind.h
++++ b/libgcc/config/mips/linux-unwind.h
+@@ -27,7 +27,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+    state data appropriately.  See unwind-dw2.c for the structs.  */
+ 
+ #include <signal.h>
+-#include <asm/unistd.h>
++#include <sys/syscall.h>
+ 
+ /* The third parameter to the signal handler points to something with
+  * this structure defined in asm/ucontext.h, but the name clashes with
+-- 
+2.9.3
+
-- 
2.15.1

---
Unsubscribe:  [email-masked]
Help:         [email-masked]
---

---

From: Nils Andreas Svee <[email-masked]>
Date: Sun, 10 Dec 2017 01:18:09 +0100

---
 main/gcc/APKBUILD | 1 +
 1 file changed, 1 insertion(+)

diff --git a/main/gcc/APKBUILD b/main/gcc/APKBUILD
index ea3b5b6a7d..f452f7c35c 100644
--- a/main/gcc/APKBUILD
+++ b/main/gcc/APKBUILD
@@ -95,6 +95,7 @@ fi
 # libitm has TEXTRELs in ARM build, so disable for now
 case "$CTARGET_ARCH" in
 arm*)		LIBITM=false ;;
+mips*)		LIBITM=false ;;
 esac
 
 # Fortran uses libquadmath if toolchain has __float128
-- 
2.15.1

---

---

From: Nils Andreas Svee <[email-masked]>
Date: Sun, 10 Dec 2017 01:18:10 +0100

---
 main/gcc/APKBUILD | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/main/gcc/APKBUILD b/main/gcc/APKBUILD
index f452f7c35c..83243c2c28 100644
--- a/main/gcc/APKBUILD
+++ b/main/gcc/APKBUILD
@@ -243,6 +243,11 @@ build() {
 	s390x-*-*-*)		_arch_configure="--with-arch=z196 --with-tune=zEC12 --with-zarch --with-long-double-128 --enable-decimal-float";;
 	esac
 
+	case "$CTARGET_ARCH" in
+	mips*)	_hash_style_configure="--with-linker-hash-style=sysv" ;;
+	*)	_hash_style_configure="--with-linker-hash-style=gnu" ;;
+	esac
+
 	case "$CTARGET_LIBC" in
 	musl)
 		# musl does not support mudflap, or libsanitizer
@@ -279,6 +284,7 @@ build() {
 	echo "  libc_configure=$_libc_configure"
 	echo "  cross_configure=$_cross_configure"
 	echo "  bootstrap_configure=$_bootstrap_configure"
+	echo "	hash_style_configure=$_hash_style_configure"
 	echo ""
 
 	mkdir -p "$_builddir"
@@ -306,7 +312,7 @@ build() {
 		$_cross_configure \
 		$_bootstrap_configure \
 		--with-system-zlib \
-		--with-linker-hash-style=gnu
+		$_hash_style_configure
 	make
 }
 
-- 
2.15.1

---

---

From: Nils Andreas Svee <[email-masked]>
Date: Sun, 10 Dec 2017 01:18:11 +0100

---
 main/musl/APKBUILD | 1 +

diff --git a/main/musl/APKBUILD b/main/musl/APKBUILD
index 2c6ca6340e..4e229db9ed 100644
--- a/main/musl/APKBUILD
+++ b/main/musl/APKBUILD
@@ -77,6 +77,7 @@ package() {
 		ppc)		ARCH="powerpc" ;;
 		ppc64*)		ARCH="powerpc64" ;;
 		s390*)		ARCH="s390x" ;;
+		mips64*)	ARCH="mips64" ;;
 		mips*)		ARCH="mips" ;;
 		esac
 
-- 
2.15.1

---

---

From: Nils Andreas Svee <[email-masked]>
Date: Sun, 10 Dec 2017 01:18:12 +0100

---
 community/go/APKBUILD | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/community/go/APKBUILD b/community/go/APKBUILD
index defa3a9ca9..d3cd4eadcb 100644
--- a/community/go/APKBUILD
+++ b/community/go/APKBUILD
@@ -51,6 +51,10 @@ s390x)  export GOARCH="s390x" ;;
 x86)    export GOARCH="386" GO386=387 ;;
 x86_64) export GOARCH="amd64" ;;
 ppc64le) export GOARCH="ppc64le" ;;
+mips)   export GOARCH="mips" ;;
+mips64) export GOARCH="mips64" ;;
+mips64el) export GOARCH="mips64le" ;;
+mipsel) export GOARCH="mipsle" ;;
 *)      die "Unsupported arch" ;;
 esac
 
-- 
2.15.1

---

---

From: Nils Andreas Svee <[email-masked]>
Date: Sun, 10 Dec 2017 01:18:13 +0100

---
 community/go-bootstrap/APKBUILD | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/community/go-bootstrap/APKBUILD b/community/go-bootstrap/APKBUILD
index 423983b13a..f244a5be09 100644
--- a/community/go-bootstrap/APKBUILD
+++ b/community/go-bootstrap/APKBUILD
@@ -51,6 +51,10 @@ build() {
 	x86)	export GOARCH="386" ;;
 	x86_64)	export GOARCH="amd64" ;;
 	arm*)	export GOARCH="arm" ;;
+	mips)   export GOARCH="mips" ;;
+	mips64) export GOARCH="mips64" ;;
+	mips64el) export GOARCH="mips64le" ;;
+	mipsel) export GOARCH="mipsle" ;;
 	*)	return 1 ;;
 	esac
 
-- 
2.15.1

---

---

From: Nils Andreas Svee <[email-masked]>
Date: Sun, 10 Dec 2017 01:18:14 +0100

libffi depends on the asm/sgidefs.h kernel header, so if we're compiling on MIPS,
add linux-headers to makedepends_host
---
 main/libffi/APKBUILD | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/main/libffi/APKBUILD b/main/libffi/APKBUILD
index 36ce7085f8..9ba93bcd2e 100644
--- a/main/libffi/APKBUILD
+++ b/main/libffi/APKBUILD
@@ -15,6 +15,10 @@ source="ftp://sourceware.org/pub/$pkgname/$pkgname-$pkgver.tar.gz
 	pax-dlmmap.patch
 	"
 
+case "$CTARGET_ARCH" in
+mips*)	makedepends_host="linux-headers" ;;
+esac
+
 builddir="$srcdir"/$pkgname-$pkgver
 
 build () {
-- 
2.15.1

---

---

From: Natanael Copa <[email-masked]>
Date: Mon, 18 Dec 2017 16:50:58 +0100

On Sun, 10 Dec 2017 01:18:14 +0100

>  builddir="$srcdir"/$pkgname-$pkgver

I think we can add linux-headers for all architectures, with a comment
that its specifically needed for mips, so we don't need the conditional.

-nc

---