1 |
commit: 020b1514bcb86d96700d81ff5ad82ec698b45311 |
2 |
Author: Sam James <sam <AT> gentoo <DOT> org> |
3 |
AuthorDate: Sat Jun 25 21:36:50 2022 +0000 |
4 |
Commit: Sam James <sam <AT> gentoo <DOT> org> |
5 |
CommitDate: Sat Jun 25 21:39:41 2022 +0000 |
6 |
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=020b1514 |
7 |
|
8 |
sys-libs/ncurses: Add stack-realign flag for compat with old 32-bit x86 binaries |
9 |
|
10 |
Older 32-bit x86 binaries aligned the stack to 4 bytes, whereas modern |
11 |
binaries align to 16 bytes. These older binaries sometimes segfault when |
12 |
newer libraries use SSE instructions. This is becoming increasingly |
13 |
common. Applying the -mstackrealign flag to the 32-bit build works |
14 |
around the issue but at a performance cost. Other popular |
15 |
distributions always apply this. |
16 |
|
17 |
[sam: There's no good choices here. As Ionen pointed out (I'd missed |
18 |
any reports of this), this ends up getting worse with GCC 12's |
19 |
default-on vectorisation at -O2. Let's make it optional for now for |
20 |
32-bit/x86 (irrelevant for other arches, it's specific to x86 ABI). |
21 |
|
22 |
ncurses is going to need similar treatment. If we end up having |
23 |
to do this for far more packages, we may revisit and e.g. |
24 |
just append-flags in ebuilds for right ABI and tell users |
25 |
to set -mno-stackrealign, or similar. |
26 |
|
27 |
Another option would be to set this globally by default (again, |
28 |
this is only ever for x86), but it'd possibly be a big performance |
29 |
hit (and bad enough doing it in glibc, but it's unavoidable). |
30 |
|
31 |
The only saving grace here is that there aren't _that_ many |
32 |
libraries with such longevity & ABI stability from back then |
33 |
that older applications are using.] |
34 |
|
35 |
Bug: https://bugs.gentoo.org/616402 |
36 |
Bug: https://github.com/taviso/123elf/issues/12 |
37 |
See: 02aa6328a720c |
38 |
Signed-off-by: Sam James <sam <AT> gentoo.org> |
39 |
|
40 |
profiles/arch/amd64/no-multilib/package.use.mask | 1 + |
41 |
profiles/arch/amd64/package.use | 1 + |
42 |
profiles/arch/amd64/package.use.mask | 1 + |
43 |
profiles/arch/x86/package.use.mask | 1 + |
44 |
profiles/base/package.use.mask | 1 + |
45 |
sys-libs/ncurses/metadata.xml | 4 ++++ |
46 |
sys-libs/ncurses/ncurses-6.3_p20220423-r1.ebuild | 10 ++++++++-- |
47 |
sys-libs/ncurses/ncurses-6.3_p20220423.ebuild | 10 ++++++++-- |
48 |
8 files changed, 25 insertions(+), 4 deletions(-) |
49 |
|
50 |
diff --git a/profiles/arch/amd64/no-multilib/package.use.mask b/profiles/arch/amd64/no-multilib/package.use.mask |
51 |
index e97fb4228074..adee98f1e014 100644 |
52 |
--- a/profiles/arch/amd64/no-multilib/package.use.mask |
53 |
+++ b/profiles/arch/amd64/no-multilib/package.use.mask |
54 |
@@ -4,6 +4,7 @@ |
55 |
# James Le Cuirot <chewi@g.o> (2022-06-25) |
56 |
# This flag concerns a 32-bit x86-specific problem. |
57 |
sys-libs/glibc stack-realign |
58 |
+sys-libs/ncurses stack-realign |
59 |
|
60 |
# Ben Kohler <bkohler@g.o> (2022-06-07) |
61 |
# Disable 32bit builds on no-multilib |
62 |
|
63 |
diff --git a/profiles/arch/amd64/package.use b/profiles/arch/amd64/package.use |
64 |
index 7b827e562200..c057afab7c94 100644 |
65 |
--- a/profiles/arch/amd64/package.use |
66 |
+++ b/profiles/arch/amd64/package.use |
67 |
@@ -5,6 +5,7 @@ |
68 |
# Realign the stack in the 32-bit build for compatibility with older binaries by |
69 |
# default. This is not the default on x86 because it has a performance cost. |
70 |
sys-libs/glibc stack-realign |
71 |
+sys-libs/ncurses stack-realign |
72 |
|
73 |
# Ben Kohler <bkohler@g.o> (2022-06-07) |
74 |
# Enable BIOS & UEFI targets by default |
75 |
|
76 |
diff --git a/profiles/arch/amd64/package.use.mask b/profiles/arch/amd64/package.use.mask |
77 |
index 189adb55d64f..55790a52e4cd 100644 |
78 |
--- a/profiles/arch/amd64/package.use.mask |
79 |
+++ b/profiles/arch/amd64/package.use.mask |
80 |
@@ -20,6 +20,7 @@ |
81 |
# James Le Cuirot <chewi@g.o> (2022-06-25) |
82 |
# Allow stack to be realigned for compatibility with older 32-bit binaries. |
83 |
sys-libs/glibc -stack-realign |
84 |
+sys-libs/ncurses -stack-realign |
85 |
|
86 |
# Unmask media-libs/libxmp here |
87 |
media-sound/qmmp -xmp |
88 |
|
89 |
diff --git a/profiles/arch/x86/package.use.mask b/profiles/arch/x86/package.use.mask |
90 |
index a618c72fa0ce..996b5d4b6100 100644 |
91 |
--- a/profiles/arch/x86/package.use.mask |
92 |
+++ b/profiles/arch/x86/package.use.mask |
93 |
@@ -4,6 +4,7 @@ |
94 |
# James Le Cuirot <chewi@g.o> (2022-06-25) |
95 |
# Allow stack to be realigned for compatibility with older 32-bit binaries. |
96 |
sys-libs/glibc -stack-realign |
97 |
+sys-libs/ncurses -stack-realign |
98 |
|
99 |
# Anna Vyalkova <cyber+gentoo@×××××.in> (2022-06-25) |
100 |
# Unkeyworded test dep |
101 |
|
102 |
diff --git a/profiles/base/package.use.mask b/profiles/base/package.use.mask |
103 |
index b97dee8d561f..ecb4772b3a77 100644 |
104 |
--- a/profiles/base/package.use.mask |
105 |
+++ b/profiles/base/package.use.mask |
106 |
@@ -9,6 +9,7 @@ |
107 |
# James Le Cuirot <chewi@g.o> (2022-06-25) |
108 |
# This flag concerns an x86-specific problem. |
109 |
sys-libs/glibc stack-realign |
110 |
+sys-libs/ncurses stack-realign |
111 |
|
112 |
# Matt Turner <mattst88@g.o> (2022-06-21) |
113 |
# Depends on old spidermonkey:68. Upstream recommends using Duktape or Webkit |
114 |
|
115 |
diff --git a/sys-libs/ncurses/metadata.xml b/sys-libs/ncurses/metadata.xml |
116 |
index 27fbeede9c53..51b044682ce5 100644 |
117 |
--- a/sys-libs/ncurses/metadata.xml |
118 |
+++ b/sys-libs/ncurses/metadata.xml |
119 |
@@ -12,6 +12,10 @@ |
120 |
library (libtinfo) -- usually needed only for binary packages -- but |
121 |
it is binary compatible in either mode |
122 |
</flag> |
123 |
+ <flag name="stack-realign"> |
124 |
+ Realign the stack in the 32-bit build for compatibility with older binaries at some performance cost. |
125 |
+ Avoids crashes in older 32-bit binaries. Only affects x86/32-bit multilib builds on amd64. |
126 |
+ </flag> |
127 |
<flag name="trace">Enable test trace() support in ncurses calls</flag> |
128 |
</use> |
129 |
<upstream> |
130 |
|
131 |
diff --git a/sys-libs/ncurses/ncurses-6.3_p20220423-r1.ebuild b/sys-libs/ncurses/ncurses-6.3_p20220423-r1.ebuild |
132 |
index 8ef705fe2b52..1a8b50aab67f 100644 |
133 |
--- a/sys-libs/ncurses/ncurses-6.3_p20220423-r1.ebuild |
134 |
+++ b/sys-libs/ncurses/ncurses-6.3_p20220423-r1.ebuild |
135 |
@@ -4,7 +4,7 @@ |
136 |
EAPI=7 |
137 |
|
138 |
VERIFY_SIG_OPENPGP_KEY_PATH="${BROOT}"/usr/share/openpgp-keys/thomasdickey.asc |
139 |
-inherit toolchain-funcs multilib multilib-minimal preserve-libs usr-ldscript verify-sig |
140 |
+inherit flag-o-matic toolchain-funcs multilib multilib-minimal preserve-libs usr-ldscript verify-sig |
141 |
|
142 |
MY_PV="${PV:0:3}" |
143 |
MY_P="${PN}-${MY_PV}" |
144 |
@@ -76,7 +76,7 @@ LICENSE="MIT" |
145 |
# The subslot reflects the SONAME. |
146 |
SLOT="0/6" |
147 |
#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" |
148 |
-IUSE="ada +cxx debug doc gpm minimal profile static-libs test tinfo trace" |
149 |
+IUSE="ada +cxx debug doc gpm minimal profile +stack-realign static-libs test tinfo trace" |
150 |
RESTRICT="!test? ( test )" |
151 |
|
152 |
DEPEND="gpm? ( sys-libs/gpm[${MULTILIB_USEDEP}] )" |
153 |
@@ -163,6 +163,12 @@ src_configure() { |
154 |
} |
155 |
|
156 |
multilib_src_configure() { |
157 |
+ if [[ ${ABI} == x86 ]] ; then |
158 |
+ # For compatibility with older binaries at slight performance cost. |
159 |
+ # bug #616402 |
160 |
+ use stack-realign && append-flags -mstackrealign |
161 |
+ fi |
162 |
+ |
163 |
local t |
164 |
for t in "${NCURSES_TARGETS[@]}" ; do |
165 |
do_configure "${t}" |
166 |
|
167 |
diff --git a/sys-libs/ncurses/ncurses-6.3_p20220423.ebuild b/sys-libs/ncurses/ncurses-6.3_p20220423.ebuild |
168 |
index 338c3216c194..4b4374096d7a 100644 |
169 |
--- a/sys-libs/ncurses/ncurses-6.3_p20220423.ebuild |
170 |
+++ b/sys-libs/ncurses/ncurses-6.3_p20220423.ebuild |
171 |
@@ -4,7 +4,7 @@ |
172 |
EAPI=7 |
173 |
|
174 |
VERIFY_SIG_OPENPGP_KEY_PATH="${BROOT}"/usr/share/openpgp-keys/thomasdickey.asc |
175 |
-inherit toolchain-funcs multilib multilib-minimal preserve-libs usr-ldscript verify-sig |
176 |
+inherit flag-o-matic toolchain-funcs multilib multilib-minimal preserve-libs usr-ldscript verify-sig |
177 |
|
178 |
MY_PV="${PV:0:3}" |
179 |
MY_P="${PN}-${MY_PV}" |
180 |
@@ -76,7 +76,7 @@ LICENSE="MIT" |
181 |
# The subslot reflects the SONAME. |
182 |
SLOT="0/6" |
183 |
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" |
184 |
-IUSE="ada +cxx debug doc gpm minimal profile static-libs test tinfo trace" |
185 |
+IUSE="ada +cxx debug doc gpm minimal profile +stack-realign static-libs test tinfo trace" |
186 |
RESTRICT="!test? ( test )" |
187 |
|
188 |
DEPEND="gpm? ( sys-libs/gpm[${MULTILIB_USEDEP}] )" |
189 |
@@ -163,6 +163,12 @@ src_configure() { |
190 |
} |
191 |
|
192 |
multilib_src_configure() { |
193 |
+ if [[ ${ABI} == x86 ]] ; then |
194 |
+ # For compatibility with older binaries at slight performance cost. |
195 |
+ # bug #616402 |
196 |
+ use stack-realign && append-flags -mstackrealign |
197 |
+ fi |
198 |
+ |
199 |
local t |
200 |
for t in "${NCURSES_TARGETS[@]}" ; do |
201 |
do_configure "${t}" |