Package Details: mingw-w64-meson 1-22

Git Clone URL: (read-only, click to copy)
Package Base: mingw-w64-meson
Description: Meson wrapper for MinGW (mingw-w64)
Upstream URL:
Licenses: GPL
Submitter: drakkan
Maintainer: drakkan
Last Packager: drakkan
Votes: 7
Popularity: 0.069837
First Submitted: 2018-04-23 10:40 (UTC)
Last Updated: 2021-04-26 13:32 (UTC)

Latest Comments

drakkan commented on 2022-06-05 08:09 (UTC)

we use CFLAGS from mingw-w64-environment

jackoneill commented on 2022-06-01 13:26 (UTC)


Any progress on removing -O2 from the CFLAGS? It's breaking meson's --optimization parameter.

xantares commented on 2021-04-26 13:30 (UTC) (edited on 2021-04-26 13:30 (UTC) by xantares)


could you bump the release number ?

I updated mingw-w64-environment and newer flags should be taken into account

Martchus commented on 2021-03-27 20:40 (UTC)

Just export MINGW_CFLAGS and MINGW_CXXFLAGS with the flags you want before calling the wrapper.

jackoneill commented on 2021-03-27 20:04 (UTC)


There's a small problem with sourcing mingw-env: the -O2 flag in ends up overriding meson's --optimization parameter.

My software happens to need the -O3 flag to compile. Lower values don't work.

drakkan commented on 2020-12-02 19:04 (UTC)

I pushed a less intrusive change that keeps the 2 different config files for now,so no PKGBUILD should break

drakkan commented on 2020-11-29 17:00 (UTC)

the problem is that it breaks fribidi, I hope to find some time tomorrow to do some tests, thank you

xantares commented on 2020-11-29 14:25 (UTC)

I tried your modification and yes it works!

xantares commented on 2020-11-27 20:20 (UTC)

I use the mingw-w64-mesa-git PKGBUILD, with the following modifications:

MESON_EXE_WRAPPER=/usr/bin/${_arch}-wine NEED_WINE=1 ${_arch}-meson build-${_arch} -Db_lto=false -Dgallium-drivers=swrast -Dbuild-tests=true

ninja test -C build-${_arch} ${MAKEFLAGS}

drakkan commented on 2020-11-27 08:51 (UTC)


can you please paste you mesa PKGBUILD so I can do some tests?

a change like this one:

 pkgdesc="Meson wrapper for MinGW (mingw-w64)"
 depends=('meson' 'mingw-w64-gcc' 'mingw-w64-pkg-config')
