Alright, I'll document this in case some other poor sod in the same boat finds it
First of all, In my PKGBUILD I first unset my flags because I don't want to use the ones in makepkg.conf for wine builds
It's only relevant for C, as C++ wouldn't allow that nonsense anyway, period (though it will take those switches without complaining). On a vanilla wine there probably isn't any C++ code but I've got some in my build (fsync patchset). The rest of this would be applicable (though the directory won't be named wine-tkg)
Code: Select all
prepare() {
unset CFLAGS
unset CXXFLAGS
export CFLAGS="-O2 -march=alderlake -Wno-error=implicit-function-declaration -Wno-error=incompatible-pointer-types"
export CXXFLAGS="-O2 -march=alderlake"
unset LDFLAGS
# add my CFLAGS where needed
patch -Np0 -i "$srcdir"/cflags.patch
...
I don't recommend anybody use -march, I just left it in as an example. I know that works for me, with Wine, I'm not hitting any breakage (and I'd try a build without if I did) but that's no so for all parts of the compatibility layer. For example, building those dlls likely get that overridden, and other builds like dxvk and vkd3d-proton will have subtly broken results. (not part of this build, but a related example)
These are the places where I added -Wno-error in my patch (at least the only places where I really need it to be)
There's no configure.in, only configure.ac which gets variables like that from other macros when autoconf is run, so it's easier to just patch configure, which is fine for just changing some variables.
Code: Select all
--- wine-tkg_orig/configure 2024-05-18 12:02:27.000000000 -0400
+++ wine-tkg/configure 2024-05-18 14:21:30.564730520 -0400
@@ -25304,7 +25304,7 @@
arm64ec_DELAYLOADFLAG = $arm64ec_DELAYLOADFLAG
arm64ec_DISABLED_SUBDIRS = $arm64ec_DISABLED_SUBDIRS
i386_CC = $i386_CC
-i386_CFLAGS = $i386_CFLAGS
+i386_CFLAGS = $i386_CFLAGS -march=alderlake -Wno-error=implicit-function-declaration -Wno-error=incompatible-pointer-types
i386_EXTRACFLAGS = $i386_EXTRACFLAGS
i386_LDFLAGS = $i386_LDFLAGS
i386_DEBUG = $i386_DEBUG
@@ -25312,7 +25312,7 @@
i386_DELAYLOADFLAG = $i386_DELAYLOADFLAG
i386_DISABLED_SUBDIRS = $i386_DISABLED_SUBDIRS
x86_64_CC = $x86_64_CC
-x86_64_CFLAGS = $x86_64_CFLAGS
+x86_64_CFLAGS = $x86_64_CFLAGS -march=alderlake -Wno-error=implicit-function-declaration -Wno-error=incompatible-pointer-types
x86_64_EXTRACFLAGS = $x86_64_EXTRACFLAGS
x86_64_LDFLAGS = $x86_64_LDFLAGS
x86_64_DEBUG = $x86_64_DEBUG
diff -Naur wine-tkg_orig/dlls/ntdll/Makefile.in wine-tkg/dlls/ntdll/Makefile.in
--- wine-tkg_orig/dlls/ntdll/Makefile.in 2024-05-18 12:02:28.000000000 -0400
+++ wine-tkg/dlls/ntdll/Makefile.in 2024-05-18 14:23:53.244737487 -0400
@@ -3,7 +3,7 @@
UNIXLIB = ntdll.so
IMPORTLIB = ntdll
IMPORTS = $(MUSL_PE_LIBS) winecrt0
-UNIX_CFLAGS = $(UNWIND_CFLAGS)
+UNIX_CFLAGS = $(UNWIND_CFLAGS) -Wno-error=implicit-function-declaration -Wno-error=incompatible-pointer-types
UNIX_LIBS = $(IOKIT_LIBS) $(COREFOUNDATION_LIBS) $(CORESERVICES_LIBS) $(RT_LIBS) $(PTHREAD_LIBS) $(UNWIND_LIBS) $(I386_LIBS) $(PROCSTAT_LIBS) -lm
EXTRADLLFLAGS = -nodefaultlibs
diff -Naur wine-tkg_orig/dlls/win32u/Makefile.in wine-tkg/dlls/win32u/Makefile.in
--- wine-tkg_orig/dlls/win32u/Makefile.in 2024-05-18 12:02:28.000000000 -0400
+++ wine-tkg/dlls/win32u/Makefile.in 2024-05-18 14:24:36.805739614 -0400
@@ -3,7 +3,7 @@
UNIXLIB = win32u.so
IMPORTLIB = win32u
IMPORTS = ntdll winecrt0
-UNIX_CFLAGS = $(FREETYPE_CFLAGS) $(FONTCONFIG_CFLAGS)
+UNIX_CFLAGS = $(FREETYPE_CFLAGS) $(FONTCONFIG_CFLAGS) -Wno-error=implicit-function-declaration -Wno-error=incompatible-pointer-types
UNIX_LIBS = $(CARBON_LIBS) $(APPKIT_LIBS) $(PTHREAD_LIBS) -lm
EXTRADLLFLAGS = -nodefaultlibs
Look at the paths and the + and - lines (don't apply this patch and again, don't use -march

)
To summarize:
Add -Wno-error=implicit-function-declaration -Wno-error=incompatible-pointer-types to wherever you are setting your CFLAGS (e.g. override in PKGBUILD or by setting variables)
Edit i386_CFLAGS and x86_64_CFLAGS in the configure script in the top level source dir
Edit UNIX_CFLAGS in dlls/ntdll/Makefile.in
Edit UNIX_CFLAGS in dlls/win32u/Makefile.in