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 C3D51455F2; Thu, 11 Jul 2024 13:39:06 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A93E3410F2; Thu, 11 Jul 2024 13:39:06 +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 777344021F for ; Thu, 11 Jul 2024 13:39:05 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1720697944; 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; bh=NByPjtVUBw7GxN2UCzwJlO06jgj5vTyrdFTJ8UVh1oA=; b=ZThkv5qnZX7Glfmtk7/ohAr83PxoHfQAtUTix2FzsRVNbjKccvc2e6naV+9IEYaOv3L60D vCzAYGomUdJNVJoOml1M9jqT0ZcYDiTkpR/MIOR3OBo2yglPWuNkur8h5XKv4DZ9V/t/5E kObH3nYJVOk6b6DgVwyboPwAMfp666E= Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-587-JXXR-XvnOxWCVCfl5hu5QA-1; Thu, 11 Jul 2024 07:39:01 -0400 X-MC-Unique: JXXR-XvnOxWCVCfl5hu5QA-1 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id C33401955F28; Thu, 11 Jul 2024 11:38:59 +0000 (UTC) Received: from dmarchan.redhat.com (unknown [10.45.224.73]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id D9DE019560AE; Thu, 11 Jul 2024 11:38:57 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: stable@dpdk.org, Ali Alnubani , Song Jiale , Dmitry Kozlyuk Subject: [PATCH] buildtools: fix build with clang 17 and ASan Date: Thu, 11 Jul 2024 13:38:51 +0200 Message-ID: <20240711113851.975368-1-david.marchand@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true 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 ASan included in clang 17 and later suffixes symbols. $ nm build/drivers/libtmp_rte_net_null.a | grep this_pmd 0000000000000000 r this_pmd_name3 0000000000000000 n this_pmd_name3.f2cd16678ab09dba8fd23405d8d11fce This breaks the detection of driver symbols in pmdinfogen which then creates duplicate symbols "_pmd_info" in many drivers. Such duplicate symbols trigger a link error. $ grep -w _pmd_info build/drivers/rte_net_*.pmd.c build/drivers/rte_net_af_packet.pmd.c:const char _pmd_info[] __attribute__((used)) = "PMD_INFO_STRING= {\"name\": \"\", \"pci_ids\": []}"; build/drivers/rte_net_null.pmd.c:const char _pmd_info[] __attribute__((used)) = "PMD_INFO_STRING= {\"name\": \"\", \"pci_ids\": []}"; A simple reproducer: $ CC=clang meson setup build -Denable_apps=test-pmd -Ddisable_libs=* \ -Denable_drivers=net/null,net/af_packet -Dtests=false \ -Db_lundef=false -Db_sanitize=address $ ninja -C build Before this patch, the pmdinfogen script was relying on a symbol name starting with this_pmd_name. On the other hand, what this script needs is symbols whose names are this_pmd_name ## __COUNTER__, see below an example for PCI driver symbols (the same applies to other buses). $ git grep -w RTE_PMD_EXPORT_NAME drivers/bus/pci/bus_pci_driver.h drivers/bus/pci/bus_pci_driver.h:RTE_PMD_EXPORT_NAME(nm, __COUNTER__) $ git grep -B1 this_pmd_name lib/eal/ lib/eal/include/rte_dev.h-#define RTE_PMD_EXPORT_NAME(name, idx) \ lib/eal/include/rte_dev.h:static const char RTE_PMD_EXPORT_NAME_ARRAY(this_pmd_name, idx) \ $ git grep define.RTE_PMD_EXPORT_NAME_ARRAY lib/eal/include/rte_dev.h lib/eal/include/rte_dev.h:#define RTE_PMD_EXPORT_NAME_ARRAY(n, idx) n##idx[] Adjust the symbol filter for both ELF and COFF implementations. Bugzilla ID: 1466 Cc: stable@dpdk.org Reported-by: Ali Alnubani Reported-by: Song Jiale Signed-off-by: David Marchand --- buildtools/pmdinfogen.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/buildtools/pmdinfogen.py b/buildtools/pmdinfogen.py index 2a44f17bda..dfb89500c0 100755 --- a/buildtools/pmdinfogen.py +++ b/buildtools/pmdinfogen.py @@ -6,6 +6,7 @@ import argparse import ctypes import json +import re import sys import tempfile @@ -66,11 +67,11 @@ def _get_symbol_by_name(self, name): return [symbol] return None - def find_by_prefix(self, prefix): - prefix = prefix.encode("utf-8") if self._legacy_elftools else prefix + def find_by_pattern(self, pattern): + pattern = pattern.encode("utf-8") if self._legacy_elftools else pattern for i in range(self._symtab.num_symbols()): symbol = self._symtab.get_symbol(i) - if symbol.name.startswith(prefix): + if re.match(pattern, symbol.name): yield ELFSymbol(self._image, symbol) @@ -97,9 +98,9 @@ def __init__(self, data): def is_big_endian(self): return False - def find_by_prefix(self, prefix): + def find_by_pattern(self, pattern): for symbol in self._image.symbols: - if symbol.name.startswith(prefix): + if re.match(pattern, symbol.name): yield COFFSymbol(self._image, symbol) def find_by_name(self, name): @@ -199,7 +200,7 @@ def dump(self, file): def load_drivers(image): drivers = [] - for symbol in image.find_by_prefix("this_pmd_name"): + for symbol in image.find_by_pattern("^this_pmd_name[0-9]+$"): drivers.append(Driver.load(image, symbol)) return drivers -- 2.45.2