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
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>
-rw-r--r--profiles/arch/amd64/no-multilib/package.use.mask1
-rw-r--r--profiles/arch/amd64/package.use1
-rw-r--r--profiles/arch/amd64/package.use.mask1
-rw-r--r--profiles/arch/x86/package.use.mask1
-rw-r--r--profiles/base/package.use.mask1
-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
8 files changed, 25 insertions, 4 deletions
diff --git a/profiles/arch/amd64/no-multilib/package.use.mask b/profiles/arch/amd64/no-multilib/package.use.mask
index e97fb4228074..adee98f1e014 100644
--- a/profiles/arch/amd64/no-multilib/package.use.mask
+++ b/profiles/arch/amd64/no-multilib/package.use.mask
@@ -4,6 +4,7 @@
# James Le Cuirot <chewi@gentoo.org> (2022-06-25)
# This flag concerns a 32-bit x86-specific problem.
sys-libs/glibc stack-realign
+sys-libs/ncurses stack-realign
# Ben Kohler <bkohler@gentoo.org> (2022-06-07)
# Disable 32bit builds on no-multilib
diff --git a/profiles/arch/amd64/package.use b/profiles/arch/amd64/package.use
index 7b827e562200..c057afab7c94 100644
--- a/profiles/arch/amd64/package.use
+++ b/profiles/arch/amd64/package.use
@@ -5,6 +5,7 @@
# Realign the stack in the 32-bit build for compatibility with older binaries by
# default. This is not the default on x86 because it has a performance cost.
sys-libs/glibc stack-realign
+sys-libs/ncurses stack-realign
# Ben Kohler <bkohler@gentoo.org> (2022-06-07)
# Enable BIOS & UEFI targets by default
diff --git a/profiles/arch/amd64/package.use.mask b/profiles/arch/amd64/package.use.mask
index 189adb55d64f..55790a52e4cd 100644
--- a/profiles/arch/amd64/package.use.mask
+++ b/profiles/arch/amd64/package.use.mask
@@ -20,6 +20,7 @@
# James Le Cuirot <chewi@gentoo.org> (2022-06-25)
# Allow stack to be realigned for compatibility with older 32-bit binaries.
sys-libs/glibc -stack-realign
+sys-libs/ncurses -stack-realign
# Unmask media-libs/libxmp here
media-sound/qmmp -xmp
diff --git a/profiles/arch/x86/package.use.mask b/profiles/arch/x86/package.use.mask
index a618c72fa0ce..996b5d4b6100 100644
--- a/profiles/arch/x86/package.use.mask
+++ b/profiles/arch/x86/package.use.mask
@@ -4,6 +4,7 @@
# James Le Cuirot <chewi@gentoo.org> (2022-06-25)
# Allow stack to be realigned for compatibility with older 32-bit binaries.
sys-libs/glibc -stack-realign
+sys-libs/ncurses -stack-realign
# Anna Vyalkova <cyber+gentoo@sysrq.in> (2022-06-25)
# Unkeyworded test dep
diff --git a/profiles/base/package.use.mask b/profiles/base/package.use.mask
index b97dee8d561f..ecb4772b3a77 100644
--- a/profiles/base/package.use.mask
+++ b/profiles/base/package.use.mask
@@ -9,6 +9,7 @@
# James Le Cuirot <chewi@gentoo.org> (2022-06-25)
# This flag concerns an x86-specific problem.
sys-libs/glibc stack-realign
+sys-libs/ncurses stack-realign
# Matt Turner <mattst88@gentoo.org> (2022-06-21)
# Depends on old spidermonkey:68. Upstream recommends using Duktape or Webkit
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}"