From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id A13B41584AD for ; Sun, 27 Apr 2025 08:27:30 +0000 (UTC) Received: from lists.gentoo.org (bobolink.gentoo.org [140.211.166.189]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) (Authenticated sender: relay-lists.gentoo.org@gentoo.org) by smtp.gentoo.org (Postfix) with ESMTPSA id 84089343070 for ; Sun, 27 Apr 2025 08:27:30 +0000 (UTC) Received: from bobolink.gentoo.org (localhost [127.0.0.1]) by bobolink.gentoo.org (Postfix) with ESMTP id 7C4BC110280; Sun, 27 Apr 2025 08:27:29 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bobolink.gentoo.org (Postfix) with ESMTPS id 70BF2110280 for ; Sun, 27 Apr 2025 08:27:29 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 15DBE343070 for ; Sun, 27 Apr 2025 08:27:29 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 9BCAB12A for ; Sun, 27 Apr 2025 08:27:27 +0000 (UTC) From: "Ionen Wolkens" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Ionen Wolkens" Message-ID: <1745742150.2db20f2eb03fee5ff43a677016c43a7b8d48d97d.ionen@gentoo> Subject: [gentoo-commits] repo/gentoo:master commit in: eclass/ X-VCS-Repository: repo/gentoo X-VCS-Files: eclass/wine.eclass X-VCS-Directories: eclass/ X-VCS-Committer: ionen X-VCS-Committer-Name: Ionen Wolkens X-VCS-Revision: 2db20f2eb03fee5ff43a677016c43a7b8d48d97d X-VCS-Branch: master Date: Sun, 27 Apr 2025 08:27:27 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: cddc7989-fdaa-460d-a1fd-a716612ff985 X-Archives-Hash: 4369b59c98051c918633aa62265db261 commit: 2db20f2eb03fee5ff43a677016c43a7b8d48d97d Author: Ionen Wolkens gentoo org> AuthorDate: Sun Apr 27 05:48:35 2025 +0000 Commit: Ionen Wolkens gentoo org> CommitDate: Sun Apr 27 08:22:30 2025 +0000 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=2db20f2e wine.eclass: split *FLAGS handling per-arch Previously would test flags for only one arch as a best effort, but this gets messier if adding --enable-archs=i386,aarch64 support where the two are more likely to need different flags. Using a function inside $() to avoid the need to preserve CHOST *FLAGS and also allow e.g. filter-flags -Wl,* (from CFLAGS...) without mangling LDFLAGS given filter-cflags does not exist. Adapted from https://github.com/gentoo/gentoo/pull/41752 Thanks-to: Sasha Finkelstein gmail.com> Signed-off-by: Ionen Wolkens gentoo.org> eclass/wine.eclass | 120 +++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 85 insertions(+), 35 deletions(-) diff --git a/eclass/wine.eclass b/eclass/wine.eclass index cb4852b99c60..223c83f1c4a5 100644 --- a/eclass/wine.eclass +++ b/eclass/wine.eclass @@ -160,9 +160,11 @@ wine_src_prepare() { # to be passed: --prefix (and similar), --enable-archs, --enable-win64 # --with-mingw, and --with-wine64 # -# Not truly supported, but cross toolchain can be customised using -# CROSSCC, CROSSCC_amd64/x86/arm64, CROSSCFLAGS and CROSSLDFLAGS -# (based on what wine's configure also recognize, or used to for CC). +# Can adjust cross toolchain using CROSSCC, CROSSCC_amd64/x86/arm64, +# CROSS{C,LD}FLAGS, and CROSS{C,LD}FLAGS_amd64/x86/arm64 (variable +# naming is mostly historical because wine itself used to recognize +# CROSSCC). By default it attempts to use same {C,LD}FLAGS as the +# main toolchain but will strip known unsupported flags. wine_src_configure() { WINE_PREFIX=/usr/lib/${P} WINE_DATADIR=/usr/share/${P} @@ -198,6 +200,10 @@ wine_src_configure() { strip-unsupported-flags fi + # wcc_* variables are used by _wine_flags(), see that + # function if need to adjust *FLAGS only for cross + local wcc_{amd64,x86,arm64}{,_testflags} + # TODO?: llvm-mingw support if ever packaged and wanted if use mingw; then conf+=( --with-mingw ) @@ -205,23 +211,24 @@ wine_src_configure() { ! has_version -b 'dev-util/mingw64-toolchain[bin-symlinks]' && PATH=${BROOT}/usr/lib/mingw64-toolchain/bin:${PATH} - # TODO?: llvm-mingw support if ever packaged and wanted - local wcc_amd64=${CROSSCC:-${CROSSCC_amd64:-x86_64-w64-mingw32-gcc}} - local wcc_x86=${CROSSCC:-${CROSSCC_x86:-i686-w64-mingw32-gcc}} + wcc_amd64=${CROSSCC:-${CROSSCC_amd64:-x86_64-w64-mingw32-gcc}} + wcc_x86=${CROSSCC:-${CROSSCC_x86:-i686-w64-mingw32-gcc}} # no mingw64-toolchain ~arm64, but "may" be usable with crossdev # (aarch64- rather than arm64- given it is what Wine searches for) - local wcc_arm64=${CROSSCC:-${CROSSCC_arm64:-aarch64-w64-mingw32-gcc}} - local -n wcc_test=wcc_$(usex arm64 arm64 $(usex abi_x86_64 amd64 x86)) + wcc_arm64=${CROSSCC:-${CROSSCC_arm64:-aarch64-w64-mingw32-gcc}} else conf+=( --with-mingw=clang ) # not building for ${CHOST} so $(tc-getCC) is not quite right, but - # *should* support -target *-windows regardless + # *should* support -target *-windows regardless (testflags is only + # used by _wine_flags(), wine handles -target by itself) tc-is-clang && local clang=$(tc-getCC) || local clang=clang - local wcc_amd64=${CROSSCC:-${CROSSCC_amd64:-${clang}}} - local wcc_x86=${CROSSCC:-${CROSSCC_x86:-${clang}}} - local wcc_arm64=${CROSSCC:-${CROSSCC_arm64:-${clang}}} - local wcc_test="${clang} -target $(usex arm64 aarch64 $(usex abi_x86_64 x86_64 i386))-windows" + wcc_amd64=${CROSSCC:-${CROSSCC_amd64:-${clang}}} + wcc_amd64_testflags="-target x86_64-windows" + wcc_x86=${CROSSCC:-${CROSSCC_x86:-${clang}}} + wcc_x86_testflags="-target i386-windows" + wcc_arm64=${CROSSCC:-${CROSSCC_arm64:-${clang}}} + wcc_arm64_testflags="-target aarch64-windows" # do not copy from regular LDFLAGS given odds are they all are # incompatible, and difficult to test linking without llvm-mingw @@ -232,30 +239,33 @@ wine_src_configure() { ac_cv_prog_x86_64_CC="${wcc_amd64}" ac_cv_prog_i386_CC="${wcc_x86}" ac_cv_prog_aarch64_CC="${wcc_arm64}" - - CROSSCFLAGS="${CROSSCFLAGS:-$( - # many hardening options are unlikely to work right - filter-flags '-fstack-protector*' #870136 - filter-flags '-mfunction-return=thunk*' #878849 - - # bashrc-mv users often do CFLAGS="${LDFLAGS}" and then - # compile-only tests miss stripping unsupported linker flags - filter-flags '-Wl,*' - - # -mavx with mingw-gcc has a history of problems and still see - # users have issues despite Wine's -mpreferred-stack-boundary=2 - use mingw && append-cflags -mno-avx - - CC=${wcc_test} test-flags-CC ${CFLAGS:--O2} - )}" - CROSSLDFLAGS="${CROSSLDFLAGS:-$( - # let compiler figure out the right linker for cross - filter-flags '-fuse-ld=*' - - CC=${wcc_test} test-flags-CCLD ${LDFLAGS} - )}" ) + if ver_test -ge 10; then + # TODO: merge with the av_cv array above when =wine-9, + # do a one-arch best effort fallback + CROSSCFLAGS="${CROSSCFLAGS_amd64:-${CROSSCFLAGS:-$(_wine_flags c amd64)}}" + CROSSLDFLAGS="${CROSSLDFLAGS_amd64:-${CROSSLDFLAGS:-$(_wine_flags ld amd64)}}" + ) + elif use abi_x86_32; then + conf+=( + CROSSCFLAGS="${CROSSCFLAGS_x86:-${CROSSCFLAGS:-$(_wine_flags c x86)}}" + CROSSLDFLAGS="${CROSSLDFLAGS_x86:-${CROSSLDFLAGS:-$(_wine_flags ld x86)}}" + ) + fi + if use abi_x86_64 && use abi_x86_32 && use !wow64; then # multilib dual build method for "old" wow64 (must do 64 first) local bits @@ -409,6 +419,46 @@ wine_pkg_postrm() { fi } +# @FUNCTION: _wine_flags +# @USAGE: +# @INTERNAL +# @DESCRIPTION: +# Filter and test current {C,LD}FLAGS for usage with the cross +# toolchain (using ``wcc_*`` variables, see wine_src_configure), +# and echo back working flags. +# +# Note that this ignores checking USE for simplicity, if compiler +# is unusable (e.g. not found) then it will return empty flags +# which is fine. +_wine_flags() { + local -n wcc=wcc_${2} wccflags=wcc_${2}_testflags + + case ${1} in + c) + # many hardening options are unlikely to work right + filter-flags '-fstack-protector*' #870136 + filter-flags '-mfunction-return=thunk*' #878849 + + # bashrc-mv users often do CFLAGS="${LDFLAGS}" and then + # compile-only tests miss stripping unsupported linker flags + filter-flags '-Wl,*' + + # -mavx with mingw-gcc has a history of problems and still see + # users have issues despite Wine's -mpreferred-stack-boundary=2 + use mingw && append-cflags -mno-avx + + # same as strip-unsupported-flags but echos only for CC + CC="${wcc} ${wccflags}" test-flags-CC ${CFLAGS} + ;; + ld) + # let compiler figure out the right linker for cross + filter-flags '-fuse-ld=*' + + CC="${wcc} ${wccflags}" test-flags-CCLD ${LDFLAGS} + ;; + esac +} + fi EXPORT_FUNCTIONS pkg_pretend src_prepare src_configure src_compile src_install pkg_postinst pkg_postrm