commit:     bac67bd1ecdf620db1b0dc03b63e66d978ff7325
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Wed Nov 23 04:24:31 2022 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Wed Nov 23 04:24:31 2022 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=bac67bd1

sys-libs/zlib: fix build on sparc

Closes: https://bugs.gentoo.org/879883
Signed-off-by: Sam James <sam <AT> gentoo.org>

 ...-off-RWX-segment-warnings-on-sparc-system.patch | 56 ++++++++++++++++++++++
 sys-libs/zlib/zlib-1.2.13-r1.ebuild                |  9 +++-
 2 files changed, 64 insertions(+), 1 deletion(-)

diff --git 
a/sys-libs/zlib/files/zlib-1.2.13-Revert-Turn-off-RWX-segment-warnings-on-sparc-system.patch
 
b/sys-libs/zlib/files/zlib-1.2.13-Revert-Turn-off-RWX-segment-warnings-on-sparc-system.patch
new file mode 100644
index 000000000000..48d58acaaf7f
--- /dev/null
+++ 
b/sys-libs/zlib/files/zlib-1.2.13-Revert-Turn-off-RWX-segment-warnings-on-sparc-system.patch
@@ -0,0 +1,56 @@
+From 2ad2713e6cb9166dcede9a020f6913b8189ff0c6 Mon Sep 17 00:00:00 2001
+From: Sam James <s...@gentoo.org>
+Date: Wed, 23 Nov 2022 04:17:16 +0000
+Subject: [PATCH] Revert "Turn off RWX segment warnings on sparc systems."
+
+This breaks building on sparc with older binutils.
+
+This reverts commit 29fd715fd0bdaffee21e2d2d37be8c5a6ac67ee4.
+--- a/Makefile.in
++++ b/Makefile.in
+@@ -22,7 +22,7 @@ CFLAGS=-O
+ 
+ SFLAGS=-O
+ LDFLAGS=
+-TEST_LDFLAGS=$(LDFLAGS) -L. libz.a
++TEST_LDFLAGS=-L. libz.a
+ LDSHARED=$(CC)
+ CPP=$(CC) -E
+ 
+@@ -288,10 +288,10 @@ minigzip$(EXE): minigzip.o $(STATICLIB)
+       $(CC) $(CFLAGS) -o $@ minigzip.o $(TEST_LDFLAGS)
+ 
+ examplesh$(EXE): example.o $(SHAREDLIBV)
+-      $(CC) $(CFLAGS) -o $@ example.o $(LDFLAGS) -L. $(SHAREDLIBV)
++      $(CC) $(CFLAGS) -o $@ example.o -L. $(SHAREDLIBV)
+ 
+ minigzipsh$(EXE): minigzip.o $(SHAREDLIBV)
+-      $(CC) $(CFLAGS) -o $@ minigzip.o $(LDFLAGS) -L. $(SHAREDLIBV)
++      $(CC) $(CFLAGS) -o $@ minigzip.o -L. $(SHAREDLIBV)
+ 
+ example64$(EXE): example64.o $(STATICLIB)
+       $(CC) $(CFLAGS) -o $@ example64.o $(TEST_LDFLAGS)
+--- a/configure
++++ b/configure
+@@ -33,10 +33,7 @@ fi
+ # set command prefix for cross-compilation
+ if [ -n "${CHOST}" ]; then
+     uname=${CHOST}
+-    mname=${CHOST}
+     CROSS_PREFIX="${CHOST}-"
+-else
+-    mname=`(uname -a || echo unknown) 2>/dev/null`
+ fi
+ 
+ # destination name for static library
+@@ -223,10 +220,6 @@ if test "$gcc" -eq 1 && ($cc -c $test.c) >> configure.log 
2>&1; then
+   fi
+   case "$uname" in
+   Linux* | linux* | *-linux* | GNU | GNU/* | solaris*)
+-        case "$mname" in
+-        *sparc*)
+-            LDFLAGS="${LDFLAGS} -Wl,--no-warn-rwx-segments" ;;
+-        esac
+         LDSHARED=${LDSHARED-"$cc -shared 
-Wl,-soname,libz.so.1,--version-script,${SRCDIR}zlib.map"} ;;
+   *BSD | *bsd* | DragonFly)
+         LDSHARED=${LDSHARED-"$cc -shared 
-Wl,-soname,libz.so.1,--version-script,${SRCDIR}zlib.map"}

diff --git a/sys-libs/zlib/zlib-1.2.13-r1.ebuild 
b/sys-libs/zlib/zlib-1.2.13-r1.ebuild
index ee60673a59b8..50b767a0ef31 100644
--- a/sys-libs/zlib/zlib-1.2.13-r1.ebuild
+++ b/sys-libs/zlib/zlib-1.2.13-r1.ebuild
@@ -6,7 +6,7 @@ EAPI=8
 # Worth keeping an eye on 'develop' branch upstream for possible backports.
 AUTOTOOLS_AUTO_DEPEND="no"
 VERIFY_SIG_OPENPGP_KEY_PATH="${BROOT}"/usr/share/openpgp-keys/madler.asc
-inherit autotools multilib-minimal usr-ldscript verify-sig
+inherit autotools multilib-minimal flag-o-matic usr-ldscript verify-sig
 
 CYGWINPATCHES=(
        
"https://github.com/cygwinports/zlib/raw/22a3462cae33a82ad966ea0a7d6cbe8fc1368fec/1.2.11-gzopen_w.patch
 -> ${PN}-1.2.11-cygwin-gzopen_w.patch"
@@ -43,6 +43,9 @@ PATCHES=(
 
        # Respect LDFLAGS during configure tests. Pending upstream
        "${FILESDIR}"/${PN}-1.2.13-use-LDFLAGS-in-configure.patch
+
+       # Fix building on sparc with older binutils, we pass it in ebuild 
instead
+       
"${FILESDIR}"/${PN}-1.2.13-Revert-Turn-off-RWX-segment-warnings-on-sparc-system.patch
 )
 
 src_prepare() {
@@ -85,6 +88,10 @@ src_prepare() {
 echoit() { echo "$@"; "$@"; }
 
 multilib_src_configure() {
+       # We pass manually instead of relying on the configure script/makefile
+       # because it would pass it even for older binutils.
+       use sparc && append-flags $(test-flags-CCLD -Wl,--no-warn-rwx-segments)
+
        case ${CHOST} in
                *-mingw*|mingw*|*-cygwin*)
                        ;;

Reply via email to