Skip to content

clang-19 compatibility#46

Open
kalvdans wants to merge 2 commits into
lvc:masterfrom
kalvdans:clang-compat
Open

clang-19 compatibility#46
kalvdans wants to merge 2 commits into
lvc:masterfrom
kalvdans:clang-compat

Conversation

@kalvdans

Copy link
Copy Markdown

Adds support for two Dwarf constructs that clang-19 emits.

Also adds a tests folder that checks that the fix works. The test needs both clang and gcc installed and not connected to CI in any way yet. Feel free to remove this folder if it doesn't fit the project's plans.

AI disclosure: Claude Opus 4.7 helped to make this PR.

kalvdans and others added 2 commits May 21, 2026 11:31
Adds a Make-driven regression that builds a small shared library with
both clang and gcc at DWARF 4 and DWARF 5, runs abi-dumper against
each, normalises the dumps (drops compiler-version metadata, renames
DIE numeric IDs to stable T0001/T0002/... via structural traversal),
and asserts the four dumps agree pairwise per DWARF version.

Run with: make -C tests
Override compilers with: make -C tests CLANG=clang-19 GCC=gcc-13

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Two clang-emitted DWARF encodings that the 1.4 parser mishandled:

* DW_TAG_subrange_type: DWARF 5 sec. 5.13 permits the bound to be
  encoded as DW_AT_count (number of elements) instead of
  DW_AT_upper_bound (highest index). gcc emits upper_bound; clang
  (>= 7) emits count for non-VLA C arrays. Previously only
  upper_bound was consulted, so fixed-size arrays from clang
  decayed to flexible arrays in the dump. Fall back to count when
  upper_bound is absent.

* DW_FORM_sdata: eu-readelf renders sdata as "(sdata) RAW (SIGNED)"
  where RAW is the unsigned u64 reinterpretation and SIGNED is the
  signed value. The generic attribute reader only stripped the
  "(sdata) " form prefix, leaving "RAW (SIGNED)" as the stored
  value -- which broke negative enumerators (gcc and clang both
  use sdata for negative enumerator values). Capture the signed
  parenthesised value when this shape is seen.

Regression covered by tests/.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
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