Subject: [alpine-devel] main/gcc: fix Ada -fno-stack-check handling

From: "Leslie P. Polzer | PORT ZERO" <[email-masked]>
Date: Sat, 23 Nov 2013 14:26:39 +0100

Hi,

the old hack for this was probably too hacky; at least it
no longer worked for me when cross-compiling to armhf-musl.
Attached changeset replaces it with a cleaner approach that
works.

Cheers,

  Leslie

-- 
Dipl.Ing.(BA) Leslie P. Polzer | CTO - PORT ZERO
UG (haftungsbeschränkt)
Softwareentwicklung & IT Engineering
Adalbertstraße 7/8
10999 Berlin
Tel.: +49 (0)30 - 69 200 907 - 0
Fax: +49 (0)30 - 69 200 907 - 9
http://www.port-zero.com
>From df791efe3767f42f4da6cf0ff6541c4b4518973a Mon Sep 17 00:00:00 2001
From: "Leslie P. Polzer" <[email-masked]>
Date: Sat, 23 Nov 2013 13:59:16 +0100
Subject: [PATCH] main/gcc: update fix to compile Ada with -fno-stack-check.

---
 main/gcc/APKBUILD | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/main/gcc/APKBUILD b/main/gcc/APKBUILD
index 45c7609..ae7b1f4 100644
--- a/main/gcc/APKBUILD
+++ b/main/gcc/APKBUILD
@@ -13,7 +13,7 @@ _cross=""
 	&& _cross="-$CTARGET"
 
 pkgname="$pkgname$_cross"
-pkgrel=1
+pkgrel=2
 pkgdesc="The GNU Compiler Collection"
 url="http://gcc.gnu.org"
 arch="all"
@@ -228,10 +228,7 @@ prepare() {
 	# fix ada bootstrap
 	# piepatches adds -fstack-check to spec which breaks ada bootstrap
 	# TODO: upstream this to piepatches
-	sed -i -e 's/stage1_cflags="$stage1_cflags -fno-stack-protector"/stage1_cflags="$stage1_cflags -fno-stack-protector -fno-stack-check"/g' \
-		configure
-	sed -i -e 's/^ESP_NOSSP_CFLAGS = -fno-stack-protector$/ESP_NOSSP_CFLAGS = -fno-stack-protector -fno-stack-check/g' \
-		Makefile.in
+	export ADA_CFLAGS='-fno-stack-check'
 
 	# genautomata crashes with a "Bus Error" when compiled with PIC
 	# mostly affecting cross-builds as on native build bootstrapping
-- 
1.8.4.3

---

From: Timo Teras <[email-masked]>
Date: Sat, 23 Nov 2013 18:07:35 +0200

On Sat, 23 Nov 2013 14:26:39 +0100

>  	# piepatches adds -fstack-check to spec which breaks ada
> bootstrap # TODO: upstream this to piepatches
> -	sed -i -e 's/stage1_cflags="$stage1_cflags
> -fno-stack-protector"/stage1_cflags="$stage1_cflags
> -fno-stack-protector -fno-stack-check"/g' \
> -		configure
> -	sed -i -e 's/^ESP_NOSSP_CFLAGS =
> -fno-stack-protector$/ESP_NOSSP_CFLAGS = -fno-stack-protector
> -fno-stack-check/g' \
> -		Makefile.in
>  	# genautomata crashes with a "Bus Error" when compiled with
> PIC # mostly affecting cross-builds as on native build bootstrapping

If you set environment vars, it should be in build() or in the global
block. Setting those in prepare() only breaks "abuild build".

But if a full bootstrap works otherwise, this probably is a good idea.

Thanks,
 Timo

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

---

From: "Leslie P. Polzer | PORT ZERO" <[email-masked]>
Date: Sun, 24 Nov 2013 16:32:24 +0100

> block. Setting those in prepare() only breaks "abuild build".

Duh, thanks. Good we have peer review.

Modified patch attached.

  Leslie

>From ce5a772e9b7cc625579e592e83d7d58bf1ade038 Mon Sep 17 00:00:00 2001
From: "Leslie P. Polzer" <[email-masked]>
Date: Sun, 24 Nov 2013 12:41:20 +0100
Subject: [PATCH] main/gcc: update fix to compile Ada with -fno-stack-check.

---
 main/gcc/APKBUILD | 15 ++++++---------
 1 file changed, 6 insertions(+), 9 deletions(-)

diff --git a/main/gcc/APKBUILD b/main/gcc/APKBUILD
index 45c7609..1aa6003 100644
--- a/main/gcc/APKBUILD
+++ b/main/gcc/APKBUILD
@@ -13,7 +13,7 @@ _cross=""
 	&& _cross="-$CTARGET"
 
 pkgname="$pkgname$_cross"
-pkgrel=1
+pkgrel=2
 pkgdesc="The GNU Compiler Collection"
 url="http://gcc.gnu.org"
 arch="all"
@@ -225,14 +225,6 @@ prepare() {
 		return 1
 	fi
 
-	# fix ada bootstrap
-	# piepatches adds -fstack-check to spec which breaks ada bootstrap
-	# TODO: upstream this to piepatches
-	sed -i -e 's/stage1_cflags="$stage1_cflags -fno-stack-protector"/stage1_cflags="$stage1_cflags -fno-stack-protector -fno-stack-check"/g' \
-		configure
-	sed -i -e 's/^ESP_NOSSP_CFLAGS = -fno-stack-protector$/ESP_NOSSP_CFLAGS = -fno-stack-protector -fno-stack-check/g' \
-		Makefile.in
-
 	# genautomata crashes with a "Bus Error" when compiled with PIC
 	# mostly affecting cross-builds as on native build bootstrapping
 	# somehow seems to build proper genautomata
@@ -357,6 +349,11 @@ build() {
 		--with-system-zlib \
 		|| return 1
 
+	# fix ada bootstrap
+	# piepatches adds -fstack-check to spec which breaks ada bootstrap
+	# TODO: upstream this to piepatches
+	export ADA_CFLAGS='-fno-stack-check'
+
 	make || return 1
 }
 
-- 
1.8.4.3

---

From: Timo Teras <[email-masked]>
Date: Fri, 29 Nov 2013 08:50:56 +0200

On Sun, 24 Nov 2013 16:32:24 +0100
"Leslie P. Polzer | PORT ZERO" <[email-masked]> wrote:

> > If you set environment vars, it should be in build() or in the
> > global block. Setting those in prepare() only breaks "abuild build".
> 

Applied. Thanks.

---