[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 01/21] meson: Avoid implicit declaration of absent functions
From: |
Paolo Bonzini |
Subject: |
[PULL 01/21] meson: Avoid implicit declaration of absent functions |
Date: |
Tue, 6 Jun 2023 16:30:56 +0200 |
From: Michal Privoznik <mprivozn@redhat.com>
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 (into meson-log.txt), e.g.:
qemu.git/build/meson-private/tmph74x3p38/testfile.c:2:34: \
warning: implicit declaration of function 'malloc_trim'
[-Wimplicit-function-declaration]
And some distributions (e.g. Gentoo) parse the meson log and
consider these erroneous because it can lead to feature
misdetection (see [1]).
We can check whether given function exists via
'cc.has_function()' or whether STATX_* macros exist via
'cc.has_header_symbol()'.
1: https://wiki.gentoo.org/wiki/Modern_C_porting
Resolves: https://bugs.gentoo.org/898810
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Message-Id:
<8e02776d18595a1c575c90a189ff65f1785f76ca.1685442612.git.mprivozn@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
meson.build | 26 +++++---------------------
1 file changed, 5 insertions(+), 21 deletions(-)
diff --git a/meson.build b/meson.build
index a61d3e9b06a..969a84f2a44 100644
--- a/meson.build
+++ b/meson.build
@@ -1797,8 +1797,7 @@ malloc = []
if get_option('malloc') == 'system'
has_malloc_trim = \
get_option('malloc_trim').allowed() and \
- cc.links('''#include <malloc.h>
- int main(void) { malloc_trim(0); return 0; }''')
+ cc.has_function('malloc_trim', prefix: '#include <malloc.h>')
else
has_malloc_trim = false
malloc = cc.find_library(get_option('malloc'), required: true)
@@ -1811,34 +1810,19 @@ if not has_malloc_trim and
get_option('malloc_trim').enabled()
endif
endif
-# Check whether the glibc provides statx()
-
gnu_source_prefix = '''
#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif
'''
-statx_test = gnu_source_prefix + '''
- #include <sys/stat.h>
- int main(void) {
- struct statx statxbuf;
- statx(0, "", 0, STATX_BASIC_STATS, &statxbuf);
- return 0;
- }'''
-has_statx = cc.links(statx_test)
+# Check whether the glibc provides STATX_BASIC_STATS
+
+has_statx = cc.has_header_symbol('sys/stat.h', 'STATX_BASIC_STATS', prefix:
gnu_source_prefix)
# Check whether statx() provides mount ID information
-statx_mnt_id_test = gnu_source_prefix + '''
- #include <sys/stat.h>
- int main(void) {
- struct statx statxbuf;
- statx(0, "", 0, STATX_BASIC_STATS | STATX_MNT_ID, &statxbuf);
- return statxbuf.stx_mnt_id;
- }'''
-
-has_statx_mnt_id = cc.links(statx_mnt_id_test)
+has_statx_mnt_id = cc.has_header_symbol('sys/stat.h', 'STATX_MNT_ID', prefix:
gnu_source_prefix)
have_vhost_user_blk_server = get_option('vhost_user_blk_server') \
.require(targetos == 'linux',
--
2.40.1
- [PULL 00/21] (Mostly) build system patches for 2023-06-06, Paolo Bonzini, 2023/06/06
- [PULL 01/21] meson: Avoid implicit declaration of absent functions,
Paolo Bonzini <=
- [PULL 03/21] scripts: remove dead file, Paolo Bonzini, 2023/06/06
- [PULL 02/21] atomics: eliminate mb_read/mb_set, Paolo Bonzini, 2023/06/06
- [PULL 04/21] meson.build: Group the UI entries in a separate summary section, Paolo Bonzini, 2023/06/06
- [PULL 05/21] meson.build: Group the network backend entries in a separate summary section, Paolo Bonzini, 2023/06/06
- [PULL 06/21] meson.build: Group the audio backend entries in a separate summary section, Paolo Bonzini, 2023/06/06
- [PULL 08/21] scsi/qemu-pr-helper: Drop support for 'old' libmultipath API, Paolo Bonzini, 2023/06/06
- [PULL 07/21] meson.build: Use -Wno-undef only for SDL2 versions that need it, Paolo Bonzini, 2023/06/06
- [PULL 09/21] Revert "tests/requirements.txt: bump up avocado-framework version to 101.0", Paolo Bonzini, 2023/06/06
- [PULL 10/21] tests: Use separate virtual environment for avocado, Paolo Bonzini, 2023/06/06
- [PULL 12/21] configure: remove --with-git= option, Paolo Bonzini, 2023/06/06