From nobody Wed Feb 11 07:13:13 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1694502989; cv=none; d=zohomail.com; s=zohoarc; b=RZpWKT2K4IEqxxJ3h1+ErlRP1ooJFIWZ97mrdoP2xszp22CVkjUdytgilAshWgdcX7VCxynAO7cjXGhJWZ4WQ/n844RUusrWJWM23twWLVwI7yEeZVFwpWZb7Z5tkTv5Jes9WMCyvCkZr4yLB9T7lWwRmwRXue4tBXXuKbVfuX8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694502989; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject; bh=UJRUv8O4TokTXkVqeubhuAV8gl+wRJjs7dLP5rlsco4=; b=WHzk21jFzn3OgexXMdEuLNpk6DLOuoLA03nISQUqire7knxxH/RUvvS/VaA8ahUeuBfXgg3RomkgOOuzbxYIoZKr4SQoSyTce0k3xzmzc7ngpZgGLyLg/j6BQhg9spWB8H+xFJrvuQQJnvWReOF97sZP1NlCOmzFmf6kC+OTu3g= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1694502989247368.54392109719663; Tue, 12 Sep 2023 00:16:29 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qfxaN-0003Kp-G3; Tue, 12 Sep 2023 03:13:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qfxaG-0003Dg-A1 for qemu-devel@nongnu.org; Tue, 12 Sep 2023 03:13:16 -0400 Received: from mail-ot1-x330.google.com ([2607:f8b0:4864:20::330]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qfxaE-0006h5-0d for qemu-devel@nongnu.org; Tue, 12 Sep 2023 03:13:16 -0400 Received: by mail-ot1-x330.google.com with SMTP id 46e09a7af769-6c0bbbbad81so3241572a34.3 for ; Tue, 12 Sep 2023 00:13:13 -0700 (PDT) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:78d2:b862:10a7:d486]) by smtp.gmail.com with ESMTPSA id f13-20020aa78b0d000000b0068be348e35fsm6647495pfd.166.2023.09.12.00.13.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Sep 2023 00:13:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1694502793; x=1695107593; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=UJRUv8O4TokTXkVqeubhuAV8gl+wRJjs7dLP5rlsco4=; b=iT9R1jY2Sm0WYzrnybPkQzUVrqwNnpQGa/ZyWEXMXoNs1qGEyPOolJbXq7lgt8zN6n BoNMg9pad1nGhdfGa/+vPEVsxnRlKz39iZ+3E4PvnE+1NwEnSPIOJxXnecIOc8eT18i9 ImUj+st4ZCeGtmucZHdoRD82br5cpeGbWGlS8lHZ1VUVmgym2wI9nq6d6DUowICW+huq JE4AIckwmTGys1LVxMWuqplXES9mKOUt460HlPXcF7D80ldMDY7JW1Nj4FsL89/MfNrd T+l0Wxa1UHnc++zL5CHZDluiKZVl5LIqN0Fsi0i4ZYP/MFehdblYK6Sw0eZZjJck/6s6 j+yw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694502793; x=1695107593; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=UJRUv8O4TokTXkVqeubhuAV8gl+wRJjs7dLP5rlsco4=; b=IssysNct7rxwNlCkDy4W7atdZb9TRaMKfSKbKC/jIDwhiT78Md2DVft3x5ro0Wmr1T 5CV62/gh1erhglhs0FumM59qtiC8nLBpmNqo/MXDR2dX0URuANTNrcuM6VM+pbXanlHd lPh4CMYF0OHcP7wpuMmVn39p7gH8GyJxwOFY+FnAn8zZpqDtrX5g2mBEtWor41KnWcLB XcrAF+HShoOL6Y2eYXAMcwcooBTyWKsoS4q3GmNXLWPLzEmAPymCzjGEyenOaUHgtyhV DrZS2LmdnXRZadhlSFHGdSBRooXD54co4Y2/xi7IMOl82b8diQtlg384fuIAOcuBvBff Vozg== X-Gm-Message-State: AOJu0YxKx1xW4cddoTmBaGwRdru+vTjKnE1AdcoMYCT2eV3nCqO5KuX2 s+irxzwqTU+XqCpyj8sfwDfYpA== X-Google-Smtp-Source: AGHT+IHItpms03KXongM82cEE9tfs/RWCPKvo6cAAnLqT5at8V7xHjpGYa8P8FiehY8pk9Gt1FaBPA== X-Received: by 2002:a05:6358:2789:b0:134:c859:d32a with SMTP id l9-20020a056358278900b00134c859d32amr11061179rwb.25.1694502793054; Tue, 12 Sep 2023 00:13:13 -0700 (PDT) From: Akihiko Odaki To: Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= , Mikhail Tyutin , Aleksandr Anenkov , qemu-devel@nongnu.org, Akihiko Odaki , Paolo Bonzini , Thomas Huth , Alexandre Iooss , Mahmoud Mandour , Richard Henderson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v7 18/18] contrib/plugins: Add cc plugin Date: Tue, 12 Sep 2023 16:12:04 +0900 Message-ID: <20230912071206.30751-19-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230912071206.30751-1-akihiko.odaki@daynix.com> References: <20230912071206.30751-1-akihiko.odaki@daynix.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::330; envelope-from=akihiko.odaki@daynix.com; helo=mail-ot1-x330.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @daynix-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1694502990723100011 Content-Type: text/plain; charset="utf-8" This demonstrates how to write a plugin in C++. Signed-off-by: Akihiko Odaki --- docs/devel/tcg-plugins.rst | 8 ++++++++ configure | 15 ++++++++++++--- contrib/plugins/Makefile | 5 +++++ contrib/plugins/cc.cc | 17 +++++++++++++++++ tests/tcg/Makefile.target | 3 +++ 5 files changed, 45 insertions(+), 3 deletions(-) create mode 100644 contrib/plugins/cc.cc diff --git a/docs/devel/tcg-plugins.rst b/docs/devel/tcg-plugins.rst index c9f8b27590..0a11f8036c 100644 --- a/docs/devel/tcg-plugins.rst +++ b/docs/devel/tcg-plugins.rst @@ -584,6 +584,14 @@ The plugin has a number of arguments, all of them are = optional: configuration arguments implies ``l2=3Don``. (default: N =3D 2097152 (2MB), B =3D 64, A =3D 16) =20 +- contrib/plugins/cc.cc + +cc plugin demonstrates how to write a plugin in C++. It simply outputs +"hello, world" to the plugin log:: + + $ qemu-system-arm $(QEMU_ARGS) \ + -plugin ./contrib/plugins/libcc.so -d plugin + API --- =20 diff --git a/configure b/configure index b9bd008592..c3cd5a15e7 100755 --- a/configure +++ b/configure @@ -293,10 +293,18 @@ else cc=3D"${CC-${cross_prefix}gcc}" fi =20 -if test -z "${CXX}${cross_prefix}"; then - cxx=3D"c++" +if test -n "${CXX+x}"; then + cxx=3D"$CXX" else - cxx=3D"${CXX-${cross_prefix}g++}" + if test -n "${cross_prefix}"; then + cxx=3D"${cross_prefix}g++" + else + cxx=3D"c++" + fi + + if ! has "$cxx"; then + cxx=3D + fi fi =20 # Preferred ObjC compiler: @@ -1765,6 +1773,7 @@ echo "MESON=3D$meson" >> $config_host_mak echo "NINJA=3D$ninja" >> $config_host_mak echo "PKG_CONFIG=3D${pkg_config}" >> $config_host_mak echo "CC=3D$cc" >> $config_host_mak +echo "CXX=3D$cxx" >> $config_host_mak echo "EXESUF=3D$EXESUF" >> $config_host_mak =20 # use included Linux headers for KVM architectures diff --git a/contrib/plugins/Makefile b/contrib/plugins/Makefile index b2b9db9f51..93d86b3d07 100644 --- a/contrib/plugins/Makefile +++ b/contrib/plugins/Makefile @@ -21,6 +21,9 @@ NAMES +=3D lockstep NAMES +=3D hwprofile NAMES +=3D cache NAMES +=3D drcov +ifneq ($(CXX),) +NAMES +=3D cc +endif =20 SONAMES :=3D $(addsuffix .so,$(addprefix lib,$(NAMES))) =20 @@ -31,6 +34,8 @@ CFLAGS +=3D -fPIC -Wall CFLAGS +=3D $(if $(CONFIG_DEBUG_TCG), -ggdb -O0) CFLAGS +=3D -I$(SRC_PATH)/include/qemu =20 +CXXFLAGS :=3D $(CFLAGS) + all: $(SONAMES) =20 %.o: %.c diff --git a/contrib/plugins/cc.cc b/contrib/plugins/cc.cc new file mode 100644 index 0000000000..83a5528db0 --- /dev/null +++ b/contrib/plugins/cc.cc @@ -0,0 +1,17 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + +#include + +extern "C" { + +QEMU_PLUGIN_EXPORT int qemu_plugin_version =3D QEMU_PLUGIN_VERSION; + +QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin_id_t id, + const qemu_info_t *info, int ar= gc, + char **argv) +{ + qemu_plugin_outs("hello, world\n"); + return 0; +} + +}; diff --git a/tests/tcg/Makefile.target b/tests/tcg/Makefile.target index 462289f47c..3d7837d3b8 100644 --- a/tests/tcg/Makefile.target +++ b/tests/tcg/Makefile.target @@ -149,6 +149,9 @@ PLUGIN_SRC=3D$(SRC_PATH)/tests/plugin PLUGIN_LIB=3D../../plugin VPATH+=3D$(PLUGIN_LIB) PLUGINS=3D$(patsubst %.c, lib%.so, $(notdir $(wildcard $(PLUGIN_SRC)/*.c))) +ifneq ($(CXX),) +PLUGINS+=3D$(patsubst %.cc, lib%.so, $(notdir $(wildcard $(PLUGIN_SRC)/*.c= c))) +endif =20 # We need to ensure expand the run-plugin-TEST-with-PLUGIN # pre-requistes manually here as we can't use stems to handle it. We --=20 2.42.0