relibc: fix netinet/ip.h cbindgen double-struct (struct struct ip)

netinet_ip/cbindgen.toml both exports (defines) struct ip/iphdr AND had
[export.rename] mapping them to 'struct ip'/'struct iphdr'. With style=Tag,
cbindgen already prefixes a struct declaration with 'struct', so the rename
produced 'struct struct ip { ... }' — a C syntax error (expected '{' before
'struct') that broke every C consumer of <netinet/ip.h> (e.g. dbus's
dbus-print-message.c).

The 'X' -> 'struct X' rename is only correct for types REFERENCED from another
header (tag-style forward ref, e.g. arpa_inet's in_addr); it must NOT be used
for a type defined+exported in the same header. Removed the rename; both
structs are native Rust defs so cbindgen emits 'struct ip'/'struct iphdr'
correctly. Regenerated header verified (0 double-struct, diff = only the two
struct-name lines).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-07-28 15:46:41 +09:00
parent 36d157dcce
commit b3ae554bd9
+5 -4
View File
@@ -11,10 +11,11 @@ cpp_compat = true
[export]
include = ["ip", "iphdr"]
[export.rename]
"ip" = "struct ip"
"iphdr" = "struct iphdr"
# NB: do NOT add [export.rename] mapping "ip" -> "struct ip". With style = "Tag"
# cbindgen already emits `struct ip { ... }` for a struct named `ip`; renaming
# the type to "struct ip" makes it emit `struct struct ip { ... }`, which is a
# C syntax error ("expected '{' before 'struct'"). Both `ip` and `iphdr` are
# defined as native Rust structs, so no rename is needed for either name.
[enum]
prefix_with_name = true