From nobody Mon Feb 9 08:28:20 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=quarantine dis=quarantine) header.from=seoss.co.uk ARC-Seal: i=1; a=rsa-sha256; t=1689257841; cv=none; d=zohomail.com; s=zohoarc; b=WZQEAa01yYEwxW2phaPdQLBvgTucSf+9JKk5SACQuvnyZ5tpYOypRETRhSkSMSK+BMsSyW7aC8Ld+0Dv3x3n3IeE4OLo16Mw3o7oRCdquiwROBwkZrmzThlmGlAN4gwd4TrfI1tzyvaGF9pmTi7q4H1IR3l263nJ1s/3zj5JI/0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1689257841; h=Content-Type: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:To; bh=MFUyecVoa1ftM/Q7dfF2wVl6o7oUuF47zmMoo+/pht4=; b=TcjEd1TUlHTwVXXBcnDKuThU803ptFsaOPqgg60mPRfuA6TF3ewVu49/dC7/cFZ9yE4Xk2Wl5//NMypqxxgq9iHOyO/s6M9oKsXBzQeZgo2d+DQarJQp7klrn+IS+mSaTYUl1RLqkOsonRCUNx3cwsvIw4/56No1a/pnpHBhbNA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail header.from= (p=quarantine dis=quarantine) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1689257841024972.5290270748336; Thu, 13 Jul 2023 07:17:21 -0700 (PDT) Received: from mimecast-mx02.redhat.com (66.187.233.73 [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-527-MvYdSRoxMwapeanSBWjyyw-1; Thu, 13 Jul 2023 10:16:20 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 2C5573C1D629; Thu, 13 Jul 2023 14:07:50 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id A6B9140C2063; Thu, 13 Jul 2023 14:07:49 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id C07EC19543A7; Thu, 13 Jul 2023 14:05:51 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 400BA1946589 for ; Thu, 13 Jul 2023 11:43:30 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 20053C1ED96; Thu, 13 Jul 2023 11:43:30 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast10.extmail.prod.ext.rdu2.redhat.com [10.11.55.26]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 18FA1C478DF for ; Thu, 13 Jul 2023 11:43:30 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-inbound-delivery-1.mimecast.com [205.139.110.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id F2BF01C17114 for ; Thu, 13 Jul 2023 11:43:29 +0000 (UTC) Received: from relay0.allsecuredomains.com (relay0.allsecuredomains.com [51.68.204.196]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-222-0TOoyfXvNnqRVe9RjsVnSg-1; Thu, 13 Jul 2023 07:43:28 -0400 Received: from [81.174.144.187] (helo=custard.lan) by relay0.allsecuredomains.com with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qJu3W-0006s8-ND; Thu, 13 Jul 2023 11:00:18 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1689257839; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=MFUyecVoa1ftM/Q7dfF2wVl6o7oUuF47zmMoo+/pht4=; b=Bup9XbX1jwZ8bcY/z+qIFDnPZbsPMkdLhQU602CBBy8ENrIRJzAfz820jSMQr2QtWFR8hv eWLUzQvUYCa15KPJ8p/FXKvopf47dnjKwfj6HUgtYfFpFk9bdXL8e20OAytQZiIFxz6zAZ byAXyNtPB/Mo85Rv7OWeTFQJNA+/+QI= X-MC-Unique: MvYdSRoxMwapeanSBWjyyw-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: 0TOoyfXvNnqRVe9RjsVnSg-1 From: Tim Small To: libvir-list@redhat.com Subject: [libvirt PATCH 05/10] docs: Add config instructions for clangd with libvirt Date: Thu, 13 Jul 2023 11:59:59 +0100 Message-Id: <20230713110004.1878682-6-tim@seoss.co.uk> In-Reply-To: <20230713110004.1878682-1-tim@seoss.co.uk> References: <20230713110004.1878682-1-tim@seoss.co.uk> MIME-Version: 1.0 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Tim Small Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: seoss.co.uk Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1689257902142100001 Content-Type: text/plain; charset="utf-8"; x-default="true" In build environments which use gcc as the default compiler, use of the clangd LSP server (for enhanced code editing and navigation etc.) with libvirt requires some additional configuration. Detail this and link from `hacking.rst`. Signed-off-by: Tim Small --- docs/clangd.rst | 51 ++++++++++++++++++++++++++++++++++++++++++++++++ docs/hacking.rst | 3 +++ docs/meson.build | 1 + 3 files changed, 55 insertions(+) create mode 100644 docs/clangd.rst diff --git a/docs/clangd.rst b/docs/clangd.rst new file mode 100644 index 0000000000..93570ae178 --- /dev/null +++ b/docs/clangd.rst @@ -0,0 +1,51 @@ +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D +Using Clangd with Libvirt +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D + +`clangd `__ is an implementation of the +`language server protocol +`__ for C +and C++. + +When paired with an LSP-compatible editor or IDE (e.g. emacs, +vim, vscode), ``clangd`` can helpful when working with libvirt's +C sources e.g. navigating the code base. + +Whilst other C LSPs are available, ``clangd`` should work +correctly with the libvirt because clang is a supported compiler +for libvirt, and ``clangd`` is part of the same code base as +clang. + +If clang is the default compiler on your system, then ``clangd`` +can be used as soon as ``meson setup`` has been run. + +If gcc is your build environment's default compiler, then +additional steps are required to use ``clangd``: + +``clangd`` looks for a ``compile_commands.json`` file in the top +level directory of the project and also in the ``build/`` +subdirectory to discover which include paths, compiler flags etc. +should be used when it parses each source file. + +Meson creates a ``compile_commands.json`` in the build directory. +Meson defaults to the system's default C compiler. When the +default compiler is gcc, its ``compile_commands.json`` output +cannot be used with ``clangd`` due to differences in compiler +invocation flags when building libvirt. + +Create a separate build directory with a ``clangd`` compatible +``compile_commands.json`` as follows: + +:: + + CC=3Dclang CXX=3Dclang++ meson setup build-clang + +Point ``clangd`` (v12 or later) at the correct +``compile_commands.json`` by placing the following into a +``.clangd`` file in the root of the project: + +:: + + --- + CompileFlags: + CompilationDatabase: "build-clang" diff --git a/docs/hacking.rst b/docs/hacking.rst index a04da9cb58..11cd21223a 100644 --- a/docs/hacking.rst +++ b/docs/hacking.rst @@ -28,6 +28,9 @@ The `"Git checkout" section = `__ of the libvirt installation instructions give an overview of the compilation process. =20 +Optionally, `Clangd with libvirt `__ can be used to +navigate the code base etc. within most code editors (and IDEs). + Preparing patches =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =20 diff --git a/docs/meson.build b/docs/meson.build index 201fd4c984..70d271ec6e 100644 --- a/docs/meson.build +++ b/docs/meson.build @@ -32,6 +32,7 @@ docs_rst_files =3D [ 'ci', 'ci-dashboard', 'ci-runners', + 'clangd', 'coding-style', 'committer-guidelines', 'compiling', --=20 2.39.2