Bug 1313

Summary: Build errors with clang 17.0.3 and ASan
Product: DPDK Reporter: Ali Alnubani (alialnu)
Component: otherAssignee: dev
Status: UNCONFIRMED ---    
Severity: normal    
Priority: Normal    
Version: 23.11   
Target Milestone: ---   
Hardware: All   
OS: All   

Description Ali Alnubani 2023-11-13 16:18:15 CET
"""
$ meson --werror -Db_sanitize=address -Db_lundef=false build
$ ninja-build -C build

[..]

drivers/rte_bus_fslmc.pmd.c:4:12: error: redefinition of '_pmd_info'
    4 | const char _pmd_info[] __attribute__((used)) = "PMD_INFO_STRING= {\"name\": \"\", \"pci_ids\": []}";
      |            ^
drivers/rte_bus_fslmc.pmd.c:2:12: note: previous definition is here
    2 | const char _pmd_info[] __attribute__((used)) = "PMD_INFO_STRING= {\"name\": \"\", \"pci_ids\": []}";
      |            ^
drivers/rte_bus_fslmc.pmd.c:6:12: error: redefinition of '_pmd_info'
    6 | const char _pmd_info[] __attribute__((used)) = "PMD_INFO_STRING= {\"name\": \"\", \"pci_ids\": []}";
      |            ^
drivers/rte_bus_fslmc.pmd.c:2:12: note: previous definition is here
    2 | const char _pmd_info[] __attribute__((used)) = "PMD_INFO_STRING= {\"name\": \"\", \"pci_ids\": []}";
      |            ^

[..]

drivers/rte_common_mlx5.pmd.c:4:12: error: redefinition of '_pmd_info'
    4 | const char _pmd_info[] __attribute__((used)) = "PMD_INFO_STRING= {\"name\": \"\", \"pci_ids\": []}";
      |            ^
drivers/rte_common_mlx5.pmd.c:2:12: note: previous definition is here
    2 | const char _pmd_info[] __attribute__((used)) = "PMD_INFO_STRING= {\"name\": \"\", \"pci_ids\": []}";
      |            ^

[..]

drivers/rte_net_bnx2x.pmd.c:4:12: error: redefinition of '_pmd_info'
    4 | const char _pmd_info[] __attribute__((used)) = "PMD_INFO_STRING= {\"name\": \"\", \"pci_ids\": []}";
      |            ^
drivers/rte_net_bnx2x.pmd.c:2:12: note: previous definition is here
    2 | const char _pmd_info[] __attribute__((used)) = "PMD_INFO_STRING= {\"name\": \"\", \"pci_ids\": []}";
      |            ^

[..]

drivers/rte_net_e1000.pmd.c:4:12: error: redefinition of '_pmd_info'
    4 | const char _pmd_info[] __attribute__((used)) = "PMD_INFO_STRING= {\"name\": \"\", \"pci_ids\": []}";
      |            ^
drivers/rte_net_e1000.pmd.c:2:12: note: previous definition is here
    2 | const char _pmd_info[] __attribute__((used)) = "PMD_INFO_STRING= {\"name\": \"\", \"pci_ids\": []}";
      |            ^
drivers/rte_net_e1000.pmd.c:6:12: error: redefinition of '_pmd_info'
    6 | const char _pmd_info[] __attribute__((used)) = "PMD_INFO_STRING= {\"name\": \"\", \"pci_ids\": []}";
      |            ^
drivers/rte_net_e1000.pmd.c:2:12: note: previous definition is here
    2 | const char _pmd_info[] __attribute__((used)) = "PMD_INFO_STRING= {\"name\": \"\", \"pci_ids\": []}";
      |            ^

[..]

drivers/rte_net_hns3.pmd.c:4:12: error: redefinition of '_pmd_info'
    4 | const char _pmd_info[] __attribute__((used)) = "PMD_INFO_STRING= {\"name\": \"\", \"pci_ids\": []}";
      |            ^
drivers/rte_net_hns3.pmd.c:2:12: note: previous definition is here
    2 | const char _pmd_info[] __attribute__((used)) = "PMD_INFO_STRING= {\"name\": \"\", \"pci_ids\": []}";
      |            ^

[..]

drivers/rte_net_ice.pmd.c:4:12: error: redefinition of '_pmd_info'
    4 | const char _pmd_info[] __attribute__((used)) = "PMD_INFO_STRING= {\"name\": \"\", \"pci_ids\": []}";
      |            ^
drivers/rte_net_ice.pmd.c:2:12: note: previous definition is here
    2 | const char _pmd_info[] __attribute__((used)) = "PMD_INFO_STRING= {\"name\": \"\", \"pci_ids\": []}";
      |            ^

[..]
"""

OS: Fedora 39
Meson: 1.2.3
Clang: 17.0.3 (Fedora 17.0.3-1.fc39)
Comment 1 Ali Alnubani 2023-11-13 16:18:32 CET
Build passes with clang version 16.0.6 (Fedora 16.0.6-3.fc38), and same Meson version.
Comment 2 Ali Alnubani 2023-11-13 16:18:43 CET
Suggested fix:
"""
diff --git a/buildtools/pmdinfogen.py b/buildtools/pmdinfogen.py
index 2a44f17bda..2b29872649 100755
--- a/buildtools/pmdinfogen.py
+++ b/buildtools/pmdinfogen.py
@@ -74 +74,3 @@ def find_by_prefix(self, prefix):
-                yield ELFSymbol(self._image, symbol)
+                elf_symbol = ELFSymbol(self._image, symbol)
+                if elf_symbol.string_value:
+                    yield elf_symbol
"""
Comment 3 Ali Alnubani 2023-11-13 16:20:43 CET
On Fedora 38 with Clang 16.0.6, load_drivers() returns a list consisting of a single driver, (e.g: ['mlx5_common_pci']).

On Fedora 39 with Clang 17.0.3, it returns a list consisting of 2 drivers (['mlx5_common_pci', '']), image.find_by_prefix("this_pmd_name") returns 2 symbols in this case, mlx5_common_pci and an empty string ''.