Skip to content

Keep global names' case in AOT header macros - #78

Merged
wtholliday merged 2 commits into
mainfrom
aot-header-macro-case
Oct 28, 2026
Merged

wtholliday merged 2 commits into
mainfrom
aot-header-macro-case

Conversation

@wtholliday

Copy link
Copy Markdown
Collaborator

Summary

The AOT backend's per-global _OFFSET_/_SIZE_/_KIND_ macros uppercased the global's name, so two globals that differ only in case defined the same macros twice. Audulus's pro patches hit this: the RS-1 ratchet sequencer has count and Count, and the dac-out script has r and R, so every translation unit including those headers got -Wmacro-redefined warnings.

Identifiers are case-sensitive and unique within a program, so this keeps their case in the macro name: RS_1_RATCHET_SEQUENCER_OFFSET_Count and ..._OFFSET_count. The prefix part stays uppercase, and non-identifier characters still become underscores. The runtime metadata table is unchanged.

This renames existing macros for any host that used them; Audulus only goes through the metadata table and manifest.

Test plan

  • New aot_header_macros_keep_global_case CLI test: globals r and R, both macros and both metadata entries present, no macro defined twice.
  • cargo test --release --features llvm aot_ in cli/: 4 passed.

🤖 Generated with Claude Code

wtholliday and others added 2 commits October 28, 2026 07:58
The per-global _OFFSET_/_SIZE_/_KIND_ macros uppercased the global's name,
so two globals differing only in case (`count` and `Count`, `r` and `R`)
defined the same macros twice and every TU including the header got
-Wmacro-redefined warnings. Identifiers are case-sensitive and unique
within a program, so keeping their case makes the macros unique.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Keeping case makes distinct identifiers distinct macros, but sanitizing can
still merge names: an overloaded extern is mangled to `send$f32`, which
becomes `send_f32`, the same macro as a global called `send_f32`. A repeat
now gets a `_2`, `_3`, ... suffix. The metadata table keeps the real names.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@wtholliday

Copy link
Copy Markdown
Collaborator Author

Follow-up from review: the overloaded-extern finding does not reproduce as described, since overloads are mangled (send$f32, send$i32) before they reach the header. The $ does sanitize to _, though, so an extern send(f32) and a global send_f32 would share a macro. The second commit gives a repeated sanitized name a _2 suffix and adds a test for that case; the metadata table still carries the real names.

🤖 Generated with Claude Code

@wtholliday
wtholliday merged commit a7d373c into main Oct 28, 2026
8 checks passed
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.

1 participant