|WARNING| [v2] eal: fix function versioning with LTO
dpdklab at iol.unh.edu
dpdklab at iol.unh.edu
Wed Jun 10 07:04:37 CEST 2026
Test-Label: ai-code-review
Test-Status: WARNING
https://dpdk.org/patch/165218
_AI Code Review_
=== Patch Review: series.patch (via Claude) ===
Review date: 2026-06-10
# DPDK Patch Review
## Patch: eal: fix function versioning with LTO
### Summary
This patch adds support for GCC's `__attribute__((symver))` when available, as a workaround for LTO build issues with function versioning. The implementation provides two code paths: one using the symver attribute (preferred) and one using inline assembly (fallback).
---
## ERRORS
None found.
---
## WARNINGS
### 1. Missing GCC version documentation for symver attribute
**Issue:** The commit message mentions "GCC 10 introduced" the symver attribute, but this crucial version requirement is not documented in the header file comments.
**Why it matters:** Future maintainers need to know the minimum compiler version that supports this feature to understand when the fallback path is used.
**Suggested fix:**
```c
/*
* RTE_VERSION_SYMBOL
* Create a symbol version table entry binding symbol <name>@DPDK_<ver> to the internal
* function name <name>_v<ver>.
*
* Uses __attribute__((symver)) when available (GCC 10+, Clang 10+),
* otherwise falls back to inline assembly.
*
* ...
*/
```
### 2. Inconsistent __rte_used annotation
**Issue:** The new symver attribute path does NOT include `__rte_used` on the versioned function declarations, but the assembly fallback path does include it. This inconsistency could lead to different compiler behavior between the two paths.
**Why it matters:** `__rte_used` prevents the compiler from eliminating symbols it thinks are unused. With LTO, unused functions can be optimized away even if they are part of the symbol version table. The symver attribute may implicitly prevent elimination, but the inconsistency is risky.
**Code locations:**
```c
/* New symver path - no __rte_used */
type name ## _v ## ver args;
/* Assembly fallback path - has __rte_used */
__rte_used type name ## _v ## ver args;
```
**Suggested fix:** Add `__rte_used` to the symver attribute path for consistency:
```c
#define RTE_VERSION_SYMBOL(ver, type, name, args) VERSIONING_WARN \
__attribute__((__symver__(RTE_STR(name) "@DPDK_" RTE_STR(ver)))) \
__rte_used type name ## _v ## ver args; \
type name ## _v ## ver args
```
Apply the same change to `RTE_VERSION_EXPERIMENTAL_SYMBOL` and `RTE_DEFAULT_SYMBOL`.
### 3. Missing release notes update
**Issue:** This patch changes the implementation of function versioning macros, which could affect how drivers and libraries use versioned symbols. While it's a build infrastructure change, it affects all code using function versioning and resolves an LTO build issue.
**Why it matters:** Users building with LTO need to know this fix exists. Developers who encounter the assembler error message described in the commit log would benefit from a release notes entry pointing them to this fix.
**Suggested fix:** Add an entry to `doc/guides/rel_notes/release_XX_XX.rst`:
```rst
* **Fixed function versioning with LTO builds.**
Added support for GCC's symver attribute to fix symbol versioning errors
when building with Link-Time Optimization enabled. The build now automatically
uses the attribute when available (GCC 10+) and falls back to inline assembly
for older compilers.
```
---
## INFO
### 1. Clang version for symver attribute
The commit message states "clang doesn't have or need this attribute" which is partially incorrect. Clang 10+ does support `__attribute__((symver))` and it's the preferred method for symbol versioning with Clang as well. The current code will work with Clang (falls back to assembly), but explicitly checking for the attribute via `__has_attribute(symver)` means Clang 10+ will also use the preferred path, which is good.
Consider clarifying in the commit message or code comment that Clang 10+ also supports and uses the symver attribute path.
### 2. Code organization
The new comment block at the top provides good documentation of the macro purposes. This is a positive improvement in code readability.
---
## CORRECTNESS VERIFICATION
**Macro expansion paths verified:**
- Both paths produce function declarations with the same signature
- Both paths produce versioned symbols (via attribute or asm)
- Static library path unchanged (no versioning, as expected)
**Resource management:** Not applicable (no dynamic resources).
**Error paths:** Not applicable (preprocessor macros).
**Thread safety:** Not applicable (build-time macros).
---
## OVERALL ASSESSMENT
The patch is technically sound and solves a real LTO build issue. The main concerns are:
1. **Warning-level:** Missing `__rte_used` consistency between code paths could cause subtle LTO issues
2. **Warning-level:** Missing release notes for a user-visible build fix
3. **Warning-level:** Missing version requirements in code comments
The implementation correctly uses `__has_attribute(symver)` to detect support, which is portable across compilers. The fallback to inline assembly maintains compatibility with older toolchains.
More information about the test-report
mailing list