From cfa56a666c616a1d37c606b47678e7834a78002d Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Wed, 13 Jul 2022 17:55:27 +0100 Subject: [PATCH] meson: Don't use cc.has_function to check for va_copy va_copy is not an ordinary function (an extern symbol), so we can't treat it as one. Instead, use the same compilation/linking check as in the Autotools build system. Signed-off-by: Simon McVittie --- meson.build | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/meson.build b/meson.build index f9995ed48..fa269d3bc 100644 --- a/meson.build +++ b/meson.build @@ -607,8 +607,35 @@ config.set('HAVE_BACKTRACE', have_backtrace) # we currently check for all three va_copy possibilities, so we get # all results in config.log for bug reports. -has_va_copy = cc.has_function('va_copy') -has___va_copy = cc.has_function('__va_copy') +# Can't use cc.has_function here because va_copy is not +# exactly a function +va_copy_check = ''' +#include +#include + +static void f (int i, ...) +{ + va_list args1, args2; + va_start (args1, i); + @0@ (args2, args1); + + if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42) + exit (1); + + va_end (args1); + va_end (args2); +} + +int main() +{ + f (0, 42); + return 0; +} +''' + +has_va_copy = cc.links(va_copy_check.format('va_copy')) +has___va_copy = cc.links(va_copy_check.format('__va_copy')) + if has_va_copy va_copy = 'va_copy' elif has___va_copy -- 2.47.3