util: Turn -DWINDOWS_NO_FUTEX to be pre_args
authorYonggang Luo <luoyonggang@gmail.com>
Sat, 15 Oct 2022 10:50:09 +0000 (18:50 +0800)
committerMarge Bot <emma+marge@anholt.net>
Sun, 16 Oct 2022 05:21:45 +0000 (05:21 +0000)
Turn -DWINDOWS_NO_FUTEX to be pre_args for not need add direct dependencies
to dep_futex for libraries and executables.
So only add dependencies to idep_mesautil is enough.

And this will make sure all source code are either using Windows futex,
or use mtx_t consistently across different sources, other than mixed usage of
futex and mtx_t before this commit.

If -DWINDOWS_NO_FUTEX is not globally available, that would cause
/src/util/simple_mtx.h:116: undefined reference to `futex_wait'

This error is raised when
 * compiled with -D min-windows-version=7
 * moved futex_wait from futex.h to futex.c
 * used simple_mtx_t in more codes

Or linkage error:
src/compiler/libcompiler.a.p/glsl_types.cpp.obj: in function `futex_wake':
/../../src/util/futex.h:154: undefined reference to `WaitOnAddress'
When:
 * compiled with -D min-windows-version=7
 * used simple_mtx_t in more codes

Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/7494
Fixes: c002bbeb2f7 ("util: Add a Win32 futex impl")

Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19087>

meson.build

index 8e45a26..fc5a32a 100644 (file)
@@ -1639,7 +1639,7 @@ endif
 dep_futex = null_dep
 if host_machine.system() == 'windows'
   if (get_option('min-windows-version') < 8)
-    dep_futex = declare_dependency(compile_args : ['-DWINDOWS_NO_FUTEX'])
+    pre_args += '-DWINDOWS_NO_FUTEX'
   else
     dep_futex = cc.find_library('synchronization', required : true)
   endif