1 |
commit: 597109c08904d741e50ce36ab94856c00fd8562f |
2 |
Author: Ionen Wolkens <ionen <AT> gentoo <DOT> org> |
3 |
AuthorDate: Sat May 7 04:19:38 2022 +0000 |
4 |
Commit: Ionen Wolkens <ionen <AT> gentoo <DOT> org> |
5 |
CommitDate: Fri May 13 02:29:29 2022 +0000 |
6 |
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=597109c0 |
7 |
|
8 |
dev-util/mingw64-toolchain: new package, add 10.0.0 |
9 |
|
10 |
This package attempts to bootstrap a mingw toolchain |
11 |
(binutils+gcc+mingw64-runtime) without crossdev for |
12 |
easy use with wine and related packages like dxvk. |
13 |
|
14 |
crossdev is generally intended for advanced use, and |
15 |
not for a user who just want to play games (e.g. many |
16 |
Blizzard games don't work without USE=mingw on wine). |
17 |
|
18 |
Not the greatest solution, but should allow improving the |
19 |
wine situation for users until there's a better option. |
20 |
|
21 |
Signed-off-by: Ionen Wolkens <ionen <AT> gentoo.org> |
22 |
|
23 |
dev-util/mingw64-toolchain/Manifest | 3 + |
24 |
.../mingw64-runtime-10.0.0-tmp-files-clash.patch | 10 + |
25 |
dev-util/mingw64-toolchain/metadata.xml | 13 + |
26 |
.../mingw64-toolchain-10.0.0.ebuild | 300 +++++++++++++++++++++ |
27 |
4 files changed, 326 insertions(+) |
28 |
|
29 |
diff --git a/dev-util/mingw64-toolchain/Manifest b/dev-util/mingw64-toolchain/Manifest |
30 |
new file mode 100644 |
31 |
index 000000000000..059c493a8601 |
32 |
--- /dev/null |
33 |
+++ b/dev-util/mingw64-toolchain/Manifest |
34 |
@@ -0,0 +1,3 @@ |
35 |
+DIST binutils-2.37.tar.xz 22916924 BLAKE2B f5a374fdf0300f7734d1e462333296b16c9d5ed6eba167e1742a4da7082f4388c929e286bf76c3933b3e434937380340732a31790723654b491ea0c8ab5b9ba5 SHA512 5c11aeef6935860a6819ed3a3c93371f052e52b4bdc5033da36037c1544d013b7f12cb8d561ec954fe7469a68f1b66f1a3cd53d5a3af7293635a90d69edd15e7 |
36 |
+DIST gcc-11.3.0.tar.xz 81141364 BLAKE2B 7e562d25446ca4ab9fe8cdb714866f66aba3744d78bf84f31bfb097c1a981e4c7f990cb1e6bcfec5ae6671836a4984e2b70eb8fed81dcef5e244f88da8623469 SHA512 f0be5ad705c73b84477128a69c047f57dd47002f375eb60e1e842e08cf2009a509e92152bca345823926d550b7395ae6d4de7db51d1ee371c2dc37313881fca7 |
37 |
+DIST mingw-w64-v10.0.0.tar.bz2 9620291 BLAKE2B 451372403289c492ca939d65bb4d9f6e9fa6bdd6b32d79d6438d858e106e8cc291712ada1f3f7b951a4c6908e7d0385d485ca76920af39bcf86effa48408e330 SHA512 3c0827af7c40809a867758f6cd9ef3ff0c988b43082345bf725e03949af95968d634ace99a7ffae323189549221dcb5d861de9e801f1fbc7904e446641b60516 |
38 |
|
39 |
diff --git a/dev-util/mingw64-toolchain/files/mingw64-runtime-10.0.0-tmp-files-clash.patch b/dev-util/mingw64-toolchain/files/mingw64-runtime-10.0.0-tmp-files-clash.patch |
40 |
new file mode 100644 |
41 |
index 000000000000..38c4abf91e77 |
42 |
--- /dev/null |
43 |
+++ b/dev-util/mingw64-toolchain/files/mingw64-runtime-10.0.0-tmp-files-clash.patch |
44 |
@@ -0,0 +1,10 @@ |
45 |
+Fix clash when enabling lib32 and lib64 at same time, backport from: |
46 |
+https://sourceforge.net/p/mingw-w64/mingw-w64/ci/953bcd32ae470c4647e94de8548dda5a8f07d82d/ |
47 |
+(except directly to Makefile.in to avoid autoreconf over this) |
48 |
+--- a/mingw64/mingw-w64-crt/Makefile.in |
49 |
++++ b/mingw64/mingw-w64-crt/Makefile.in |
50 |
+@@ -153,3 +153,3 @@ |
51 |
+ host_triplet = @host@ |
52 |
+-@DLLTOOL_HAS_TEMP_PREFIX_TRUE@am__append_1 = --temp-prefix $$(basename $@ .a) |
53 |
++@DLLTOOL_HAS_TEMP_PREFIX_TRUE@am__append_1 = --temp-prefix $(basename $@) |
54 |
+ @DELAY_IMPORT_LIBS_TRUE@am__append_2 = --output-delaylib $@.delayimp.a |
55 |
|
56 |
diff --git a/dev-util/mingw64-toolchain/metadata.xml b/dev-util/mingw64-toolchain/metadata.xml |
57 |
new file mode 100644 |
58 |
index 000000000000..7a95ab69a652 |
59 |
--- /dev/null |
60 |
+++ b/dev-util/mingw64-toolchain/metadata.xml |
61 |
@@ -0,0 +1,13 @@ |
62 |
+<?xml version="1.0" encoding="UTF-8"?> |
63 |
+<!DOCTYPE pkgmetadata SYSTEM "https://www.gentoo.org/dtd/metadata.dtd"> |
64 |
+<pkgmetadata> |
65 |
+ <maintainer type="person"> |
66 |
+ <email>ionen@g.o</email> |
67 |
+ <name>Ionen Wolkens</name> |
68 |
+ </maintainer> |
69 |
+ <upstream> |
70 |
+ <remote-id type="cpe">cpe:/a:gnu:gcc</remote-id> |
71 |
+ <remote-id type="cpe">cpe:/a:gnu:binutils</remote-id> |
72 |
+ <remote-id type="sourceforge">mingw-w64</remote-id> |
73 |
+ </upstream> |
74 |
+</pkgmetadata> |
75 |
|
76 |
diff --git a/dev-util/mingw64-toolchain/mingw64-toolchain-10.0.0.ebuild b/dev-util/mingw64-toolchain/mingw64-toolchain-10.0.0.ebuild |
77 |
new file mode 100644 |
78 |
index 000000000000..1ae7b097c037 |
79 |
--- /dev/null |
80 |
+++ b/dev-util/mingw64-toolchain/mingw64-toolchain-10.0.0.ebuild |
81 |
@@ -0,0 +1,300 @@ |
82 |
+# Copyright 2022 Gentoo Authors |
83 |
+# Distributed under the terms of the GNU General Public License v2 |
84 |
+ |
85 |
+EAPI=8 |
86 |
+ |
87 |
+MULTILIB_COMPAT=( abi_x86_{32,64} ) |
88 |
+inherit edo flag-o-matic multilib-build toolchain-funcs |
89 |
+ |
90 |
+# Pick versions known to work for Wine and use vanilla for simplicity, |
91 |
+# ideally update only on mingw64-runtime bumps or if there's known issues |
92 |
+# (please report) to avoid rebuilding the entire toolchain too often. |
93 |
+# Do _p1++ rather than revbump if changing without bumping mingw64 itself. |
94 |
+BINUTILS_PV=2.37 # 2.38 needs bug #838106 |
95 |
+GCC_PV=11.3.0 |
96 |
+ |
97 |
+DESCRIPTION="All-in-one mingw64 toolchain intended for building Wine without crossdev" |
98 |
+HOMEPAGE=" |
99 |
+ https://www.mingw-w64.org/ |
100 |
+ https://gcc.gnu.org/ |
101 |
+ https://sourceware.org/binutils/" |
102 |
+SRC_URI=" |
103 |
+ mirror://sourceforge/mingw-w64/mingw-w64/mingw-w64-release/mingw-w64-v${PV}.tar.bz2 |
104 |
+ mirror://gnu/gcc/gcc-${GCC_PV}/gcc-${GCC_PV}.tar.xz |
105 |
+ mirror://gnu/binutils/binutils-${BINUTILS_PV}.tar.xz" |
106 |
+S="${WORKDIR}" |
107 |
+ |
108 |
+# l1:binutils+gcc, l2:gcc(libraries), l3:mingw64-runtime |
109 |
+LICENSE=" |
110 |
+ GPL-3+ |
111 |
+ LGPL-3+ || ( GPL-3+ libgcc libstdc++ gcc-runtime-library-exception-3.1 ) |
112 |
+ ZPL BSD BSD-2 ISC LGPL-2+ LGPL-2.1+ MIT public-domain" |
113 |
+SLOT="0" |
114 |
+KEYWORDS="-* ~amd64 ~x86" |
115 |
+IUSE="+abi_x86_32 custom-cflags debug" |
116 |
+ |
117 |
+RDEPEND=" |
118 |
+ dev-libs/gmp:= |
119 |
+ dev-libs/mpc:= |
120 |
+ dev-libs/mpfr:= |
121 |
+ sys-libs/zlib:= |
122 |
+ virtual/libiconv" |
123 |
+DEPEND="${RDEPEND}" |
124 |
+ |
125 |
+PATCHES=( |
126 |
+ "${FILESDIR}"/mingw64-runtime-10.0.0-tmp-files-clash.patch |
127 |
+) |
128 |
+ |
129 |
+pkg_pretend() { |
130 |
+ [[ ${MERGE_TYPE} == binary ]] && return |
131 |
+ |
132 |
+ tc-is-cross-compiler && |
133 |
+ die "cross-compilation of the toolchain itself is unsupported" |
134 |
+} |
135 |
+ |
136 |
+src_prepare() { |
137 |
+ # rename directories to simplify both patching and the ebuild |
138 |
+ mv binutils{-${BINUTILS_PV},} || die |
139 |
+ mv gcc{-${GCC_PV},} || die |
140 |
+ mv mingw-w64-v${PV} mingw64 || die |
141 |
+ |
142 |
+ default |
143 |
+} |
144 |
+ |
145 |
+src_compile() { |
146 |
+ # not great but do everything in src_compile given bootstrapping |
147 |
+ # process needs to be done in steps of configure+compile+install |
148 |
+ # (done modular to have most package-specific things in one place) |
149 |
+ |
150 |
+ CTARGET=$(usex x86 i686 x86_64)-w64-mingw32 |
151 |
+ |
152 |
+ MWT_D=${T}/root # use ${T} to respect VariableScope for ${D} |
153 |
+ local mwtdir=/usr/lib/${PN} |
154 |
+ local prefix=${EPREFIX}${mwtdir} |
155 |
+ local sysroot=${MWT_D}${prefix} |
156 |
+ local -x PATH=${sysroot}/bin:${PATH} |
157 |
+ |
158 |
+ use custom-cflags || strip-flags # fancy flags are not realistic here |
159 |
+ |
160 |
+ local multilib=false |
161 |
+ use abi_x86_32 && use abi_x86_64 && multilib=true |
162 |
+ |
163 |
+ # global configure flags |
164 |
+ local conf=( |
165 |
+ --build=${CBUILD:-${CHOST}} |
166 |
+ --target=${CTARGET} |
167 |
+ --{doc,info,man}dir=/.skip # let individual packages handle docs |
168 |
+ ) |
169 |
+ |
170 |
+ # binutils |
171 |
+ local conf_binutils=( |
172 |
+ --prefix="${prefix}" |
173 |
+ --host=${CHOST} |
174 |
+ --disable-cet |
175 |
+ --disable-nls |
176 |
+ --disable-shared |
177 |
+ --with-system-zlib |
178 |
+ --without-debuginfod |
179 |
+ ) |
180 |
+ mwt-binutils() { |
181 |
+ # replace duplicates with symlinks |
182 |
+ local bin |
183 |
+ for bin in "${sysroot}"/${CTARGET}/bin/*; do |
184 |
+ ln -sf {../${CTARGET}/bin/,"${sysroot}"/bin/${CTARGET}-}${bin##*/} || die |
185 |
+ done |
186 |
+ ln -sf ld.bfd "${sysroot}"/${CTARGET}/bin/ld || die |
187 |
+ } |
188 |
+ |
189 |
+ # gcc (minimal -- if need more, disable only in stage1 / enable in stage3) |
190 |
+ local conf_gcc=( |
191 |
+ --prefix="${prefix}" |
192 |
+ --host=${CHOST} |
193 |
+ --disable-bootstrap |
194 |
+ --disable-cet |
195 |
+ --disable-gomp |
196 |
+ --disable-libquadmath |
197 |
+ --disable-libsanitizer |
198 |
+ --disable-libssp |
199 |
+ --disable-libvtv |
200 |
+ --disable-shared |
201 |
+ --with-system-zlib |
202 |
+ --without-isl |
203 |
+ --without-zstd |
204 |
+ ) |
205 |
+ ${multilib} || conf_gcc+=( --disable-multilib ) |
206 |
+ |
207 |
+ local conf_gcc_stage1=( |
208 |
+ --enable-languages=c |
209 |
+ --disable-libatomic |
210 |
+ --with-sysroot="${sysroot}" |
211 |
+ ) |
212 |
+ local -n conf_gcc_stage2=conf_gcc_stage1 |
213 |
+ |
214 |
+ local conf_gcc_stage3=( |
215 |
+ --enable-languages=c,c++ |
216 |
+ --enable-threads=posix # needs stage3, and is required for dxvk/vkd3d |
217 |
+ --with-sysroot="${prefix}" |
218 |
+ --with-build-sysroot="${sysroot}" |
219 |
+ ) |
220 |
+ mwt-gcc_stage3() { |
221 |
+ # replace duplicate with symlink |
222 |
+ ln -sf ${CTARGET}-gcc "${sysroot}"/bin/${CTARGET}-gcc-${GCC_PV} || die |
223 |
+ } |
224 |
+ |
225 |
+ # mingw64-runtime (split in several parts, 3 needed for gcc stages) |
226 |
+ local conf_mingw64=( |
227 |
+ --prefix="${prefix}"/${CTARGET} |
228 |
+ --host=${CTARGET} |
229 |
+ --with-sysroot=no |
230 |
+ --without-{crt,headers} |
231 |
+ |
232 |
+ # mingw .dll aren't used by wine and packages wouldn't find them |
233 |
+ # at runtime, use crossdev if need dll and proper search paths |
234 |
+ --disable-shared |
235 |
+ ) |
236 |
+ |
237 |
+ local conf_mingw64_headers=( |
238 |
+ --enable-idl |
239 |
+ --with-headers |
240 |
+ ) |
241 |
+ mwt-mingw64_headers() { ln -s ${CTARGET} "${sysroot}"/mingw || die; } #419601 |
242 |
+ |
243 |
+ local conf_mingw64_runtime=( --with-crt ) |
244 |
+ ${multilib} || |
245 |
+ conf_mingw64_runtime+=( $(usex x86 --disable-lib64 --disable-lib32 ) ) |
246 |
+ |
247 |
+ local conf_mingw64_libraries=( --with-libraries ) |
248 |
+ local conf_mingw64_libraries32=( |
249 |
+ --libdir="${prefix}"/${CTARGET}/lib32 |
250 |
+ --with-libraries |
251 |
+ CC="${CTARGET}-gcc -m32" |
252 |
+ RCFLAGS="--target=pe-i386 ${RCFLAGS}" |
253 |
+ ) |
254 |
+ |
255 |
+ # mingw64-runtime's idl compiler (useful not to depend on wine for widl) |
256 |
+ local conf_widl=( --prefix="${prefix}" ) |
257 |
+ |
258 |
+ # mwt-build [-x] <path/package-name> [stage-name] |
259 |
+ # -> ./configure && make && make install && mwt-package() && mwt-package_stage() |
260 |
+ # passes conf, conf_package, and conf_package_stage arrays to configure, and |
261 |
+ # users can add options through environment with e.g. |
262 |
+ # MWT_BINUTILS_CONF="--some-option" |
263 |
+ # MWT_GCC_STAGE1_CONF="--some-gcc-stage1-only-option" |
264 |
+ # MWT_WIDL_CONF="--some-other-option" |
265 |
+ # EXTRA_ECONF="--global-option" (generic naming for if not reading this) |
266 |
+ mwt-build() { |
267 |
+ if [[ ${1} == -x ]]; then |
268 |
+ ( |
269 |
+ # cross-compiling, cleanup and let ./configure handle it |
270 |
+ unset AR AS CC CPP CXX LD NM OBJCOPY OBJDUMP RANLIB RC STRIP |
271 |
+ CHOST=${CTARGET} |
272 |
+ strip-unsupported-flags |
273 |
+ mwt-build "${@:2}" |
274 |
+ ) |
275 |
+ return |
276 |
+ fi |
277 |
+ |
278 |
+ local id=${1##*/} |
279 |
+ local build_dir=${WORKDIR}/${1}${2+_${2}}-build |
280 |
+ |
281 |
+ # econf is not allowed in src_compile and its defaults are |
282 |
+ # mostly unused here, so use configure directly |
283 |
+ eval ' |
284 |
+ local conf=( "${WORKDIR}/${1}"/configure "${conf[@]}" ) |
285 |
+ [[ ${conf_'${id}'@a} ]] && conf+=( "${conf_'${id}'[@]}" ) |
286 |
+ [[ ${2} && ${conf_'${id}_${2}'@a} ]] && conf+=( "${conf_'${id}_${2}'[@]}" ) |
287 |
+ conf+=( ${EXTRA_ECONF} ${MWT_'${id^^}'_CONF} ) |
288 |
+ [[ ${2} ]] && conf+=( ${MWT_'${1^^}_${2^^}'_CONF} )' |
289 |
+ |
290 |
+ einfo "Building ${id}${2+ ${2}} in ${build_dir} ..." |
291 |
+ |
292 |
+ mkdir "${build_dir}" || die |
293 |
+ pushd "${build_dir}" >/dev/null || die |
294 |
+ |
295 |
+ edo "${conf[@]}" |
296 |
+ emake |
297 |
+ emake DESTDIR="${MWT_D}" install |
298 |
+ |
299 |
+ declare -f mwt-${id} >/dev/null && edo mwt-${id} |
300 |
+ declare -f mwt-${id}_${2} >/dev/null && edo mwt-${id}_${2} |
301 |
+ |
302 |
+ popd >/dev/null || die |
303 |
+ } |
304 |
+ |
305 |
+ # build with same ordering that crossdev would do + stage3 for pthreads |
306 |
+ mwt-build binutils |
307 |
+ mwt-build mingw64 headers |
308 |
+ mwt-build gcc stage1 |
309 |
+ mwt-build -x mingw64 runtime |
310 |
+ mwt-build gcc stage2 |
311 |
+ ${multilib} && mwt-build -x mingw64 libraries32 |
312 |
+ mwt-build -x mingw64 libraries |
313 |
+ mwt-build gcc stage3 |
314 |
+ mwt-build mingw64/mingw-w64-tools/widl |
315 |
+ # note: /could/ system-bootstrap if already installed, but gcc and |
316 |
+ # libraries will use the system's older mingw64 headers/static-libs |
317 |
+ # and make this potentially fragile without more workarounds/stages |
318 |
+ |
319 |
+ if ${multilib}; then |
320 |
+ # Like system's gcc, `x86_64-w64-mingw32-gcc -m32` can build for x86, |
321 |
+ # but packages expect crossdev's i686-w64-mingw32-gcc which is the same |
322 |
+ # just without 64bit support and would rather not build the toolchain |
323 |
+ # twice. Dirty but wrap to allow simple interoperability with crossdev. |
324 |
+ mwt-i686_wrapper() { |
325 |
+ printf "#!/usr/bin/env sh\nexec \"${prefix}/bin/${bin}\" ${*} "'"${@}"\n' \ |
326 |
+ > ${bin32} || die |
327 |
+ chmod +x ${bin32} || die |
328 |
+ } |
329 |
+ pushd "${sysroot}"/bin >/dev/null || die |
330 |
+ local bin bin32 |
331 |
+ for bin in ${CTARGET}-*; do |
332 |
+ bin32=${bin/x86_64-w64/i686-w64} |
333 |
+ case ${bin#${CTARGET}-} in |
334 |
+ gcc|gcc-${GCC_PV}|g++|widl) mwt-i686_wrapper -m32;; |
335 |
+ ld|ld.bfd) mwt-i686_wrapper -m i386pe;; |
336 |
+ windres) mwt-i686_wrapper --target=pe-i386;; |
337 |
+ *) ln -s ${bin} ${bin32} || die;; |
338 |
+ esac |
339 |
+ done |
340 |
+ popd >/dev/null || die |
341 |
+ fi |
342 |
+ |
343 |
+ # portage doesn't know the right strip executable to use for CTARGET |
344 |
+ # and it can lead to .a mangling, notably with 32bit (breaks toolchain) |
345 |
+ dostrip -x ${mwtdir}/{${CTARGET}/lib{,32},lib/gcc/${CTARGET}} |
346 |
+ |
347 |
+ # ... and instead do it here given this saves ~60MB |
348 |
+ if use !debug; then |
349 |
+ einfo "Stripping ${CTARGET} static libraries ..." |
350 |
+ find "${sysroot}"/{,lib/gcc/}${CTARGET} -type f -name '*.a' \ |
351 |
+ -exec ${CTARGET}-strip --strip-unneeded {} + || die |
352 |
+ fi |
353 |
+} |
354 |
+ |
355 |
+src_install() { |
356 |
+ # use mv over copying given it's ~370MB |
357 |
+ mv "${MWT_D}${EPREFIX}"/* "${ED}" || die |
358 |
+ |
359 |
+ # gcc handles static libs internally without needing .la |
360 |
+ find "${ED}" -type f -name '*.la' -delete || die |
361 |
+} |
362 |
+ |
363 |
+pkg_postinst() { |
364 |
+ if [[ ! ${REPLACING_VERSIONS} ]]; then |
365 |
+ elog "Note that this package is primarily intended for Wine and related" |
366 |
+ elog "packages to depend on without needing a manual crossdev setup." |
367 |
+ elog |
368 |
+ elog "Settings are oriented only for what these need and simplicity." |
369 |
+ elog "Please use sys-devel/crossdev for full toolchain/customization:" |
370 |
+ elog " https://wiki.gentoo.org/wiki/Mingw" |
371 |
+ elog " https://wiki.gentoo.org/wiki/Crossdev" |
372 |
+ fi |
373 |
+ |
374 |
+ local cross_gcc=cross-$(usex x86 i686 x86_64)-w64-mingw32/gcc |
375 |
+ if has_version ${cross_gcc}; then |
376 |
+ # encourage cleanup given users may not realize if switch by default |
377 |
+ ewarn "${cross_gcc} is installed, note that ${PN}" |
378 |
+ ewarn "is redundant with the *-w64-mingw32/{binutils,gcc,mingw64-runtime}" |
379 |
+ ewarn "packages and optionally only one needs to be kept." |
380 |
+ fi |
381 |
+} |