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 BA35A45AC7; Sun, 6 Oct 2024 15:09:17 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 37C164025F; Sun, 6 Oct 2024 15:09:17 +0200 (CEST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mails.dpdk.org (Postfix) with ESMTP id D848C4025D for ; Sun, 6 Oct 2024 15:09:15 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1728220155; h=from:from: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; bh=ZbfZV5jobMLLDVPAAAkWivnMxegDRmCremAgmM+is/8=; b=bsZpmDMJeNEnbhzskqQVkC+TLANKCJf9EejQQboxVNorlEG2wlIsGiu3ZWkW6/E9RcFEQe +XwSNSuDc6XCiiPE7yLXh9FMbaB2BgPbknegJOi4YDdvSJCqIBRmWZbggJ+DKsxolnwkWH lLGfYsOowOtgRdXCMLX25nzlbJ0yLuc= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-505-Tc0qn_fhM3uN8fq79wHSfA-1; Sun, 06 Oct 2024 09:09:13 -0400 X-MC-Unique: Tc0qn_fhM3uN8fq79wHSfA-1 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-37ce14d621aso2192253f8f.3 for ; Sun, 06 Oct 2024 06:09:13 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728220153; x=1728824953; h=in-reply-to:references:user-agent:to:from:cc:subject:message-id :date:content-transfer-encoding:mime-version:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=ZbfZV5jobMLLDVPAAAkWivnMxegDRmCremAgmM+is/8=; b=O3wi2pfY0jkokytkyzfHjNxdJZIorzFREuznbAlfNx/Zi1MLjceQj3DQsyuFT+PXUp SX/ZXV0p86WrWmTO7uMihhpIcg4WPKqWzX4qs/G6Yj7NDDAzJ/NIojBXO5SHicgh7Zzj XvKZTTBEJTdquoOfrGI8zj5+Ft1Okfi8meMe7BKLVVH2wyQwB+mgnya4kmI3thw2xDos n1dWtbq5ROkP/PiLFw0pbvI0XJFFS8Knh9HPFipJxI6QcVEglA5yjSDQd+CUaXnXm8qf s1kIC8c9U2ns+yjuTrTmXONzm4ZxIaUfPnz30tAOvn+KUvqx+G9I9JmFiZ4povEtUgYb 4WCw== X-Forwarded-Encrypted: i=1; AJvYcCV8/iG4xt5lnsA1tv33i7EzgNbMdxfoDTkB1qvaU+zbAV2EZGwCHc8lxxGVw5XafmGn9AA=@dpdk.org X-Gm-Message-State: AOJu0YxWwwzTCuh2JFmdQcMpSJgMekTuYoa3rhQMZzaAtmuI42sNON/5 P+mkGujfsQaytja5td4dFOm+495X7+A7QokeshkpAI0Gk9IWsJwiEXt+aJ8ufbcRo5G3wZMpVOo HuBJZU8Azl2cicVaQ/+jdf6fjr57g0h414KWWTy71 X-Received: by 2002:adf:a1d9:0:b0:37c:d181:a2be with SMTP id ffacd0b85a97d-37d0e8e0022mr4648881f8f.56.1728220152728; Sun, 06 Oct 2024 06:09:12 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHRXCUtju2hID7lxAfXMURP6d25jPc/Mb8Wroei4S+bgthDmc/blZgs3095p9gdTozLDNMXGA== X-Received: by 2002:adf:a1d9:0:b0:37c:d181:a2be with SMTP id ffacd0b85a97d-37d0e8e0022mr4648865f8f.56.1728220152244; Sun, 06 Oct 2024 06:09:12 -0700 (PDT) Received: from localhost (2a01cb00025433001b9f807167cdbf20.ipv6.abo.wanadoo.fr. [2a01:cb00:254:3300:1b9f:8071:67cd:bf20]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-37d1690f75bsm3625017f8f.23.2024.10.06.06.09.11 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 06 Oct 2024 06:09:11 -0700 (PDT) Mime-Version: 1.0 Date: Sun, 06 Oct 2024 15:09:11 +0200 Message-Id: Subject: Re: [PATCH v12 1/7] buildtools/chkincs: relax C linkage requirement Cc: "Heng Wang" , "Stephen Hemminger" , "Tyler Retzlaff" , =?utf-8?q?Morten_Br=C3=B8rup?= , "Jack Bond-Preston" , "David Marchand" , "Chengwen Feng" From: "Robin Jarry" To: =?utf-8?q?Mattias_R=C3=B6nnblom?= , =?utf-8?q?Mattias_R=C3=B6nnblom?= , User-Agent: aerc/0.18.2-74-g7e4ac1a5f54c References: <20240920062437.738706-2-mattias.ronnblom@ericsson.com> <20240920104754.739033-1-mattias.ronnblom@ericsson.com> <20240920104754.739033-2-mattias.ronnblom@ericsson.com> <74e86a66-4341-465d-bcba-d76db66035cd@lysator.liu.se> <722ddf9d-29ed-4d3b-bc54-ac2aafefd2bb@lysator.liu.se> <6fd9040d-d923-42e2-8eab-b7ad5e48e28c@lysator.liu.se> In-Reply-To: X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8; format=Flowed 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 Robin Jarry, Oct 06, 2024 at 14:25: > I think you need to change run_command() to custom_target(). I was=20 > thinking of this patch to be much simpler as follows: > > diff --git a/buildtools/chkincs/check_extern_c.sh b/buildtools/chkincs/ch= eck_extern_c.sh Sorry, I didn't think about windows compatibility which probably=20 requires python. Please disregard my previous message. Here is=20 a simplified python version: diff --git a/buildtools/chkincs/check_extern_c.py b/buildtools/chkincs/chec= k_extern_c.py new file mode 100755 index 000000000000..9534ef10ba4e --- /dev/null +++ b/buildtools/chkincs/check_extern_c.py @@ -0,0 +1,55 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: BSD-3-Clause + +import argparse +import re +import sys + +SYMBOL_EXPR =3D [ + # external variable definitions + re.compile(r"^extern\s+[a-z0-9_]+\s", re.MULTILINE), + # exported functions + re.compile(r"rte_[a-z0-9_]+\("), + re.compile(r"cmdline_[a-z0-9_]+\("), + re.compile(r"vt100_[a-z0-9_]+\("), + re.compile(r"rdline_[a-z0-9_]+\("), + re.compile(r"cirbuf_[a-z0-9_]+\("), + # windows compatibility + re.compile(r"pthread_[a-z0-9_]+\("), + re.compile(r"regcomp\("), + re.compile(r"count_cpu\("), +] + + +def has_symbols(buf): + for expr in SYMBOL_EXPR: + if expr.search(buf): + return True + return False + + +def main(): + parser =3D argparse.ArgumentParser() + parser.add_argument("mode", choices=3D("redundant", "missing")) + parser.add_argument("headers", nargs=3D"+") + args =3D parser.parse_args() + + ret =3D 0 + + for h in args.headers: + with open(h) as f: + buf =3D f.read() + if args.mode =3D=3D "missing": + if has_symbols(buf) and 'extern "C"' not in buf: + print('error: missing extern "C":', h) + ret =3D 1 + elif args.mode =3D=3D "redundant": + if not has_symbols(buf) and 'extern "C"' in buf: + print('error: redundant extern "C":', h) + ret =3D 1 + + return ret + + +if __name__ =3D=3D "__main__": + sys.exit(main()) diff --git a/buildtools/chkincs/meson.build b/buildtools/chkincs/meson.buil= d index f2dadcae18ef..381f30f42431 100644 --- a/buildtools/chkincs/meson.build +++ b/buildtools/chkincs/meson.build @@ -38,14 +38,11 @@ if not add_languages('cpp', required: false) endif =20 # check for extern C in files, since this is not detected as an error by t= he compiler -grep =3D find_program('grep', required: false) -if grep.found() - errlist =3D run_command([grep, '--files-without-match', '^extern "C"',= dpdk_chkinc_headers], - check: false, capture: true).stdout().split() - if errlist !=3D [] - error('Files missing C++ \'extern "C"\' guards:\n- ' + '\n- '.join= (errlist)) - endif -endif +custom_target('check-extern-c', + command: files('check_extern_c.py') + ['missing', '@INPUT@'], + input: dpdk_chkinc_headers, + output: 'check-extern-c', + build_by_default: true) =20 gen_cpp_files =3D generator(gen_c_file_for_header, output: '@BASENAME@.cpp',