On 5/29/23 12:24, Peter Maydell wrote:
On Mon, 29 May 2023 at 08:58, Michal Privoznik <mpriv...@redhat.com> wrote:

While detecting a presence of a function via 'cc.links()'
gives desired result (i.e. detects whether function is present),
it also produces a warning on systems where the function is not
present, e.g.:

   qemu.git/build/meson-private/tmph74x3p38/testfile.c:2:34: \
   warning: implicit declaration of function 'malloc_trim' 
[-Wimplicit-function-declaration]

Produces a warning where ? On stdout/stderr ?

The linked bug report says "in the configure logs"
which is kinda vague. Warnings in the logfiles are
not a problem; warnings in the terminal output are...

It seems to be a lint:

 * QA Notice: Found the following implicit function declarations in configure 
logs:
 *   
/var/tmp/portage/app-emulation/qemu-7.2.0-r3/work/qemu-7.2.0/tools-build/meson-logs/meson-log.txt:562
 - malloc_trim
 *   
/var/tmp/portage/app-emulation/qemu-7.2.0-r3/work/qemu-7.2.0/tools-build/meson-logs/meson-log.txt:591
 - statx
 *   
/var/tmp/portage/app-emulation/qemu-7.2.0-r3/work/qemu-7.2.0/tools-build/meson-logs/meson-log.txt:627
 - statx
 *   
/var/tmp/portage/app-emulation/qemu-7.2.0-r3/work/qemu-7.2.0/softmmu-build/meson-logs/meson-log.txt:718
 - malloc_trim
 *   
/var/tmp/portage/app-emulation/qemu-7.2.0-r3/work/qemu-7.2.0/softmmu-build/meson-logs/meson-log.txt:747
 - statx
 *   
/var/tmp/portage/app-emulation/qemu-7.2.0-r3/work/qemu-7.2.0/softmmu-build/meson-logs/meson-log.txt:783
 - statx
 * Check that no features were accidentally disabled.
 * See https://wiki.gentoo.org/wiki/Modern_C_porting.

So, not an actual bug but more of a favor that we can do to the distros.

+    cc.has_function('malloc_trim', prefix: '#include <malloc.h>') and \
      cc.links('''#include <malloc.h>
                  int main(void) { malloc_trim(0); return 0; }''')

This seems super clunky -- surely this isn't the way Meson
intends people to write tests ?

For this one can remove the cc.links test altogether, so this part of the
patch is okay.

The statx is less clear.


+statx_test = statx_prefix + '''
   int main(void) {
     struct statx statxbuf;
     statx(0, "", 0, STATX_BASIC_STATS, &statxbuf);
     return 0;
   }'''
-has_statx = cc.links(statx_test)
+has_statx = cc.has_function('statx', prefix: statx_prefix) and \
+ cc.links(statx_test)

Here we could replace cc.links with a cc.has_header_symbol('sys/stat.h',
'STATX_BASIC_STATS'), and likewise for has_statx_mnt_id below.

If it was just has_statx I would rather leave things as is.  However,
given that there is has_statx_mnt_id too, I'd apply a v2 that removes
usage of cc.links for these three tests.

Paolo


Reply via email to