qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Marc-André Lureau" <marcandre.lureau@redhat.com>
Subject: [PULL 21/26] configure, meson: move more compiler checks to Meson
Date: Thu, 14 Oct 2021 18:29:33 +0200	[thread overview]
Message-ID: <20211014162938.430211-22-pbonzini@redhat.com> (raw)
In-Reply-To: <20211014162938.430211-1-pbonzini@redhat.com>

Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20211007130829.632254-15-pbonzini@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 configure        | 91 ------------------------------------------------
 meson.build      | 44 +++++++++++++++++++++++
 util/meson.build |  4 ++-
 3 files changed, 47 insertions(+), 92 deletions(-)

diff --git a/configure b/configure
index 9b59dce2f8..7c58c7c28d 100755
--- a/configure
+++ b/configure
@@ -3110,19 +3110,6 @@ elif test "$tpm" = "yes"; then
   fi
 fi
 
-##########################################
-# iovec probe
-cat > $TMPC <<EOF
-#include <sys/types.h>
-#include <sys/uio.h>
-#include <unistd.h>
-int main(void) { return sizeof(struct iovec); }
-EOF
-iovec=no
-if compile_prog "" "" ; then
-  iovec=yes
-fi
-
 ##########################################
 # fdt probe
 
@@ -3564,42 +3551,6 @@ EOF
   fi
 fi
 
-#########################################
-# See if 64-bit atomic operations are supported.
-# Note that without __atomic builtins, we can only
-# assume atomic loads/stores max at pointer size.
-
-cat > $TMPC << EOF
-#include <stdint.h>
-int main(void)
-{
-  uint64_t x = 0, y = 0;
-  y = __atomic_load_n(&x, __ATOMIC_RELAXED);
-  __atomic_store_n(&x, y, __ATOMIC_RELAXED);
-  __atomic_compare_exchange_n(&x, &y, x, 0, __ATOMIC_RELAXED, __ATOMIC_RELAXED);
-  __atomic_exchange_n(&x, y, __ATOMIC_RELAXED);
-  __atomic_fetch_add(&x, y, __ATOMIC_RELAXED);
-  return 0;
-}
-EOF
-if compile_prog "" "" ; then
-  atomic64=yes
-fi
-
-########################################
-# check if getauxval is available.
-
-getauxval=no
-cat > $TMPC << EOF
-#include <sys/auxv.h>
-int main(void) {
-  return getauxval(AT_HWCAP) == 0;
-}
-EOF
-if compile_prog "" "" ; then
-    getauxval=yes
-fi
-
 ########################################
 # check if ccache is interfering with
 # semantic analysis of macros
@@ -3673,33 +3624,6 @@ else
     membarrier=no
 fi
 
-##########################################
-# check for usable AF_VSOCK environment
-have_af_vsock=no
-cat > $TMPC << EOF
-#include <errno.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#if !defined(AF_VSOCK)
-# error missing AF_VSOCK flag
-#endif
-#include <linux/vm_sockets.h>
-int main(void) {
-    int sock, ret;
-    struct sockaddr_vm svm;
-    socklen_t len = sizeof(svm);
-    sock = socket(AF_VSOCK, SOCK_STREAM, 0);
-    ret = getpeername(sock, (struct sockaddr *)&svm, &len);
-    if ((ret == -1) && (errno == ENOTCONN)) {
-        return 0;
-    }
-    return -1;
-}
-EOF
-if compile_prog "" "" ; then
-    have_af_vsock=yes
-fi
-
 ##########################################
 # check for usable AF_ALG environment
 have_afalg=no
@@ -4175,9 +4099,6 @@ fi
 if test "$vhost_user_fs" = "yes" ; then
   echo "CONFIG_VHOST_USER_FS=y" >> $config_host_mak
 fi
-if test "$iovec" = "yes" ; then
-  echo "CONFIG_IOVEC=y" >> $config_host_mak
-fi
 if test "$membarrier" = "yes" ; then
   echo "CONFIG_MEMBARRIER=y" >> $config_host_mak
 fi
@@ -4247,14 +4168,6 @@ if test "$cmpxchg128" = "yes" ; then
   echo "CONFIG_CMPXCHG128=y" >> $config_host_mak
 fi
 
