From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id EA1CEA052A; Tue, 26 Jan 2021 15:19:13 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B3F95140CDE; Tue, 26 Jan 2021 15:19:13 +0100 (CET) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by mails.dpdk.org (Postfix) with ESMTP id D4FA0140CD6 for ; Tue, 26 Jan 2021 15:19:11 +0100 (CET) IronPort-SDR: be3X3GAM0Ug+jrnVxzp7z0Vt+3jU4qG1gewMUcpDIZoaNueQCUtYvZ218bUgM3/Gw5SXW8R2W7 CilhsLaWXd5Q== X-IronPort-AV: E=McAfee;i="6000,8403,9875"; a="179986212" X-IronPort-AV: E=Sophos;i="5.79,375,1602572400"; d="scan'208";a="179986212" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Jan 2021 06:19:09 -0800 IronPort-SDR: 4dR0dqXmIDKKKxTfNhodkxaX+lEJvx7wkuK7NcPdbvt5Yod45qA/FV6QaueLccDtKCZdt5wymY tP/fjBnZ21Tw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.79,375,1602572400"; d="scan'208";a="361995409" Received: from silpixa00399126.ir.intel.com ([10.237.222.4]) by fmsmga008.fm.intel.com with ESMTP; 26 Jan 2021 06:19:07 -0800 From: Bruce Richardson To: dev@dpdk.org Cc: david.marchand@redhat.com, Bruce Richardson Date: Tue, 26 Jan 2021 14:18:49 +0000 Message-Id: <20210126141857.1029916-1-bruce.richardson@intel.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210114110606.21142-1-bruce.richardson@intel.com> References: <20210114110606.21142-1-bruce.richardson@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v4 0/7] add checking of header includes X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" As a general principle, each header file should include any other headers it needs to provide data type definitions or macros. For example, any header using the uintX_t types in structures or function prototypes should include "stdint.h" to provide those type definitions. In practice, while many, but not all, headers in DPDK did include all necessary headers, it was never actually checked that each header could be included in a C file and compiled without having any compiler errors about missing definitions. The script "check-includes.sh" could be used for this job, but it was not called out in the documentation, so many contributors may not have been aware of it's existance. It also was difficult to run from a source-code directory, as the script did not automatically allow finding of headers from one DPDK library directory to another [this was probably based on running it on a build created by the "make" build system, where all headers were in a single directory]. To attempt to have a build-system integrated replacement, this patchset adds a "chkincs" app in the buildtools directory to verify this on an ongoing basis. This chkincs app does nothing when run, and is not installed as part of a DPDK "ninja install", it's for build-time checking only. Its source code consists of one C file per public DPDK header, where that C file contains nothing except an include for that header. Therefore, if any header is added to the lib folder which fails to compile when included alone, the build of chkincs will fail with a suitable error message. Since this compile checking is not needed on most builds of DPDK, the building of chkincs is disabled by default, but can be enabled by the "test_includes" meson option. To catch errors with patch submissions, the final patch of this series enables it for a single build in test-meson-builds script. Future work could involve doing similar checks on headers for C++ compatibility, which was something done by the check-includes.sh script but which is missing here. V4: * Fixed build errors with clang and arm builds * Added support for running chkincs as part of github actions CI V3: * Shrunk patchset as most header fixes already applied * Moved chkincs from "apps" to the "buildtools" directory, which is a better location for something not for installation for end-user use. * Added patch to drop check-includes script. V2: * Add maintainers file entry for new app * Drop patch for c11 ring header * Use build variable "headers_no_chkincs" for tracking exceptions Bruce Richardson (7): eal: add missing include to mcslock eal: fix error attribute use for clang rib: fix missing header include build: separate out headers for include checking buildtools/chkincs: add app to verify header includes devtools: remove check-includes script ci: add checking of includes to CI builds .ci/linux-build.sh | 1 + MAINTAINERS | 5 +- buildtools/chkincs/gen_c_file_for_header.py | 12 + buildtools/chkincs/main.c | 4 + buildtools/chkincs/meson.build | 41 +++ devtools/check-includes.sh | 259 ------------------- devtools/test-meson-builds.sh | 2 +- doc/guides/contributing/coding_style.rst | 12 + lib/librte_eal/include/generic/rte_mcslock.h | 1 + lib/librte_eal/include/meson.build | 2 +- lib/librte_eal/include/rte_compat.h | 8 +- lib/librte_eal/x86/include/meson.build | 14 +- lib/librte_ethdev/meson.build | 4 +- lib/librte_hash/meson.build | 4 +- lib/librte_ipsec/meson.build | 3 +- lib/librte_lpm/meson.build | 2 +- lib/librte_regexdev/meson.build | 2 +- lib/librte_rib/rte_rib6.h | 1 + lib/librte_ring/meson.build | 4 +- lib/librte_stack/meson.build | 4 +- lib/librte_table/meson.build | 7 +- lib/meson.build | 3 + meson.build | 6 + meson_options.txt | 2 + 24 files changed, 122 insertions(+), 281 deletions(-) create mode 100755 buildtools/chkincs/gen_c_file_for_header.py create mode 100644 buildtools/chkincs/main.c create mode 100644 buildtools/chkincs/meson.build delete mode 100755 devtools/check-includes.sh -- 2.27.0