Skip to content

ci: fix vtcc sed patch — use int(-2147483648) not u32 for shf_private#26869

Open
quaesitor-scientiam wants to merge 1 commit intovlang:masterfrom
quaesitor-scientiam:fix-vtcc-sed-patch-correct
Open

ci: fix vtcc sed patch — use int(-2147483648) not u32 for shf_private#26869
quaesitor-scientiam wants to merge 1 commit intovlang:masterfrom
quaesitor-scientiam:fix-vtcc-sed-patch-correct

Conversation

@quaesitor-scientiam
Copy link
Copy Markdown
Contributor

Follow-up to #26858

The vtcc workaround in #26858 patched const shf_private = int(0x8000_0000)u32(0x8000_0000). This fixed the overflow warning but introduced a new error visible in the c80a8a8 CI run:

failed src/tccelf.v:49:65: error: `(shf_private | shf_dynsym)` (no value) used as value in argument 4 to `new_symtab`
   49 |     s.dynsymtab_section = new_symtab(s, c'.dynsymtab', sht_symtab, (shf_private | shf_dynsym),

Root cause: shf_dynsym is still int and new_symtab takes sh_flags int. V cannot OR u32 | int and pass the result as int. Fixing by cascading u32 through struct Section.sh_flags, new_section, and new_symtab would touch 20+ bitwise-op sites.

Fix: use -2147483648 (INT_MIN) — the same bit pattern as 0x8000_0000 in two's complement signed arithmetic. Type stays int, no cascading changes needed.

A proper upstream fix has been filed at felipensp/vtcc#7. This sed patch is a temporary workaround until that merges into the stable branch.

Test plan

  • Test vtcc passes on ubuntu-latest without overflow warning or type error

🤖 Generated with Claude Code

The previous patch (in vlang#26858) changed `int(0x8000_0000)` → `u32(0x8000_0000)`,
which fixed the overflow warning but introduced a new type error:

    failed src/tccelf.v:49:65: error: `(shf_private | shf_dynsym)` (no value)
    used as value in argument 4 to `new_symtab`

Root cause: `shf_dynsym` is still `int` and `new_symtab` takes `sh_flags int`;
V cannot OR `u32 | int` and implicitly pass the result as `int`. Changing to
`u32` throughout cascades into 20+ sites across tccelf.v and struct Section.

Correct workaround: use `-2147483648` (INT_MIN) instead — the identical bit
pattern as `0x8000_0000` in two's complement, with type `int`. No downstream
type changes needed. A proper fix has been filed upstream at felipensp/vtcc#7.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@quaesitor-scientiam
Copy link
Copy Markdown
Contributor Author

quaesitor-scientiam commented Apr 12, 2026

Once vtcc#7 merges, the right follow-up is a third PR to remove the sed patch entirely from compile_v_with_vtcc.sh (since the fix will be in the source). @felipensp

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