-if test "$atomic64" = "yes" ; then
-  echo "CONFIG_ATOMIC64=y" >> $config_host_mak
-fi
-
-if test "$getauxval" = "yes" ; then
-  echo "CONFIG_GETAUXVAL=y" >> $config_host_mak
-fi
-
 if test "$libssh" = "yes" ; then
   echo "CONFIG_LIBSSH=y" >> $config_host_mak
   echo "LIBSSH_CFLAGS=$libssh_cflags" >> $config_host_mak
@@ -4282,10 +4195,6 @@ if test "$replication" = "yes" ; then
   echo "CONFIG_REPLICATION=y" >> $config_host_mak
 fi
 
-if test "$have_af_vsock" = "yes" ; then
-  echo "CONFIG_AF_VSOCK=y" >> $config_host_mak
-fi
-
 if test "$debug_mutex" = "yes" ; then
   echo "CONFIG_DEBUG_MUTEX=y" >> $config_host_mak
 fi
diff --git a/meson.build b/meson.build
index 6bf43e6d30..6b7487b725 100644
--- a/meson.build
+++ b/meson.build
@@ -1550,6 +1550,8 @@ config_host_data.set('CONFIG_INOTIFY',
                      cc.has_header_symbol('sys/inotify.h', 'inotify_init'))
 config_host_data.set('CONFIG_INOTIFY1',
                      cc.has_header_symbol('sys/inotify.h', 'inotify_init1'))
