From: Michal Privoznik <mprivozn@redhat.com>
To: qemu-devel@nongnu.org
Subject: [PATCH] meson: Avoid implicit declaration of functions
Date: Mon, 29 May 2023 09:56:26 +0200 [thread overview]
Message-ID: <068f343a62de3dbc3764d0ad98111881b04a60d2.1685346951.git.mprivozn@redhat.com> (raw)
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]
We can check whether given function exists via
'cc.has_function()' firstly.
Resolves: https://bugs.gentoo.org/898810
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
---
meson.build | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/meson.build b/meson.build
index 2d48aa1e2e..5da4dbac24 100644
--- a/meson.build
+++ b/meson.build
@@ -1797,6 +1797,7 @@ malloc = []
if get_option('malloc') == 'system'
has_malloc_trim = \
get_option('malloc_trim').allowed() and \
+ cc.has_function('malloc_trim', prefix: '#include <malloc.h>') and \
cc.links('''#include <malloc.h>
int main(void) { malloc_trim(0); return 0; }''')
else
@@ -1818,27 +1819,29 @@ gnu_source_prefix = '''
#define _GNU_SOURCE
#endif
'''
-statx_test = gnu_source_prefix + '''
- #include <sys/stat.h>
+statx_prefix = gnu_source_prefix + '''
+ #include<sys/stat.h>
+'''
+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)
# Check whether statx() provides mount ID information
-statx_mnt_id_test = gnu_source_prefix + '''
- #include <sys/stat.h>
+statx_mnt_id_test = statx_prefix + '''
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 = has_statx and cc.links(statx_mnt_id_test)
have_vhost_user_blk_server = get_option('vhost_user_blk_server') \
.require(targetos == 'linux',
--
2.39.3
next reply other threads:[~2023-05-29 7:58 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-29 7:56 Michal Privoznik [this message]
2023-05-29 10:24 ` [PATCH] meson: Avoid implicit declaration of functions Peter Maydell
2023-05-29 11:04 ` Paolo Bonzini
2023-05-29 11:13 ` Michael Tokarev
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=068f343a62de3dbc3764d0ad98111881b04a60d2.1685346951.git.mprivozn@redhat.com \
--to=mprivozn@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).