Gentoo Archives: gentoo-commits

From: Sergei Trofimovich <slyfox@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: games-emulation/zsnes/files/, games-emulation/zsnes/
Date: Fri, 06 Jul 2018 22:33:22
Message-Id: 1530916389.c068f68557e6a0d7d2f5232221900205076429aa.slyfox@gentoo
1 commit: c068f68557e6a0d7d2f5232221900205076429aa
2 Author: Sergei Trofimovich <slyfox <AT> gentoo <DOT> org>
3 AuthorDate: Fri Jul 6 22:32:25 2018 +0000
4 Commit: Sergei Trofimovich <slyfox <AT> gentoo <DOT> org>
5 CommitDate: Fri Jul 6 22:33:09 2018 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=c068f685
7
8 games-emulation/zsnes: apply stack realignment to more functions
9
10 Expand existing stack realignment hack to more C functions
11 that get called from early init assembly. Fixes zsnes startup
12 for me.
13
14 Bug: https://bugs.gentoo.org/503138
15 Package-Manager: Portage-2.3.41, Repoman-2.3.9
16
17 .../zsnes/files/zsnes-1.51-stack-align-v2.patch | 56 ++++++++++
18 games-emulation/zsnes/zsnes-1.51-r7.ebuild | 122 +++++++++++++++++++++
19 2 files changed, 178 insertions(+)
20
21 diff --git a/games-emulation/zsnes/files/zsnes-1.51-stack-align-v2.patch b/games-emulation/zsnes/files/zsnes-1.51-stack-align-v2.patch
22 new file mode 100644
23 index 00000000000..35613a95359
24 --- /dev/null
25 +++ b/games-emulation/zsnes/files/zsnes-1.51-stack-align-v2.patch
26 @@ -0,0 +1,56 @@
27 +zsnes call C initialization code from assembler.
28 +
29 +Example backtrace:
30 +
31 + Thread 1 "zsnes" received signal SIGSEGV, Segmentation fault.
32 + => 0xf7550275 <+37>: vmovdqa (%esp),%xmm1
33 + ...
34 + #13 0x5699ef82 in InitSound () at linux/audio.c:336
35 + #14 0x569a25af in initwinvideo () at linux/sdllink.c:1080
36 + #15 0x5699fc13 in initvideo () at linux/sdllink.c:1298
37 + #16 0x56f9d5bc in regptwa ()
38 + #17 0x56a34b50 in SA1tableG ()
39 + #18 0x56f84788 in selcB800 ()
40 + ...
41 +
42 +Call to 'initwinvideo' (first C function) looks like that:
43 + NEWSYM InitPreGame ; Executes before starting/continuing a game
44 + mov byte[pressed+1],2
45 + pushad
46 + call Start60HZ
47 + %ifdef __OPENGL__
48 + call drawscreenwin
49 + %endif
50 + call initwinvideo
51 +
52 +Note: pushad / call does not 16-byte maintain stack alignment
53 +and breaks i386 ABI.
54 +
55 +We apply realignment attribute to all functions noticed by users.
56 +Bug: https://bugs.gentoo.org/503138
57 +--- src/linux/sdllink.c.old
58 ++++ src/linux/sdllink.c
59 +@@ -773,11 +773,11 @@ BOOL InitInput()
60 + {
61 + InitJoystickInput();
62 + return TRUE;
63 + }
64 +
65 +-int startgame()
66 ++int __attribute__((force_align_arg_pointer)) startgame()
67 + {
68 + static bool ranonce = false;
69 + int status;
70 +
71 + if (!ranonce)
72 +--- a/linux/sdllink.c
73 ++++ b/linux/sdllink.c
74 +@@ -897,7 +897,7 @@ bool OGLModeCheck()
75 + return(cvidmode > 4);
76 + }
77 +
78 +-void initwinvideo(void)
79 ++void __attribute__((force_align_arg_pointer)) initwinvideo(void)
80 + {
81 + DWORD newmode = 0;
82 +
83
84 diff --git a/games-emulation/zsnes/zsnes-1.51-r7.ebuild b/games-emulation/zsnes/zsnes-1.51-r7.ebuild
85 new file mode 100644
86 index 00000000000..9613a4888e8
87 --- /dev/null
88 +++ b/games-emulation/zsnes/zsnes-1.51-r7.ebuild
89 @@ -0,0 +1,122 @@
90 +# Copyright 1999-2018 Gentoo Foundation
91 +# Distributed under the terms of the GNU General Public License v2
92 +
93 +EAPI=6
94 +inherit autotools desktop flag-o-matic toolchain-funcs pax-utils
95 +
96 +DESCRIPTION="SNES (Super Nintendo) emulator that uses x86 assembly"
97 +HOMEPAGE="http://www.zsnes.com/ http://ipherswipsite.com/zsnes/"
98 +SRC_URI="mirror://sourceforge/zsnes/${PN}${PV//./}src.tar.bz2"
99 +
100 +LICENSE="GPL-2"
101 +SLOT="0"
102 +KEYWORDS="-* ~amd64 ~x86 ~x86-fbsd ~amd64-linux ~x86-linux"
103 +IUSE="ao custom-cflags +debug opengl pax_kernel png"
104 +
105 +RDEPEND="
106 + media-libs/libsdl[sound,video,abi_x86_32(-)]
107 + >=sys-libs/zlib-1.2.3-r1[abi_x86_32(-)]
108 + ao? ( media-libs/libao[abi_x86_32(-)] )
109 + debug? ( sys-libs/ncurses:0=[abi_x86_32(-)] )
110 + opengl? ( virtual/opengl[abi_x86_32(-)] )
111 + png? ( media-libs/libpng:0=[abi_x86_32(-)] )
112 +"
113 +DEPEND="${RDEPEND}
114 + dev-lang/nasm
115 + debug? ( virtual/pkgconfig )
116 +"
117 +
118 +S="${WORKDIR}/${PN}_${PV//./_}/src"
119 +
120 +PATCHES=(
121 + # Fixing compilation without libpng installed
122 + "${FILESDIR}"/${P}-libpng.patch
123 +
124 + # Fix bug #186111
125 + # Fix bug #214697
126 + # Fix bug #170108
127 + # Fix bug #260247
128 + "${FILESDIR}"/${P}-archopt-july-23-update.patch
129 + "${FILESDIR}"/${P}-gcc43.patch
130 + "${FILESDIR}"/${P}-libao-thread.patch
131 + "${FILESDIR}"/${P}-depbuild.patch
132 + "${FILESDIR}"/${P}-CC-quotes.patch
133 +
134 + # Fix compability with libpng15 wrt #378735
135 + "${FILESDIR}"/${P}-libpng15.patch
136 +
137 + # Fix buffer overwrite #257963
138 + "${FILESDIR}"/${P}-buffer.patch
139 + # Fix gcc47 compile #419635
140 + "${FILESDIR}"/${P}-gcc47.patch
141 + # Fix stack alignment issue #503138
142 + "${FILESDIR}"/${P}-stack-align-v2.patch
143 +
144 + "${FILESDIR}"/${P}-cross-compile.patch
145 + "${FILESDIR}"/${P}-arch.patch
146 +)
147 +
148 +src_prepare() {
149 + default
150 +
151 + # The sdl detection logic uses AC_PROG_PATH instead of
152 + # AC_PROG_TOOL, so force the var to get set the way we
153 + # need for things to work correctly.
154 + tc-is-cross-compiler && export ac_cv_path_SDL_CONFIG=${CHOST}-sdl-config
155 +
156 + sed -i -e '67i#define OF(x) x' zip/zunzip.h || die
157 +
158 + # Remove hardcoded CFLAGS and LDFLAGS
159 + sed -i \
160 + -e '/^CFLAGS=.*local/s:-pipe.*:-Wall -I.":' \
161 + -e '/^LDFLAGS=.*local/d' \
162 + -e '/\w*CFLAGS=.*fomit/s:-O3.*$STRIP::' \
163 + -e '/lncurses/s:-lncurses:`pkg-config ncurses --libs`:' \
164 + -e '/lcurses/s:-lcurses:`pkg-config ncurses --libs`:' \
165 + configure.in || die
166 + sed -i \
167 + -e 's/configure.in/configure.ac/' \
168 + Makefile.in || die
169 + mv configure.in configure.ac || die
170 + eautoreconf
171 +}
172 +
173 +src_configure() {
174 + tc-export CC
175 + export BUILD_CXX=$(tc-getBUILD_CXX)
176 + export NFLAGS=-O1
177 + use amd64 && multilib_toolchain_setup x86
178 + use custom-cflags || strip-flags
179 +
180 + append-cppflags -U_FORTIFY_SOURCE #257963
181 +
182 + econf \
183 + $(use_enable ao libao) \
184 + $(use_enable debug debugger) \
185 + $(use_enable png libpng) \
186 + $(use_enable opengl) \
187 + --disable-debug \
188 + --disable-cpucheck
189 +}
190 +
191 +src_compile() {
192 + emake makefile.dep
193 + emake
194 +}
195 +
196 +src_install() {
197 + dobin zsnes
198 + if use pax_kernel; then
199 + pax-mark m "${D}""${GAMES_BINDIR}"/zsnes || die
200 + fi
201 +
202 + newman linux/zsnes.1 zsnes.6
203 +
204 + dodoc \
205 + ../docs/{readme.1st,authors.txt,srcinfo.txt,stdards.txt,support.txt,thanks.txt,todo.txt,README.LINUX} \
206 + ../docs/readme.txt/*
207 + HTML_DOCS="../docs/readme.htm/*" einstalldocs
208 +
209 + make_desktop_entry zsnes ZSNES
210 + newicon icons/48x48x32.png ${PN}.png
211 +}