+config_host_data.set('CONFIG_IOVEC',
+                     cc.has_header_symbol('sys/uio.h', 'struct iovec'))
 config_host_data.set('CONFIG_MACHINE_BSWAP_H',
                      cc.has_header_symbol('machine/bswap.h', 'bswap32',
                                           prefix: '''#include <sys/endian.h>
@@ -1697,6 +1699,48 @@ config_host_data.set('HAVE_BROKEN_SIZE_MAX', not cc.compiles('''
         return printf("%zu", SIZE_MAX);
     }''', args: ['-Werror']))
 
+# See if 64-bit atomic operations are supported.
+# Note that without __atomic builtins, we can only
+# assume atomic loads/stores max at pointer size.
+config_host_data.set('CONFIG_ATOMIC64', cc.links('''
+  #include <stdint.h>
+  int main(void)
+  {
+    uint64_t x = 0, y = 0;
+    y = __atomic_load_n(&x, __ATOMIC_RELAXED);
+    __atomic_store_n(&x, y, __ATOMIC_RELAXED);
+    __atomic_compare_exchange_n(&x, &y, x, 0, __ATOMIC_RELAXED, __ATOMIC_RELAXED);
+    __atomic_exchange_n(&x, y, __ATOMIC_RELAXED);
+    __atomic_fetch_add(&x, y, __ATOMIC_RELAXED);
+    return 0;
+  }'''))
+
+config_host_data.set('CONFIG_GETAUXVAL', cc.links(gnu_source_prefix + '''
+  #include <sys/auxv.h>
+  int main(void) {
+    return getauxval(AT_HWCAP) == 0;
+  }'''))
+
+config_host_data.set('CONFIG_AF_VSOCK', cc.compiles(gnu_source_prefix + '''
+  #include <errno.h>
+  #include <sys/types.h>
+  #include <sys/socket.h>
+  #if !defined(AF_VSOCK)
+  # error missing AF_VSOCK flag
+  #endif
+  #include <linux/vm_sockets.h>
+  int main(void) {
+    int sock, ret;
+    struct sockaddr_vm svm;
+    socklen_t len = sizeof(svm);
+    sock = socket(AF_VSOCK, SOCK_STREAM, 0);
+    ret = getpeername(sock, (struct sockaddr *)&svm, &len);
+    if ((ret == -1) && (errno == ENOTCONN)) {
+        return 0;
+    }
+    return -1;
+  }'''))
+
 ignored = ['CONFIG_QEMU_INTERP_PREFIX', # actually per-target
     'HAVE_GDB_BIN']
 arrays = ['CONFIG_BDRV_RW_WHITELIST', 'CONFIG_BDRV_RO_WHITELIST']
diff --git a/util/meson.build b/util/meson.build
index 779f413c86..05b593055a 100644
--- a/util/meson.build
+++ b/util/meson.build
@@ -1,5 +1,7 @@
 util_ss.add(files('osdep.c', 'cutils.c', 'unicode.c', 'qemu-timer-common.c'))
-util_ss.add(when: 'CONFIG_ATOMIC64', if_false: files('atomic64.c'))
+if not config_host_data.get('CONFIG_ATOMIC64')
+  util_ss.add(files('atomic64.c'))
+endif
 util_ss.add(when: 'CONFIG_POSIX', if_true: files('aio-posix.c'))
 util_ss.add(when: 'CONFIG_POSIX', if_true: files('fdmon-poll.c'))
 if config_host_data.get('CONFIG_EPOLL_CREATE1')
-- 
2.31.1




  parent reply	other threads:[~2021-10-14 16:49 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-14 16:29 [PULL 00/26] Meson changes for 2021-10-14 Paolo Bonzini
2021-10-14 16:29 ` [PULL 01/26] configure: remove --oss-lib Paolo Bonzini
2021-10-14 16:29 ` [PULL 02/26] audio: remove CONFIG_AUDIO_WIN_INT Paolo Bonzini
2021-10-14 16:29 ` [PULL 03/26] configure, meson: move audio driver detection to Meson Paolo Bonzini
2021-11-01 14:32   ` Peter Maydell
2021-10-14 16:29 ` [PULL 04/26] meson: define symbols for all available audio drivers Paolo Bonzini
2021-10-14 16:29 ` [PULL 05/26] configure: add command line options for " Paolo Bonzini
2021-10-14 16:29 ` [PULL 06/26] kconfig: split CONFIG_SPARSE_MEM from fuzzing Paolo Bonzini
2021-10-14 16:29 ` [PULL 07/26] configure, meson: move fuzzing configuration to Meson Paolo Bonzini
2021-10-14 16:29 ` [PULL 08/26] trace: simple: pass trace_file unmodified to config-host.h Paolo Bonzini
2021-10-14 16:29 ` [PULL 09/26] trace: move configuration from configure to Meson Paolo Bonzini
2021-10-14 16:29 ` [PULL 10/26] configure, meson: move CONFIG_HOST_DSOSUF " Paolo Bonzini
2021-10-14 16:29 ` [PULL 11/26] configure, meson: get HOST_WORDS_BIGENDIAN via the machine object Paolo Bonzini
2021-10-14 16:29 ` [PULL 12/26] configure, meson: remove CONFIG_GCOV from config-host.mak Paolo Bonzini
2021-10-14 16:29 ` [PULL 13/26] meson: HAVE_GDB_BIN is not used by C code Paolo Bonzini
2021-10-14 16:29 ` [PULL 14/26] configure, meson: move remaining HAVE_* compiler tests to Meson Paolo Bonzini
2021-10-14 16:29 ` [PULL 15/26] configure, meson: move pthread_setname_np checks " Paolo Bonzini
2021-11-15 17:15   ` Daniel P. Berrangé
2021-11-15 17:25     ` Peter Maydell
2021-10-14 16:29 ` [PULL 16/26] configure, meson: move libaio check to meson.build Paolo Bonzini
2021-10-14 16:29 ` [PULL 17/26] configure, meson: move vde detection to meson Paolo Bonzini
2021-10-14 16:29 ` [PULL 18/26] configure, meson: move netmap " Paolo Bonzini
2021-10-14 16:29 ` [PULL 19/26] configure, meson: move Spice configure handling " Paolo Bonzini
2021-10-14 16:29 ` [PULL 20/26] configure: remove obsolete Solaris ar check Paolo Bonzini
2021-10-14 16:29 ` Paolo Bonzini [this message]
2021-11-15 16:36   ` [PULL 21/26] configure, meson: move more compiler checks to Meson Peter Maydell
2021-11-15 16:42     ` Peter Maydell
2021-11-16  9:29       ` Paolo Bonzini
2021-11-16 13:13       ` Peter Maydell
2021-11-15 16:55     ` Peter Maydell
2021-10-14 16:29 ` [PULL 22/26] configure: remove deprecated --{enable, disable}-git-update Paolo Bonzini
2021-10-14 16:29 ` [PULL 23/26] configure: accept "internal" for --enable-capstone/slirp/fdt Paolo Bonzini
2021-10-14 16:29 ` [PULL 24/26] configure: prepare for auto-generated option parsing Paolo Bonzini
2021-10-14 16:29 ` [PULL 25/26] meson-buildoptions: include list of tracing backends Paolo Bonzini
2021-10-14 16:29 ` [PULL 26/26] configure: automatically parse command line for meson -D options Paolo Bonzini
2021-10-14 19:15 ` [PULL 00/26] Meson changes for 2021-10-14 Richard Henderson

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=20211014162938.430211-22-pbonzini@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=marcandre.lureau@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).