From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Subject: [PULL 023/150] meson: add sparse support
Date: Tue, 18 Aug 2020 10:08:18 -0400 [thread overview]
Message-ID: <20200818141025.21608-24-pbonzini@redhat.com> (raw)
In-Reply-To: <20200818141025.21608-1-pbonzini@redhat.com>
Do not use cgcc; instead, extract compilation commands from compile_commands.json
and invoke sparse directly.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
Makefile | 1 +
configure | 8 ++------
meson.build | 7 +++++++
scripts/check_sparse.py | 25 +++++++++++++++++++++++++
4 files changed, 35 insertions(+), 6 deletions(-)
create mode 100644 scripts/check_sparse.py
diff --git a/Makefile b/Makefile
index 7e9663aeb7..6198236c40 100644
--- a/Makefile
+++ b/Makefile
@@ -1256,6 +1256,7 @@ endif
$(call print-help,install,Install QEMU, documentation and tools)
$(call print-help,ctags/TAGS,Generate tags file for editors)
$(call print-help,cscope,Generate cscope index)
+ $(call print-help,sparse,Run sparse on the QEMU source)
@echo ''
@$(if $(TARGET_DIRS), \
echo 'Architecture specific targets:'; \
diff --git a/configure b/configure
index 41c20ade4e..5263ec7d43 100755
--- a/configure
+++ b/configure
@@ -3009,7 +3009,7 @@ fi
##########################################
# Sparse probe
if test "$sparse" != "no" ; then
- if has cgcc; then
+ if has sparse; then
sparse=yes
else
if test "$sparse" = "yes" ; then
@@ -7810,11 +7810,7 @@ echo "QEMU_CFLAGS=$QEMU_CFLAGS" >> $config_host_mak
echo "QEMU_CXXFLAGS=$QEMU_CXXFLAGS" >> $config_host_mak
echo "QEMU_INCLUDES=$QEMU_INCLUDES" >> $config_host_mak
if test "$sparse" = "yes" ; then
- echo "CC := REAL_CC=\"\$(CC)\" cgcc" >> $config_host_mak
- echo "CPP := REAL_CC=\"\$(CPP)\" cgcc" >> $config_host_mak
- echo "CXX := REAL_CC=\"\$(CXX)\" cgcc" >> $config_host_mak
- echo "HOST_CC := REAL_CC=\"\$(HOST_CC)\" cgcc" >> $config_host_mak
- echo "QEMU_CFLAGS += -Wbitwise -Wno-transparent-union -Wno-old-initializer -Wno-non-pointer-null" >> $config_host_mak
+ echo "SPARSE_CFLAGS = -Wbitwise -Wno-transparent-union -Wno-old-initializer -Wno-non-pointer-null" >> $config_host_mak
fi
echo "QEMU_LDFLAGS=$QEMU_LDFLAGS" >> $config_host_mak
echo "LDFLAGS_NOPIE=$LDFLAGS_NOPIE" >> $config_host_mak
diff --git a/meson.build b/meson.build
index 7f15799933..eb0d2ed992 100644
--- a/meson.build
+++ b/meson.build
@@ -22,6 +22,13 @@ if host_machine.system() == 'darwin'
add_languages('objc', required: false, native: false)
endif
+if 'SPARSE_CFLAGS' in config_host
+ run_target('sparse',
+ command: [find_program('scripts/check_sparse.py'),
+ config_host['SPARSE_CFLAGS'].split(),
+ 'compile_commands.json'])
+endif
+
configure_file(input: files('scripts/ninjatool.py'),
output: 'ninjatool',
configuration: config_host)
diff --git a/scripts/check_sparse.py b/scripts/check_sparse.py
new file mode 100644
index 0000000000..0de7aa55d9
--- /dev/null
+++ b/scripts/check_sparse.py
@@ -0,0 +1,25 @@
+#! /usr/bin/env python3
+
+# Invoke sparse based on the contents of compile_commands.json
+
+import json
+import subprocess
+import sys
+import shlex
+
+def extract_cflags(shcmd):
+ cflags = shlex.split(shcmd)
+ return [x for x in cflags
+ if x.startswith('-D') or x.startswith('-I') or x.startswith('-W')
+ or x.startswith('-std=')]
+
+cflags = sys.argv[1:-1]
+with open(sys.argv[-1], 'r') as fd:
+ compile_commands = json.load(fd)
+
+for cmd in compile_commands:
+ cmd = ['sparse'] + cflags + extract_cflags(cmd['command']) + [cmd['file']]
+ print(' '.join((shlex.quote(x) for x in cmd)))
+ r = subprocess.run(cmd)
+ if r.returncode != 0:
+ sys.exit(r.returncode)
--
2.26.2
next prev parent reply other threads:[~2020-08-18 14:15 UTC|newest]
Thread overview: 160+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-18 14:07 [PULL 000/150] Meson-based build system Paolo Bonzini
2020-08-18 14:07 ` [PULL 001/150] oss-fuzz/build: remove LIB_FUZZING_ENGINE Paolo Bonzini
2020-08-18 14:07 ` [PULL 002/150] optionrom: simplify Makefile Paolo Bonzini
2020-08-18 14:07 ` [PULL 003/150] pc-bios/s390-ccw: do not use rules.mak Paolo Bonzini
2020-08-18 14:07 ` [PULL 004/150] trace: switch position of headers to what Meson requires Paolo Bonzini
2020-08-18 14:08 ` [PULL 005/150] meson: rename included C source files to .c.inc Paolo Bonzini
2020-08-18 14:08 ` [PULL 006/150] meson: rename .inc.h files to .h.inc Paolo Bonzini
2020-08-18 14:08 ` [PULL 007/150] build-sys hack: ensure target directory is there Paolo Bonzini
2020-08-18 14:08 ` [PULL 008/150] tests/vm: do not pollute configure with --efi-aarch64 Paolo Bonzini
2020-08-18 14:08 ` [PULL 009/150] tests/vm: check for Python YAML parser in the Makefile Paolo Bonzini
2020-08-18 14:08 ` [PULL 010/150] tests/docker: add test script for static linux-user builds Paolo Bonzini
2020-08-18 14:08 ` [PULL 011/150] nsis: use "make DESTDIR=" instead of "make prefix=" Paolo Bonzini
2020-08-18 14:08 ` [PULL 012/150] configure: do not include $(...) variables in config-host.mak Paolo Bonzini
2020-08-18 14:08 ` [PULL 013/150] configure: expand path variables for meson configure Paolo Bonzini
2020-08-18 14:08 ` [PULL 014/150] configure: prepare CFLAGS/CXXFLAGS/LDFLAGS for Meson Paolo Bonzini
2020-08-18 14:08 ` [PULL 015/150] tests/vm: include setuptools Paolo Bonzini
2020-08-18 14:08 ` [PULL 016/150] configure: integrate Meson in the build system Paolo Bonzini
2020-08-18 14:08 ` [PULL 017/150] configure: generate Meson cross file Paolo Bonzini
2020-08-18 14:08 ` [PULL 018/150] build-sys hack: link with whole .fa archives Paolo Bonzini
2020-08-18 14:08 ` [PULL 019/150] build-sys: add meson submodule Paolo Bonzini
2020-08-18 14:08 ` [PULL 020/150] meson: move summary to meson.build Paolo Bonzini
2020-08-18 14:08 ` [PULL 021/150] meson: enable pie Paolo Bonzini
2020-08-18 14:08 ` [PULL 022/150] meson: use coverage option Paolo Bonzini
2020-08-18 14:08 ` Paolo Bonzini [this message]
2020-08-18 14:08 ` [PULL 024/150] meson: add testsuite Makefile generator Paolo Bonzini
2020-08-18 14:08 ` [PULL 025/150] libqemuutil, qapi, trace: convert to meson Paolo Bonzini
2020-08-18 14:08 ` [PULL 026/150] meson: add remaining generated tcg trace helpers Paolo Bonzini
2020-08-18 14:08 ` [PULL 027/150] meson: add version.o Paolo Bonzini
2020-08-18 14:08 ` [PULL 028/150] contrib/libvhost-user: convert to Meson Paolo Bonzini
2020-08-18 14:08 ` [PULL 029/150] tools/virtiofsd: " Paolo Bonzini
2020-08-18 14:08 ` [PULL 030/150] contrib/vhost-user-blk: " Paolo Bonzini
2020-08-18 14:08 ` [PULL 031/150] vhost-user-scsi: add compatibility for libiscsi 1.9.0 Paolo Bonzini
2020-08-18 14:08 ` [PULL 032/150] contrib/vhost-user-scsi: convert to Meson Paolo Bonzini
2020-08-18 14:08 ` [PULL 033/150] contrib/rdmacm-mux: " Paolo Bonzini
2020-08-18 14:08 ` [PULL 034/150] contrib/vhost-user-input: convert to meson Paolo Bonzini
2020-08-18 14:08 ` [PULL 035/150] contrib/vhost-user-gpu: " Paolo Bonzini
2020-08-18 14:08 ` [PULL 036/150] contrib/ivshmem: " Paolo Bonzini
2020-08-18 14:08 ` [PULL 037/150] contrib/elf2dmp: " Paolo Bonzini
2020-08-18 14:08 ` [PULL 038/150] meson: add macos dependencies Paolo Bonzini
2020-08-18 14:08 ` [PULL 039/150] meson: add solaris and Haiku libraries Paolo Bonzini
2020-08-18 14:08 ` [PULL 040/150] meson: convert qemu-ga Paolo Bonzini
2020-08-18 14:08 ` [PULL 041/150] meson: convert vss-win32 Paolo Bonzini
2020-08-18 14:08 ` [PULL 042/150] meson: add msi generation Paolo Bonzini
2020-08-18 14:08 ` [PULL 043/150] meson: convert dummy Windows qga/qemu-ga target Paolo Bonzini
2020-08-18 14:08 ` [PULL 044/150] meson: add qemu-bridge-helper Paolo Bonzini
2020-08-18 14:08 ` [PULL 045/150] meson: add qemu-keymap Paolo Bonzini
2020-08-18 14:08 ` [PULL 046/150] meson: add qemu-edid Paolo Bonzini
2020-08-18 14:08 ` [PULL 047/150] meson: add virtfs-proxy-helper Paolo Bonzini
2020-08-18 14:08 ` [PULL 048/150] meson: keymap-gen Paolo Bonzini
2020-08-18 14:08 ` [PULL 049/150] meson: generate qemu-version.h Paolo Bonzini
2020-08-18 14:08 ` [PULL 050/150] meson: generate shader headers Paolo Bonzini
2020-08-18 14:08 ` [PULL 051/150] meson: generate hxtool files Paolo Bonzini
2020-08-18 14:08 ` [PULL 052/150] meson: handle edk2 bios and descriptors Paolo Bonzini
2020-08-18 14:08 ` [PULL 053/150] meson: convert check-decodetree Paolo Bonzini
2020-08-18 14:08 ` [PULL 054/150] meson: convert tests/fp and check-softfloat Paolo Bonzini
2020-08-18 14:08 ` [PULL 055/150] meson: convert check-qapi-schema Paolo Bonzini
2020-08-18 14:08 ` [PULL 056/150] meson: convert qom directory to Meson (tools part) Paolo Bonzini
2020-08-18 14:08 ` [PULL 057/150] meson: convert authz directory to Meson Paolo Bonzini
2020-08-18 14:08 ` [PULL 058/150] meson: convert crypto " Paolo Bonzini
2020-08-18 14:08 ` [PULL 059/150] meson: convert io " Paolo Bonzini
2020-08-18 14:08 ` [PULL 060/150] meson: convert target/s390x/gen-features.h Paolo Bonzini
2020-08-18 14:08 ` [PULL 061/150] meson: infrastructure for building emulators Paolo Bonzini
2020-08-18 14:08 ` [PULL 062/150] meson: add modules infrastructure Paolo Bonzini
2020-08-18 14:08 ` [PULL 063/150] meson: convert chardev directory to Meson (tools part) Paolo Bonzini
2020-08-18 14:08 ` [PULL 064/150] meson: convert block Paolo Bonzini
2020-08-18 14:09 ` [PULL 065/150] meson: qemu-{img,io,nbd} Paolo Bonzini
2020-08-18 14:09 ` [PULL 066/150] meson: qemu-pr-helper Paolo Bonzini
2020-08-18 14:09 ` [PULL 067/150] configure, Makefile; remove TOOLS and HELPERS-y variable Paolo Bonzini
2020-08-18 14:09 ` [PULL 068/150] meson: convert chardev directory to Meson (emulator part) Paolo Bonzini
2020-08-18 14:09 ` [PULL 069/150] meson: convert tests/qtest to meson Paolo Bonzini
2020-08-18 14:09 ` [PULL 070/150] meson: convert audio directory to Meson Paolo Bonzini
2020-08-18 14:09 ` [PULL 071/150] meson: convert ui " Paolo Bonzini
2020-08-18 14:09 ` [PULL 072/150] meson: convert root " Paolo Bonzini
2020-08-18 14:09 ` [PULL 073/150] meson: convert most of softmmu/ Paolo Bonzini
2020-08-18 14:09 ` [PULL 074/150] meson: convert trace/ Paolo Bonzini
2020-08-18 14:09 ` [PULL 075/150] meson: convert dump/ Paolo Bonzini
2020-08-18 14:09 ` [PULL 076/150] meson: convert common QMP bits for qemu and qemu-storage-daemon Paolo Bonzini
2020-08-18 14:09 ` [PULL 077/150] meson: convert qemu-storage-daemon Paolo Bonzini
2020-08-18 14:09 ` [PULL 078/150] meson: convert replay directory to Meson Paolo Bonzini
2020-08-18 14:09 ` [PULL 079/150] meson: convert migration " Paolo Bonzini
2020-08-18 14:09 ` [PULL 080/150] meson: convert net " Paolo Bonzini
2020-08-18 14:09 ` [PULL 081/150] meson: convert backends " Paolo Bonzini
2020-08-18 14:09 ` [PULL 082/150] meson: convert fsdev/ Paolo Bonzini
2020-08-18 14:09 ` [PULL 083/150] meson: convert disas directory to Meson Paolo Bonzini
2020-08-18 14:09 ` [PULL 084/150] meson: convert qapi-specific to meson Paolo Bonzini
2020-08-18 14:09 ` [PULL 085/150] meson: convert hw/xen Paolo Bonzini
2020-08-18 14:09 ` [PULL 086/150] meson: convert hw/core Paolo Bonzini
2020-08-18 14:09 ` [PULL 087/150] meson: convert hw/semihosting Paolo Bonzini
2020-08-18 14:09 ` [PULL 088/150] meson: convert hw/nubus Paolo Bonzini
2020-08-18 14:09 ` [PULL 089/150] meson: convert hw/smbios Paolo Bonzini
2020-08-18 14:09 ` [PULL 090/150] meson: convert hw/mem Paolo Bonzini
2020-08-18 14:09 ` [PULL 091/150] meson: convert hw/watchdog Paolo Bonzini
2020-08-18 14:09 ` [PULL 092/150] meson: convert hw/virtio Paolo Bonzini
2020-08-18 14:09 ` [PULL 093/150] meson: convert hw/vfio Paolo Bonzini
2020-08-18 14:09 ` [PULL 094/150] meson: convert hw/usb Paolo Bonzini
2020-08-18 14:09 ` [PULL 095/150] meson: convert hw/tpm Paolo Bonzini
2020-08-18 14:09 ` [PULL 096/150] meson: convert hw/timer Paolo Bonzini
2020-08-18 14:09 ` [PULL 097/150] meson: convert hw/rtc Paolo Bonzini
2020-08-18 14:09 ` [PULL 098/150] meson: convert hw/ssi Paolo Bonzini
2020-08-18 14:09 ` [PULL 099/150] meson: convert hw/sd Paolo Bonzini
2020-08-18 14:09 ` [PULL 100/150] meson: convert hw/scsi Paolo Bonzini
2020-08-18 14:09 ` [PULL 101/150] meson: convert hw/pcmcia Paolo Bonzini
2020-08-18 14:09 ` [PULL 102/150] meson: convert hw/pci-host Paolo Bonzini
2020-08-18 14:09 ` [PULL 103/150] meson: convert hw/pci-bridge Paolo Bonzini
2020-08-18 14:09 ` [PULL 104/150] meson: convert hw/pci Paolo Bonzini
2020-08-18 14:09 ` [PULL 105/150] meson: convert hw/nvram Paolo Bonzini
2020-08-18 14:09 ` [PULL 106/150] meson: convert hw/rdma Paolo Bonzini
2020-08-18 14:09 ` [PULL 107/150] meson: convert hw/net Paolo Bonzini
2020-08-18 14:09 ` [PULL 108/150] meson: convert hw/misc Paolo Bonzini
2020-08-18 14:09 ` [PULL 109/150] meson: convert hw/isa Paolo Bonzini
2020-08-18 14:09 ` [PULL 110/150] meson: convert hw/ipmi Paolo Bonzini
2020-08-18 14:09 ` [PULL 111/150] meson: convert hw/ipack Paolo Bonzini
2020-08-18 14:09 ` [PULL 112/150] meson: convert hw/intc Paolo Bonzini
2020-08-18 14:09 ` [PULL 113/150] meson: convert hw/input Paolo Bonzini
2020-08-18 14:09 ` [PULL 114/150] meson: convert hw/ide Paolo Bonzini
2020-08-18 14:09 ` [PULL 115/150] meson: convert hw/i2c Paolo Bonzini
2020-08-18 14:09 ` [PULL 116/150] meson: convert hw/hyperv Paolo Bonzini
2020-08-18 14:09 ` [PULL 117/150] meson: convert hw/gpio Paolo Bonzini
2020-08-18 14:09 ` [PULL 118/150] meson: convert hw/dma Paolo Bonzini
2020-08-18 14:09 ` [PULL 119/150] meson: convert hw/display Paolo Bonzini
2020-08-18 14:09 ` [PULL 120/150] meson: convert hw/cpu Paolo Bonzini
2020-08-18 14:09 ` [PULL 121/150] meson: convert hw/char Paolo Bonzini
2020-08-18 14:09 ` [PULL 122/150] meson: convert hw/block Paolo Bonzini
2020-08-18 14:09 ` [PULL 123/150] meson: convert hw/audio Paolo Bonzini
2020-08-18 14:09 ` [PULL 124/150] meson: convert hw/adc Paolo Bonzini
2020-08-18 14:10 ` [PULL 125/150] meson: convert hw/acpi Paolo Bonzini
2020-08-18 14:10 ` [PULL 126/150] meson: convert hw/9pfs, cleanup Paolo Bonzini
2020-08-18 14:10 ` [PULL 127/150] meson: convert hw/arch* Paolo Bonzini
2020-08-18 14:10 ` [PULL 128/150] meson: target Paolo Bonzini
2020-08-18 14:10 ` [PULL 129/150] meson: accel Paolo Bonzini
2020-08-18 14:10 ` [PULL 130/150] meson: linux-user Paolo Bonzini
2020-08-18 14:10 ` [PULL 131/150] meson: bsd-user Paolo Bonzini
2020-08-18 14:10 ` [PULL 132/150] meson: cpu-emu Paolo Bonzini
2020-08-18 14:10 ` [PULL 133/150] meson: plugins Paolo Bonzini
2020-08-18 14:10 ` [PULL 134/150] meson: link emulators without Makefile.target Paolo Bonzini
2020-08-18 14:10 ` [PULL 135/150] meson: convert systemtap files Paolo Bonzini
2020-08-18 14:10 ` [PULL 136/150] rules.mak: remove version.o Paolo Bonzini
2020-08-18 14:10 ` [PULL 137/150] remove Makefile.target Paolo Bonzini
2020-08-18 14:10 ` [PULL 138/150] meson: sphinx-build Paolo Bonzini
2020-08-18 14:10 ` [PULL 139/150] docs: automatically track manual dependencies Paolo Bonzini
2020-08-18 14:10 ` [PULL 140/150] meson: build texi doc Paolo Bonzini
2020-08-18 14:10 ` [PULL 141/150] meson: convert check-block Paolo Bonzini
2020-08-18 14:10 ` [PULL 142/150] rules.mak: drop unneeded macros Paolo Bonzini
2020-08-18 14:10 ` [PULL 143/150] meson: replace create-config with meson configure_file Paolo Bonzini
2020-08-18 14:10 ` [PULL 144/150] meson: convert sample plugins Paolo Bonzini
2020-08-18 14:10 ` [PULL 145/150] meson: move SDL and SDL-image detection to meson Paolo Bonzini
2020-08-18 14:10 ` [PULL 146/150] meson: convert VNC and dependent libraries " Paolo Bonzini
2020-08-18 14:10 ` [PULL 147/150] meson: convert po/ Paolo Bonzini
2020-08-19 1:56 ` Brad Smith
2020-08-19 8:03 ` Paolo Bonzini
2020-08-19 16:55 ` Brad Smith
2020-08-18 14:10 ` [PULL 148/150] meson: avoid unstable module warning with Meson 0.56.0 or newer Paolo Bonzini
2020-08-18 14:10 ` [PULL 149/150] meson: update build-system documentation Paolo Bonzini
2020-08-18 14:10 ` [PULL 150/150] docs: convert build system documentation to rST Paolo Bonzini
2020-08-18 14:23 ` [PULL 000/150] Meson-based build system Peter Maydell
2020-08-18 14:33 ` Peter Maydell
2020-08-18 18:05 ` no-reply
2020-08-18 19:26 ` Peter Maydell
2020-08-18 20:10 ` Paolo Bonzini
2020-08-18 20:34 ` Paolo Bonzini
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=20200818141025.21608-24-pbonzini@redhat.com \
--to=pbonzini@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).