commit:     bcebdbdbeb4dad9e922f1d91326af00f38f8a252
Author:     Ionen Wolkens <ionen <AT> gentoo <DOT> org>
AuthorDate: Tue Jul 29 04:56:47 2025 +0000
Commit:     Ionen Wolkens <ionen <AT> gentoo <DOT> org>
CommitDate: Tue Jul 29 05:33:41 2025 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=bcebdbdb

wine.eclass: do not pass CFLAGS as CROSSCFLAGS for mingw by default

Desktop integration tab wrt bug #960825 is not *that* big of an issue,
but these kind of issues with CROSSCFLAGS="-march=native ..." keep
coming back and I'd rather this not be done anymore unless
USE=custom-cflags so regular users do not have to deal with this.
Very few people/distros set CROSSCFLAGS and by default wine will use
just -O2 rather than try to copy CFLAGS which results in a lot of
(not really) "Gentoo"-specific obscure issues.

Closing bug given not currently planning to change this even if that
specific issue is fixed in upstream gcc/wine, but feel free to
re-open/repurpose if someone wants to pursue this further.

Technically needs revbumps, but letting this propagate on wine bumps
should be sufficient, wine should still mostly work albeit the exact
extend of issues beyond the desktop integration tab is unknown. Please
rebuild manually if affected and want this fixed now.

Leaving this alone for clang (USE=-mingw), no issues that I'm aware
of yet (or at least not specific to *FLAGS, it is generally less
tested with wine and may have other unrelated issues).

Closes: https://bugs.gentoo.org/960825
Thanks-to: GoldsrcSource
Signed-off-by: Ionen Wolkens <ionen <AT> gentoo.org>

 eclass/wine.eclass | 38 +++++++++++++++++++++++++++-----------
 1 file changed, 27 insertions(+), 11 deletions(-)

diff --git a/eclass/wine.eclass b/eclass/wine.eclass
index 185d3bf4ec59..a92f01f9e37c 100644
--- a/eclass/wine.eclass
+++ b/eclass/wine.eclass
@@ -459,17 +459,33 @@ _wine_flags() {
 
        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
+                       if use mingw && use !custom-cflags; then
+                               # Changing CROSSCFLAGS is not very tested and 
often cause
+                               # problems even with simple things like 
-march=native/-O3 when
+                               # using mingw-gcc (thus -mno-avx below, also 
bug #960825), only
+                               # inherit basic flags from CFLAGS unless 
USE=custom-cflags.
+                               #
+                               # Note that users setting CROSSCFLAGS directly 
(unfiltered)
+                               # are on their own just like with 
USE=custom-cflags.
+                               local flag flags=${CFLAGS} CFLAGS=-O2
+                               # not get-flag() given it returns only the 
first occurence
+                               for flag in ${flags}; do
+                                       [[ ${flag} == @(-g*|-O[0-1g]) ]] && 
CFLAGS+=" ${flag}"
+                               done
+                       else
+                               # 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
+                               # (kept even with USE=custom-cflags wrt bug 
#912268)
+                               use mingw && append-cflags -mno-avx
+                       fi
 
                        # same as strip-unsupported-flags but echos only for CC
                        CC="${wcc} ${wccflags}" test-flags-CC ${CFLAGS}

Reply via email to