util: Turn -DWINDOWS_NO_FUTEX to be pre_args

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: c002bbeb2f ("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>
This commit is contained in:
Yonggang Luo 2022-10-15 18:50:09 +08:00 committed by Marge Bot
parent 4c7a44413a
commit 2b64ff9284

View 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