@@ -13,7 +13,7 @@ url=""
-            'c91f2bbcafad7b742f13c6bd46324a03b70066b348621ce6a20f4a05005985ef')
+            '9430f5d112c05b766a18c11b2b1f4ac9f190cd3e7201229b02ff3e1cd7877209')
 _architectures="i686-w64-mingw32 x86_64-w64-mingw32"

 build() {
@@ -24,7 +24,6 @@ build() {
     unset LDFLAGS
     source mingw-env ${_arch}
     python --arch ${_arch} --output-file toolchain-${_arch}.meson 
-    python --arch ${_arch} --output-file toolchain-${_arch}-wine.meson --need-exe-wrapper 
     sed "s|@TRIPLE@|${_arch}|g;" meson-mingw-wrapper > ${_arch}-meson
@@ -36,7 +35,6 @@ package() {
   for _arch in ${_architectures}; do
     install -m 755 "${srcdir}/${_arch}-meson" "$pkgdir/usr/bin/${_arch}-meson"
     install -m 644 toolchain-${_arch}.meson "${pkgdir}"/usr/share/mingw/
-    install -m 644 toolchain-${_arch}-wine.meson "${pkgdir}"/usr/share/mingw/

diff --git a/meson-mingw-wrapper b/meson-mingw-wrapper
index 9adc2d0..240c397 100644
--- a/meson-mingw-wrapper
+++ b/meson-mingw-wrapper
@@ -2,11 +2,14 @@

 if [ -z ${CROSS_FILE} ]
-  if [ -z ${NEED_WINE} ]
+  CROSS_FILE=/usr/share/mingw/toolchain-@TRIPLE@.meson
+if [ -z ${MESON_EXE_WRAPPER} ]
+  if [ -n ${NEED_WINE} ]
-    CROSS_FILE=/usr/share/mingw/toolchain-@TRIPLE@.meson
-  else
-    CROSS_FILE=/usr/share/mingw/toolchain-@TRIPLE@-wine.meson
+    MESON_EXE_WRAPPER=/usr/bin/@TRIPLE@-wine

breaks fribidi tests

xantares commented on 2020-11-26 18:37 (UTC) (edited on 2020-11-26 19:08 (UTC) by xantares)

I appears it helps to set MESON_EXE_WRAPPER env variable when calling i686-w64-mingw32-meson when configuring mesa for tests to be run, should it be defined inside the wrapper when NEED_WINE is set ?

would this be an alternative to having to use 2 different config files ?

drakkan commented on 2020-11-03 18:01 (UTC)


I think we need to change properties to built-in options here. I cannot test this change before tomorrow

xantares commented on 2020-11-03 17:50 (UTC) (edited on 2020-11-03 17:50 (UTC) by xantares)


seems something has changed in latest meson, can you have a look:

DEPRECATION: c_args in the [properties] section of the machine file is deprecated, use the [built-in options] section.

DEPRECATION: cpp_args in the [properties] section of the machine file is deprecated, use the [built-in options] section.

DEPRECATION: c_link_args in the [properties] section of the machine file is deprecated, use the [built-in options] section.

DEPRECATION: cpp_link_args in the [properties] section of the machine file is deprecated, use the [built-in options] section.

drakkan commented on 2020-08-21 11:43 (UTC)

Please take a look here

xantares commented on 2020-08-21 11:15 (UTC)


How can I add custom flags to my build ?

I tried setting CXXFLAGS/LDFLAGS/CFLAGS without luck:

CXXFLAGS="-fno-lto" ${_arch}-meson


Martchus commented on 2019-12-06 14:16 (UTC)

That's similar to qmake. But you can still at least insert the flags at build time of the mingw-w64-mesion package instead of duplicating them. I did the same for mingw-w64-qt5-base:

This way we can change flags when needed by only customizing mingw-w64-environment and just need to rebuild mingw-w64-meson (and mingw-w64-qt5-base).

xantares commented on 2019-12-04 08:19 (UTC) (edited on 2019-12-04 08:19 (UTC) by xantares)

ok; seems their design allow to have rules for native and cross targets in the same build, no idea what it's for

drakkan commented on 2019-12-02 21:29 (UTC) (edited on 2019-12-02 21:30 (UTC) by drakkan)

@xantares, I don't think that this work for meson, from the docs:

c_args, cpp_args, c_link_args, and cpp_link_args only affect native builds, when cross compiling they will not be applied to binaries or libraries targeting the host system, only those being run on the build system.

I just did a quick test adding -v to ninja for mingw-w64-libsoup, current meson wrapper:

[84/91] x86_64-w64-mingw32-gcc -Iexamples/c590b3c@@simple-proxy@exe -Iexamples -I../examples -I. -I../ -Ilibsoup -I/usr/x86_64-w64-mingw32/include/glib-2.0 -I/usr/x86_64-w64-mingw32/lib/glib-2.0/include -I/usr/x86_64-w64-mingw32/include -I/usr/x86_64-w64-mingw32/lib/libffi-3.2.1/include -flto -fdiagnostics-color=always -pipe -Wall -Winvalid-pch -std=c89 -O3 -D_DEFAULT_SOURCE -D__USE_MINGW_ANSI_STDIO=1 -DHAVE_CONFIG_H -Wall -Wmissing-include-dirs -Wpointer-arith -Winit-self -Wdeclaration-after-statement -Werror=missing-prototypes -Werror=implicit-function-declaration -Werror=aggregate-return -Werror=format=2 -Wstrict-prototypes -Wno-format-zero-length -Wp,-D_FORTIFY_SOURCE=2 -fno-plt -fexceptions --param=ssp-buffer-size=4 -mms-bitfields -mms-bitfields -mms-bitfields -MD -MQ 'examples/c590b3c@@simple-proxy@exe/simple-proxy.c.obj' -MF 'examples/c590b3c@@simple-proxy@exe/simple-proxy.c.obj.d' -o 'examples/c590b3c@@simple-proxy@exe/simple-proxy.c.obj' -c ../examples/simple-proxy.c

meson wrapper modified as you suggest:

[82/91] x86_64-w64-mingw32-gcc -Iexamples/c590b3c@@simple-proxy@exe -Iexamples -I../examples -I. -I../ -Ilibsoup -I/usr/x86_64-w64-mingw32/include/glib-2.0 -I/usr/x86_64-w64-mingw32/lib/glib-2.0/include -I/usr/x86_64-w64-mingw32/include -I/usr/x86_64-w64-mingw32/lib/libffi-3.2.1/include -flto -fdiagnostics-color=always -pipe -Wall -Winvalid-pch -std=c89 -O3 -D_DEFAULT_SOURCE -D__USE_MINGW_ANSI_STDIO=1 -DHAVE_CONFIG_H -Wall -Wmissing-include-dirs -Wpointer-arith -Winit-self -Wdeclaration-after-statement -Werror=missing-prototypes -Werror=implicit-function-declaration -Werror=aggregate-return -Werror=format=2 -Wstrict-prototypes -Wno-format-zero-length -mms-bitfields -mms-bitfields -mms-bitfields -MD -MQ 'examples/c590b3c@@simple-proxy@exe/simple-proxy.c.obj' -MF 'examples/c590b3c@@simple-proxy@exe/simple-proxy.c.obj.d' -o 'examples/c590b3c@@simple-proxy@exe/simple-proxy.c.obj' -c ../examples/simple-proxy.c

xantares commented on 2019-12-02 20:53 (UTC)

hello, can you use mingw-w64-environment ?

just do "source mingw-env @TRIPLE@" at beginning of meson-mingw-wrapper instead of setting all the flags manually, see /usr/bin/


xantares commented on 2019-11-17 11:56 (UTC)

one last thing, can you add the "-Wl,-O1,--sort-common,--as-needed" linker flags that are used in mingw-w64-configure and mingw-w64-cmake ?

xantares commented on 2019-11-17 11:43 (UTC)


can you add mingw-w64-cmake as optdepends ?

xantares commented on 2019-11-17 10:47 (UTC) (edited on 2019-11-17 10:55 (UTC) by xantares)

could you add the cmake entry in toolchain-mingw.meson under [binaries] ?

cmake = '@TRIPLE@-cmake'

then mingw-w64-cmake can be added to optdepends

this is needed for mingw-w64-mesa if I want to switch to meson

rodrigo21 commented on 2019-11-16 22:28 (UTC)

Please add c_link_args = ['-fstack-protector'] and cpp_link_args = ['-fstack-protector'] under [properties] or some package will not build.

xantares commented on 2019-11-11 16:47 (UTC)

you'll probably want to add -fstack-protector to LDFLAGS with the new crt

drakkan commented on 2019-01-05 12:06 (UTC)

@xantares, ok I'll do some test with these flags

c_args = ['-D_FORTIFY_SOURCE=2', '-fno-plt', '-fexceptions', '--param=ssp-buffer-size=4']
cpp_args = ['-D_FORTIFY_SOURCE=2', '-fno-plt', '-fexceptions', '--param=ssp-buffer-size=4']

and I'll push the changes if all is fine.

Please note that with meson the flags -O2 -g ecc.. are added by buildtype:

  • buildtype release will add -O3
  • buildtype debug will add -O0 -g

xantares commented on 2019-01-05 09:34 (UTC)

hi, you may want to update the flags here to add "fno-plt" like in w64-cmake

drakkan commented on 2018-12-22 18:22 (UTC)

@Martchus, we could add a new package (for example something like mingw-w64-env) that defines default mingw env vars and then modify mingw meson/cmake/configure to read these vars from the file provided by that package.

Martchus commented on 2018-12-22 17:50 (UTC)

Not having -g is good enough for me right now. But good to know about the environment variable.

drakkan commented on 2018-12-22 17:32 (UTC) (edited on 2018-12-22 18:09 (UTC) by drakkan)

@Martchus, actually you can set CROSS_FILE env var that points to a different cross file. This should be enough for egde cases.

I agree that defaults flags should be consistent in mingw-w64-configure, cmake and meson, so I have no problem to change the meson defaults if we agree so.

Maybe we can do something similar to fedora

I can remove c_args and cpp_args from the cross file and so the env var should be used

Martchus commented on 2018-12-22 14:16 (UTC)

Since this package also hard codes linker flags:

Maybe it is not so easy to make the flags configurable via environment variables in case of meson. But the defaults could still be adjusted. The good thing is that the build flag which is my main concern (-g) isn't present in your package anyways.

drakkan commented on 2018-09-03 16:05 (UTC)

I just compiled mingw-w64-gcc and retested glib complitation and it works for me.

Anyway your patch should not hurts, so I think I'll apply it later today, thanks!

Martchus commented on 2018-09-03 14:20 (UTC)

Could you git am this patch: ?

See recent comments under for details.

jackoneill commented on 2018-06-12 20:23 (UTC)

And probably -Wall interferes with the --warnlevel parameter.

jackoneill commented on 2018-06-12 20:05 (UTC)

Hi! The -O2 and -g compiler parameters interfere with meson's --buildtype parameter.

Example of a compile command with --buildtype=release:

i686-w64-mingw32-g++ -Idecross@sha -I. -I.. -I/usr/i686-w64-mingw32/include -I/usr/include/vapoursynth -fdiagnostics-color=always -pipe -Wall -Winvalid-pch -Wnon-virtual-dtor -std=c++11 -O3 -Wall -Wextra -Wshadow -mfpmath=sse -msse2 -mstackrealign -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions --param=ssp-buffer-size=4 -MD -MQ 'decross@sha/src_decross.cpp.obj' -MF 'decross@sha/src_decross.cpp.obj.d' -o 'decross@sha/src_decross.cpp.obj' -c ../src/decross.cpp

And with --buildtype=debug:

i686-w64-mingw32-g++ -Idecross@sha -I. -I.. -I/usr/i686-w64-mingw32/include -I/usr/include/vapoursynth -fdiagnostics-color=always -pipe -Wall -Winvalid-pch -Wnon-virtual-dtor -std=c++11 -O0 -g -Wall -Wextra -Wshadow -mfpmath=sse -msse2 -mstackrealign -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions --param=ssp-buffer-size=4 -MD -MQ 'decross@sha/src_decross.cpp.obj' -MF 'decross@sha/src_decross.cpp.obj.d' -o 'decross@sha/src_decross.cpp.obj' -c ../src/decross.cpp

In both cases the compiler uses -O2 because it appears later.

drakkan commented on 2018-05-10 15:43 (UTC)

Thanks! I'll merge these changes later today, I'm only a bit uncertain about wine, this way wine will be a required depends for meson since if it is not installed meson will crash with this error

FileNotFoundError: [Errno 2] No such file or directory: 'wine': 'wine'

I'll try to investigate this error

kfg commented on 2018-05-10 13:55 (UTC)


some of my packages have moved to meson and i thought it would be nice to have wrapper scripts like in the mingw-w64-configure and mingw-w64-cmake packages. So I made a template for mingw64 meson wrapper scripts based on the arch-meson script.

I've uploaded the changes here:

I also added exe_wrapper = 'wine' to the [binaries] section in the toolchain template. This is necessary for building some packages since they need to run the created windows executables to generate configs/build files or they run test binaries in the check() step.