Skip to content

migrate: fold c ## L paste macros (INTMAX_C, UINTMAX_C, …) to typed literals so INTMAX_MAX/INTMAX_MIN/PTRDIFF_MIN/MAX become data #945

Closed

Description

@ehartford

What

pcre2's migrated shared defs (lib/std/re/defs.w) carry five pub let globals whose initializers call the migrated paste-macro helpers INTMAX_C[T] / UINTMAX_C[T] (C's c ## L token paste): INTMAX_MAX, UINTMAX_MAX, and INTMAX_MIN, PTRDIFF_MIN, PTRDIFF_MAX derived from them. A generic helper call is not a compile-time initializer, so codegen cannot fold these globals to data.

Why it matters

A .wo bundle object (docs/wo_bundles.md, D38/D39 Level 0) supplies every owned global as data; nothing runs an initializer for it. Batch C3 therefore treats such a global like a generic function: omitted from the .wi with a note, omitted <module> <name> runtime-init-global in the manifest, undefined in the object, and a build warning (branch wo-c3, commit c3b79cf9). Inside the corpus Sema folds every use, so pcre2 links and RunTest passes, but the surface is smaller than the source says and the warning fires on every bundle build.

Fix

The migrator should fold c ## L-style paste macros to a typed literal at migration time (INTMAX_C(x) → x as i64-shaped literal, UINTMAX_C(x) → u64), so the derived globals are plain constants. Then the omission path never fires for pcre2; keep the path for the general case. Verify by re-migrating pcre2 (:pcre2-migrate), promoting, and checking that with build lib/std/re/bundle.w --emit-obj --bundle-corpus std/re --emit-bundle-interface … prints no omission warning and the manifest has no omitted line.

Found by the C3.6 wo-drift harness.

Activity

  1. ehartford commented on Sep 3, 2026

    @ehartford
    ContributorAuthor

    Fixed on main: b4dc2ff (migrator: a paste-suffix macro on an integer literal is the suffixed literal, with a system-header regression test), 9a4418f (idempotent bundle-root write the promote gate exposed), 5465144 (pcre2 and zlib re-promoted; the five globals are compile-time data, the bundle manifest has no runtime-init omission and the .wi exports them). Battery green (build, fixpoint, move/drop audits, test), pushed, reseeded v0.15.1.7-g54651442e.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions