Skip to content

Api check stuff#594

Open
rjarry wants to merge 2 commits intoDPDK:mainfrom
rjarry:api-check
Open

Api check stuff#594
rjarry wants to merge 2 commits intoDPDK:mainfrom
rjarry:api-check

Conversation

@rjarry
Copy link
Copy Markdown
Collaborator

@rjarry rjarry commented Apr 16, 2026

API inline function compatibility checking

Extends the API compatibility check (introduced in commit 9e51368) to track and compare inline wrapper functions across revisions.

Changes

api/gr_api.h
Introduces a GR_API_INLINE macro conditionally defined as static inline. This macro provides a hook for generated request/response wrapper functions to be marked with a specific attribute or section marker.

devtools/check_api.sh
Augments the ABI compatibility check with inline function tracking:

  • Adds compiler flags -Wno-missing-declarations and -Wno-missing-prototypes to suppress warnings for generated functions
  • Injects GR_API_INLINE macro definition to place inline wrapper functions into a dedicated ELF section (.api_inline)
  • After binary compilation, extracts and disassembles inline function symbols from the .api_inline section in both previous and current builds
  • Compares the disassembled instruction streams of each inline function between revisions
  • Sets inline_change flag when inline functions are added, removed, or their implementation differs
  • Integrates inline function changes into the overall ABI compatibility decision: treats inline changes as breaking changes that affect the final result
  • Relocates GR_API_VERSION comparison/output outside the abidiff failure conditional to ensure it displays regardless of abidiff result

devtools/gen_api_header.sh
Corrects the date format command from date +Y to date +%Y to properly output the four-digit year in the copyright notice.

rjarry added 2 commits April 16, 2026 09:54
The date format needs a % character.

Fixes: 8de3676 ("api: generate a single grout.h umbrella header")
Signed-off-by: Robin Jarry <rjarry@redhat.com>
Add a GR_API_INLINE macro that normally expands to static inline. In
check_api.sh, it is redefined to empty so the compiler emits an external
symbol that abidiff can track.

For inline functions whose body is part of the API contract (e.g. shared
memory ring accessors), compare the disassembly of both revisions with
objdump. Since both binaries are built with the same toolchain and
flags, any difference is a real code change. Treat removed or changed
inline functions as breaking.

Signed-off-by: Robin Jarry <rjarry@redhat.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 16, 2026

📝 Walkthrough

Walkthrough

The pull request introduces a new GR_API_INLINE macro conditionally defined as static inline in the API header, designating functions for inclusion in a dedicated .api_inline ELF section. The API checking script is enhanced to extract and compare inline functions between builds, treating mismatches or changes as ABI violations. Additionally, compilation warnings are suppressed during API validation. A minor date format correction is applied to the header generation script.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@devtools/check_api.sh`:
- Around line 99-100: The branch handling newly added inline API functions (elif
[ -z "$a" ]; then) only echoes "inline API function $func: added" but does not
flip inline_change, so additions of GR_API_INLINE helpers can bypass the
API-change path; update that branch in devtools/check_api.sh to set
inline_change=true (and keep the echo) when func corresponds to a GR_API_INLINE
symbol so the later API-change branch (lines handling inline_change) runs;
reference the elif [ -z "$a" ]; then branch, the inline_change variable, and the
GR_API_INLINE helper/function name ($func) when making this change.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 739d44b6-866e-420f-8a7f-1c67f5ad525a

📥 Commits

Reviewing files that changed from the base of the PR and between 0731cb6 and c58cd68.

📒 Files selected for processing (3)
  • api/gr_api.h
  • devtools/check_api.sh
  • devtools/gen_api_header.sh

Comment thread devtools/check_api.sh
Comment on lines +99 to +100
elif [ -z "$a" ]; then
echo "inline API function $func: added"
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Added inline API functions currently bypass the change detection path.

Line 99 only logs "added" and leaves inline_change=false. If a PR adds a new GR_API_INLINE helper and abidiff stays quiet, Lines 113-129 never enter the API-change branch, so the new public inline API slips through this check entirely.

Possible fix
-inline_change=false
+inline_change=false
+inline_added=false
 while read -r func; do
 	a=$(objdump -d --disassemble="$func" $dir/check_api/a.bin 2>/dev/null \
 		| sed -n '/^[0-9a-f].*:/{s/^[^:]*://;s/\t[0-9a-f ]*\t/\t/;p}')
 	b=$(objdump -d --disassemble="$func" $dir/check_api/b.bin 2>/dev/null \
 		| sed -n '/^[0-9a-f].*:/{s/^[^:]*://;s/\t[0-9a-f ]*\t/\t/;p}')
 	if [ -z "$a" ] && [ -z "$b" ]; then
 		continue
 	elif [ -z "$a" ]; then
+		inline_added=true
 		echo "inline API function $func: added"
 	elif [ -z "$b" ]; then
 		inline_change=true
 		echo "inline API function $func: removed"
 	elif [ "$a" != "$b" ]; then
 		inline_change=true
 		echo "inline API function $func: code changed"
 	fi
 done < $dir/check_api/inline_funcs

-if ! $abidiff --non-reachable-types --drop-private-types --show-bytes \
+if ! $abidiff --non-reachable-types --drop-private-types --show-bytes \
 	--headers-dir1 $dir/check_api/a --headers-dir2 $dir/check_api/b \
-	$dir/check_api/a.bin $dir/check_api/b.bin >"$dir/abidiff.log" 2>&1 \
-	|| [ "$inline_change" = true ]
+	$dir/check_api/a.bin $dir/check_api/b.bin >"$dir/abidiff.log" 2>&1 \
+	|| [ "$inline_change" = true ] || [ "$inline_added" = true ]
 then
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
elif [ -z "$a" ]; then
echo "inline API function $func: added"
inline_change=false
inline_added=false
while read -r func; do
a=$(objdump -d --disassemble="$func" $dir/check_api/a.bin 2>/dev/null \
| sed -n '/^[0-9a-f].*:/{s/^[^:]*://;s/\t[0-9a-f ]*\t/\t/;p}')
b=$(objdump -d --disassemble="$func" $dir/check_api/b.bin 2>/dev/null \
| sed -n '/^[0-9a-f].*:/{s/^[^:]*://;s/\t[0-9a-f ]*\t/\t/;p}')
if [ -z "$a" ] && [ -z "$b" ]; then
continue
elif [ -z "$a" ]; then
inline_added=true
echo "inline API function $func: added"
elif [ -z "$b" ]; then
inline_change=true
echo "inline API function $func: removed"
elif [ "$a" != "$b" ]; then
inline_change=true
echo "inline API function $func: code changed"
fi
done < $dir/check_api/inline_funcs
if ! $abidiff --non-reachable-types --drop-private-types --show-bytes \
--headers-dir1 $dir/check_api/a --headers-dir2 $dir/check_api/b \
$dir/check_api/a.bin $dir/check_api/b.bin >"$dir/abidiff.log" 2>&1 \
|| [ "$inline_change" = true ] || [ "$inline_added" = true ]
then
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@devtools/check_api.sh` around lines 99 - 100, The branch handling newly added
inline API functions (elif [ -z "$a" ]; then) only echoes "inline API function
$func: added" but does not flip inline_change, so additions of GR_API_INLINE
helpers can bypass the API-change path; update that branch in
devtools/check_api.sh to set inline_change=true (and keep the echo) when func
corresponds to a GR_API_INLINE symbol so the later API-change branch (lines
handling inline_change) runs; reference the elif [ -z "$a" ]; then branch, the
inline_change variable, and the GR_API_INLINE helper/function name ($func) when
making this change.

@rjarry rjarry requested a review from david-marchand April 16, 2026 10:41

echo "// SPDX-License-Identifier: BSD-3-Clause"
echo "// Copyright (c) $(date +Y) Red Hat"
echo "// Copyright (c) $(date +%Y) Red Hat"
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ack

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants