Repository navigation
Conversation
ropoctl
force-pushed
the
fix-migrate-paste-suffix-glibc
branch
from
September 4, 2026 04:33
a05d080 to
4f40717
Compare
ropoctl
force-pushed
the
fix-migrate-paste-suffix-glibc
branch
from
September 4, 2026 06:04
4f40717 to
a80b9f5
Compare
ropoctl
force-pushed
the
fix-migrate-paste-suffix-glibc
branch
from
September 4, 2026 09:10
a80b9f5 to
dbccd4f
Compare
The paste-suffix migrator (#945) folds INTMAX_C(9223372036854775807) and friends to a suffixed literal by reading the token-paste suffix from the macro session built out of the preprocessed #define lines. Two facts about glibc's <stdint.h> defeated that on a glibc host: - glibc writes "# define" (whitespace between # and define), which the define-line recognizer, keyed on a literal "#define", did not match; and - the width constants route through __-prefixed helpers -- INTMAX_MAX is __INT64_C(9223372036854775807), UINTMAX_MAX is __UINT64_C(...) -- which the session builder dropped outright on the leading-underscore rule. Together those made __INT64_C/__INTMAX_C/__UINT64_C invisible to the folder, so INTMAX_MAX/UINTMAX_MAX could not paste their suffix and stayed unfolded on Linux while folding correctly on darwin. Recognize # + optional whitespace + define, and retain __-prefixed paste macros in the session. Emission already filters leading-underscore names, so a retained __INT64_C folds callers without ever being emitted.
…xture
The paste-suffix migrator fixture runs against the host's real <stdint.h>, so
two of its assertions were pinned to darwin's exact output and failed on a
glibc host even though the migration was correct:
- INTMAX_MIN: darwin references INTMAX_MAX (`-INTMAX_MAX - 1`) while glibc
pastes the literal inline (`-9223372036854775807i64 - 1`); both fold to
i64::MIN.
- the kept generic helper echoes the header's own macro parameter name --
darwin `INTMAX_C(v)`, glibc `INTMAX_C(c)` -- so the signature is
`INTMAX_C[T](v: T)` vs `INTMAX_C[T](c: T)`, the same translation.
Add bs_assert_contains_either and accept both intended spellings. Each
alternative is a valid, correct output for its host -- this loosens the fixture
to the set of correct results, not to accept a wrong one.
ropoctl
force-pushed
the
fix-migrate-paste-suffix-glibc
branch
from
September 4, 2026 11:04
dbccd4f to
9bf2327
Compare
ehartford
pushed a commit
that referenced
this pull request
Sep 5, 2026
…untranslated, not a self-referential global #997 (`# define` recognition) makes glibc's builtin-valued float macros reach the object-macro translator's bare-identifier path, where nothing rejected a self-reference: `#define NAN (__builtin_nanf(""))` and `HUGE_VALF (__builtin_huge_valf())` collapse to their own name and were emitted as `let NAN = NAN` / `let HUGE_VALF = HUGE_VALF`, and `#define INFINITY HUGE_VALF` as `let INFINITY = HUGE_VALF` naming one of them — globals codegen cannot lower ("global 'NAN' has no initializer codegen can lower"). test/spec/spec_ss16_ffi_and_c_import.w (a c_import("math.h")) reds on the fresh compiler; the previous compiler never saw these macros because their `# define` lines were not recognized. §16.2: a value With cannot express is recorded untranslated, not emitted as a broken decl. The bare-identifier emit now records the macro untranslated when its value is its own name (self-reference) or names a macro already omitted; a forward reference to a macro that will be emitted is untouched. Verified: math.h now omits the three (0 errors), spec_ss16 passes, and inttypes.h still emits its 42 PRI* lets with PRIdLEAST16 usable (the forward-reference class the guard must not break).
Contributor
|
Landed on main via cherry-pick under new hashes: 66c44de (fold paste-suffix macros through glibc's |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Fixes the
c-migrator-core-testspaste_suffix_*failures on glibc Linuxhosts. The paste-suffix macro folder (#945) only worked against darwin's
<stdint.h>; on a glibc host it leftINTMAX_MAX/UINTMAX_MAXunfolded.Stacked on #956.
Root cause
The folder reads the token-paste suffix (
L→i64,UL→u64, …) from a macrosession built out of the preprocessed
#definelines. Two glibc<stdint.h>facts defeated it:
# define(whitespace between#anddefine); thedefine-line recognizer, keyed on a literal
#define, did not match it.__-prefixed helpers —INTMAX_MAXis
__INT64_C(9223372036854775807),UINTMAX_MAXis__UINT64_C(...)—which the session builder dropped outright on its leading-underscore rule.
Together those made
__INT64_C/__INTMAX_C/__UINT64_Cinvisible to thefolder, so those constants could not paste their suffix and stayed unfolded on
Linux while folding correctly on darwin.
Fix
Commit 1 (compiler): recognize
#+ optional whitespace +define, and retain__-prefixed paste macros in the session. Emission already filtersleading-underscore names, so a retained
__INT64_Cfolds callers without everbeing emitted.
Commit 2 (tests): two fixture assertions were pinned to darwin's exact output.
The migrated form is fixed by the host header text and is equally correct either
way — INTMAX_MIN (
-INTMAX_MAX - 1vs the literal inline) and the kept generichelper's echoed parameter name (
INTMAX_C(v)vsINTMAX_C(c)). Addedbs_assert_contains_eitherand accept both intended spellings — this loosensthe fixture to the set of correct results, not to accept a wrong one.
Verification
with build :c-migrator-core-testsgreen on a glibc host (rebuilds + self-hostsstage2, migrates the fixture, and runs it):
survey: all targets green.