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 EE8FE45AC7; Sun, 6 Oct 2024 14:25:08 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A76D14025F; Sun, 6 Oct 2024 14:25:06 +0200 (CEST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mails.dpdk.org (Postfix) with ESMTP id 05D8D4025D for ; Sun, 6 Oct 2024 14:25:04 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1728217504; 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=dw8xhWDhE/yh3r0ac0ogzblVqWRSDNuGntzwv/dEGU8=; b=ae1C0J8z6md9c+4opUpDOkQTJXY3Z09wKQZtSbzBu2eVwG06vi/PvSskccuc6cXmkxPC75 C6l7ugrfj8dzw6YxF8C5+xPUHXqoEr8C4Ra/XPBdidHiv9WJldyy9Hpg4DLqtzluikr4Eq T4phypS3RnNfTsywXU6AUzi4hU1RhgA= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-58-VivF77frPCOLZ6UKJLEgAQ-1; Sun, 06 Oct 2024 08:25:03 -0400 X-MC-Unique: VivF77frPCOLZ6UKJLEgAQ-1 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-42cb89fbb8bso21633425e9.3 for ; Sun, 06 Oct 2024 05:25:02 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728217502; x=1728822302; h=in-reply-to:references:user-agent:from:cc:subject:to:message-id :date:content-transfer-encoding:mime-version:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=ylXbt/OJKZu10N3iStnZ2hFTCrCd81DYPQbTQ14gKWM=; b=imlxhNg1woQyf+tPsU90cDr7/qvni+/ySX2yTly+RcsQLfI5z6q5xdz7/VQu+4h1ap jVyXoUgNAbLha3WxNzCebjbNy8huLYGX0HYHMyzFaAI7eM2IKF5/hdJNaHsLaOyfSwpY NMbNL6BEeGbMV0o6cxGA0xhYmLW1QO1DCQQnAxVVauM5nRgxkmgkZ15Hc3rij6weKZ9o rJtumvjvaLZ3uTlqAP2HeQram692SsRMHqqLLk/tpGULEQPSxYNmE4EqfRyqUERUhVIz a8xiqU32oOZS/8eBDnqIeyH+pp8ZpFEKxJEFJUpjjiQlitwjebXZ8t6sHvMhXwC/jN+G SIrQ== X-Forwarded-Encrypted: i=1; AJvYcCUUuAM/a+0MRIqHeaefQ5SzmobWZVMibufg7vwBgtZwbk7vZFniCaSJEwmbSC219xsKgVc=@dpdk.org X-Gm-Message-State: AOJu0YzA1rTGBbcKzVJxXhLuScFWi+/TVRC8AQNlpdjivewboMt+Mwhq JYRoE9ks2jFr3kdrqIgLukoyTsxZ98kccXhJ4CwNxbst6afRQBa3lvQoiduaRMxudCkTGX88Sre m3NSXiW+FJ5ltJgUpWrGF/cp4viPGBZRdzg37e2mj X-Received: by 2002:a05:600c:4514:b0:42c:a802:a8b4 with SMTP id 5b1f17b1804b1-42f859b0f48mr59710235e9.0.1728217501865; Sun, 06 Oct 2024 05:25:01 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFahyDA8UOI6mQUhgMnwWDpy5Zt/sNvbY6S0qTFE+nZBjYRqjX3OhOmIKLhTeaG4vLP1EzP2A== X-Received: by 2002:a05:600c:4514:b0:42c:a802:a8b4 with SMTP id 5b1f17b1804b1-42f859b0f48mr59710135e9.0.1728217501540; Sun, 06 Oct 2024 05:25:01 -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 5b1f17b1804b1-42f89ed922esm45534715e9.39.2024.10.06.05.25.00 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 06 Oct 2024 05:25:01 -0700 (PDT) Mime-Version: 1.0 Date: Sun, 06 Oct 2024 14:25:00 +0200 Message-Id: To: =?utf-8?q?Mattias_R=C3=B6nnblom?= , =?utf-8?q?Mattias_R=C3=B6nnblom?= , 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" 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: <6fd9040d-d923-42e2-8eab-b7ad5e48e28c@lysator.liu.se> 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 Mattias R=C3=B6nnblom, Oct 06, 2024 at 11:47: > OK, so it does change something, but not for the better, seemingly. > > meson.build now somehow has to distinguished between two different "error= s": > 1) One or more offending header files were found. > 2) Any other kind of error (file not found, access control issues,=20 > internal script error, etc). > > For 1), it should print a list of the offending header files. > > If you just set "check: true" in run_command(), and have the=20 > chkextern.py script return non-zero on error, the offending header files= =20 > will not be printed on stdout. > > My guess would be that this complicating factor is the reason for this=20 > pattern of not (in/from meson) depending on the script delegate exit=20 > code, but rather the output. > > May I should rename the script to "scanextern.py" to better reflect that= =20 > a failure to find an issue is not an error (=3Dnon-zero exit code). 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/chec= k_extern_c.sh new file mode 100755 index 000000000000..96ace5ffd248 --- /dev/null +++ b/buildtools/chkincs/check_extern_c.sh @@ -0,0 +1,49 @@ +#!/bin/sh +# SPDX-License-Identifier: BSD-3-Clause + +has_symbols() { +=09grep -Eq \ +=09=09-e 'rte_[a-z0-9_]+\(' \ +=09=09-e 'cmdline_[a-z0-9_]+\(' \ +=09=09-e 'vt100_[a-z0-9_]+\(' \ +=09=09-e 'rdline_[a-z0-9_]+\(' \ +=09=09-e 'cirbuf_[a-z0-9_]+\(' \ +=09=09-e 'pthread_[a-z0-9_]+\(' \ +=09=09-e 'regcomp\(' \ +=09=09-e 'count_cpu\(' \ +=09=09-e '^extern[[:space:]]+[a-z0-9_]+[[:space:]]' \ +=09=09"$1" +} + +has_extern_c() { +=09grep -q 'extern "C"' "$1" +} + +mode=3D$1 +shift +ret=3D0 + +case "$mode" in +--missing) +=09for header in "$@"; do +=09=09if has_symbols "$header" && ! has_extern_c "$header"; then +=09=09=09echo "error: missing extern \"C\": $header" >&2 +=09=09=09ret=3D1 +=09=09fi +=09done +=09;; +--redundant) +=09for header in "$@"; do +=09=09if ! has_symbols "$header" && has_extern_c "$header"; then +=09=09=09echo "error: missing extern \"C\": $header" >&2 +=09=09=09exit 1 +=09=09fi +=09done +=09;; +*) +=09echo "error: unsupported mode '$mode'" >&2 +=09ret=3D1 +esac + +exit $ret diff --git a/buildtools/chkincs/meson.build b/buildtools/chkincs/meson.buil= d index f2dadcae18ef..b463845083eb 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.sh') + ['--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',