summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam James <sam@gentoo.org>2022-06-25 22:36:50 +0100
committerSam James <sam@gentoo.org>2022-06-25 22:39:41 +0100
commit020b1514bcb86d96700d81ff5ad82ec698b45311 (patch)
treeba5d012592ba4145babcb435c5557c43729fc2ad /sys-libs
parentsys-libs/glibc: slight->some for stack-realign description (diff)
downloadgentoo-020b1514bcb86d96700d81ff5ad82ec698b45311.tar.gz
gentoo-020b1514bcb86d96700d81ff5ad82ec698b45311.tar.bz2
gentoo-020b1514bcb86d96700d81ff5ad82ec698b45311.zip
sys-libs/ncurses: Add stack-realign flag for compat with old 32-bit x86 binaries
Older 32-bit x86 binaries aligned the stack to 4 bytes, whereas modern binaries align to 16 bytes. These older binaries sometimes segfault when newer libraries use SSE instructions. This is becoming increasingly common. Applying the -mstackrealign flag to the 32-bit build works around the issue but at a performance cost. Other popular distributions always apply this. [sam: There's no good choices here. As Ionen pointed out (I'd missed any reports of this), this ends up getting worse with GCC 12's default-on vectorisation at -O2. Let's make it optional for now for 32-bit/x86 (irrelevant for other arches, it's specific to x86 ABI). ncurses is going to need similar treatment. If we end up having to do this for far more packages, we may revisit and e.g. just append-flags in ebuilds for right ABI and tell users to set -mno-stackrealign, or similar. Another option would be to set this globally by default (again, this is only ever for x86), but it'd possibly be a big performance hit (and bad enough doing it in glibc, but it's unavoidable). The only saving grace here is that there aren't _that_ many libraries with such longevity & ABI stability from back then that older applications are using.] Bug: https://bugs.gentoo.org/616402 Bug: https://github.com/taviso/123elf/issues/12 See: 02aa6328a720c Signed-off-by: Sam James <sam@gentoo.org>
Diffstat (limited to 'sys-libs')
-rw-r--r--sys-libs/ncurses/metadata.xml4
-rw-r--r--sys-libs/ncurses/ncurses-6.3_p20220423-r1.ebuild10
-rw-r--r--sys-libs/ncurses/ncurses-6.3_p20220423.ebuild10
3 files changed, 20 insertions, 4 deletions
diff --git a/sys-libs/ncurses/metadata.xml b/sys-libs/ncurses/metadata.xml
index 27fbeede9c53..51b044682ce5 100644
--- a/sys-libs/ncurses/metadata.xml
+++ b/sys-libs/ncurses/metadata.xml
@@ -12,6 +12,10 @@
library (libtinfo) -- usually needed only for binary packages -- but
it is binary compatible in either mode
</flag>
+ <flag name="stack-realign">
+ Realign the stack in the 32-bit build for compatibility with older binaries at some performance cost.
+ Avoids crashes in older 32-bit binaries. Only affects x86/32-bit multilib builds on amd64.
+ </flag>
<flag name="trace">Enable test trace() support in ncurses calls</flag>
</use>
<upstream>
diff --git a/sys-libs/ncurses/ncurses-6.3_p20220423-r1.ebuild b/sys-libs/ncurses/ncurses-6.3_p20220423-r1.ebuild
index 8ef705fe2b52..1a8b50aab67f 100644
--- a/sys-libs/ncurses/ncurses-6.3_p20220423-r1.ebuild
+++ b/sys-libs/ncurses/ncurses-6.3_p20220423-r1.ebuild
@@ -4,7 +4,7 @@
EAPI=7
VERIFY_SIG_OPENPGP_KEY_PATH="${BROOT}"/usr/share/openpgp-keys/thomasdickey.asc
-inherit toolchain-funcs multilib multilib-minimal preserve-libs usr-ldscript verify-sig
+inherit flag-o-matic toolchain-funcs multilib multilib-minimal preserve-libs usr-ldscript verify-sig
MY_PV="${PV:0:3}"
MY_P="${PN}-${MY_PV}"
@@ -76,7 +76,7 @@ LICENSE="MIT"
# The subslot reflects the SONAME.
SLOT="0/6"
#KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~loong ~m68k ~mips ~ppc ~ppc64 ~riscv ~s390 ~sparc ~x86 ~x64-cygwin ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris"
-IUSE="ada +cxx debug doc gpm minimal profile static-libs test tinfo trace"
+IUSE="ada +cxx debug doc gpm minimal profile +stack-realign static-libs test tinfo trace"
RESTRICT="!test? ( test )"
DEPEND="gpm? ( sys-libs/gpm[${MULTILIB_USEDEP}] )"
@@ -163,6 +163,12 @@ src_configure() {
}
multilib_src_configure() {
+ if [[ ${ABI} == x86 ]] ; then
+ # For compatibility with older binaries at slight performance cost.
+ # bug #616402
+ use stack-realign && append-flags -mstackrealign
+ fi
+
local t
for t in "${NCURSES_TARGETS[@]}" ; do
do_configure "${t}"
diff --git a/sys-libs/ncurses/ncurses-6.3_p20220423.ebuild b/sys-libs/ncurses/ncurses-6.3_p20220423.ebuild
index 338c3216c194..4b4374096d7a 100644
--- a/sys-libs/ncurses/ncurses-6.3_p20220423.ebuild
+++ b/sys-libs/ncurses/ncurses-6.3_p20220423.ebuild
@@ -4,7 +4,7 @@
EAPI=7
VERIFY_SIG_OPENPGP_KEY_PATH="${BROOT}"/usr/share/openpgp-keys/thomasdickey.asc
-inherit toolchain-funcs multilib multilib-minimal preserve-libs usr-ldscript verify-sig
+inherit flag-o-matic toolchain-funcs multilib multilib-minimal preserve-libs usr-ldscript verify-sig
MY_PV="${PV:0:3}"
MY_P="${PN}-${MY_PV}"
@@ -76,7 +76,7 @@ LICENSE="MIT"
# The subslot reflects the SONAME.
SLOT="0/6"
KEYWORDS="~alpha amd64 arm arm64 hppa ~ia64 ~loong ~m68k ~mips ppc ppc64 ~riscv ~s390 sparc x86 ~x64-cygwin ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris"
-IUSE="ada +cxx debug doc gpm minimal profile static-libs test tinfo trace"
+IUSE="ada +cxx debug doc gpm minimal profile +stack-realign static-libs test tinfo trace"
RESTRICT="!test? ( test )"
DEPEND="gpm? ( sys-libs/gpm[${MULTILIB_USEDEP}] )"
@@ -163,6 +163,12 @@ src_configure() {
}
multilib_src_configure() {
+ if [[ ${ABI} == x86 ]] ; then
+ # For compatibility with older binaries at slight performance cost.
+ # bug #616402
+ use stack-realign && append-flags -mstackrealign
+ fi
+
local t
for t in "${NCURSES_TARGETS[@]}" ; do
do_configure "${t}"