Skip to content

Bump bootstrap to ab4bad9c and restore the FloatToString peephole fold - #1688

Merged
mbouaziz merged 4 commits into
mainfrom
bootstrap-float-tostring
Nov 17, 2026
Merged

mbouaziz merged 4 commits into
mainfrom
bootstrap-float-tostring

Conversation

@mbouaziz

Copy link
Copy Markdown
Contributor

What

  1. Bump the bootstrap compiler to SkipLabs/skiplang-bootstrap@2ef40fd, promoted from ab4bad9c (= current main + the skargo fix below) with bin/bump_bootstrap.sh. The promoted IR carries the Ryu-based Float.toString from prelude: Float.toString via Ryu (round-trip-safe, shortest representation) #1288, so the bootstrap compiler now formats floats exactly like the current runtime.
  2. Restore the FloatToString peephole constant fold (FloatToString(ConstantFloat) -> constant string), removed in prelude: Float.toString via Ryu (round-trip-safe, shortest representation) #1288 because the old bootstrap folded with the old formatter while the runtime printed the new one. With the bumped bootstrap, compiler and target share the same Float.toString, so folding is consistent again. A new Runtime/FloatToString test pins the folded output of constant Float.toString (0.1, -0.0, 1.0e+100, nan, -inf, ...) to the runtime's shortest round-trip form.
  3. Fix a latent skargo bug that blocked the bump: the release profile started passing --split-support-module to skc itself (c5ff01a), while the compiler Makefile still forwarded it via --skcopt (needed only by the older bootstrap skargo). skc rejects a duplicated option, so every stage2+ build failed — including the stage3 verification in bump_bootstrap.sh. Skc.process now drops from --skcopt whatever the profile already sets, with regression tests.

Validation

  • bin/bump_bootstrap.sh on ab4bad9c: clean rebuild from the promoted IR through stage3 with an identical self-hosting fixpoint (stage2/stage3 skc IR byte-identical); new stage0 reports skc 0.4.1 (ab4bad9c); full compiler test suite 1766/1766 against the new stage0. IR pushed to SkipLabs/skiplang-bootstrap@2ef40fd (Update to ab4bad9c), fast-forwarded on its main exactly as bump-bootstrap.yml does.
  • With the fold restored, fresh caches (make clean, stage0 rebuilt from the new bootstrap IR): make stage1 + make test 1767/1767 (includes the new FloatToString test), prelude 131/131, skargo 15/15 (the 6 local failures seen with the stale system skc 0.3.3 on PATH pass with the freshly built skc), and the prelude runtime regression script passes ("Wasm Float.toString matches JS digits").
  • CI builds stage0 from the submodule pointer in this PR, so the restored fold is exercised consistently (stage0 carries the new formatter; stage1 folds with it).

Notes

  • After merging, republish the CI images (docker-publish) since the pinned bootstrap changed.
  • AI assistance: commits generated with Mistral Vibe (Co-Authored-By trailers); validation performed in-session as described above.

@mbouaziz
mbouaziz enabled auto-merge November 17, 2026 10:55
@mbouaziz
mbouaziz disabled auto-merge November 17, 2026 11:01
mbouaziz and others added 4 commits November 17, 2026 11:02
skc rejects an option passed twice, so the release profile adding
--split-support-module (c5ff01a) breaks any build that also forwards it
via --skcopt -- e.g. the compiler Makefile, which passes it to the bootstrap
skargo. That made every stage2+ build fail, including the stage3
verification in bin/bump_bootstrap.sh, so the bootstrap could not be
rebuilt.

Skc.process now takes the profile options and drops them from the forwarded
extra options.

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
Co-Authored-By: Claude Opus 5.5 (Anthropic, via Mistral Vibe; thinking: high) <noreply@anthropic.com>
Rebuilt from ab4bad9 (main + the skargo --skcopt dedup fix) with
bin/bump_bootstrap.sh: clean self-hosting rebuild through stage3 with an
identical fixpoint, and the full compiler test suite (1766/1766) against
the new stage0.

The promoted IR carries the Ryu-based Float.toString from #1288, so the
bootstrap compiler now formats floats exactly like the current runtime.

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
Co-Authored-By: Claude Opus 5.5 (Anthropic, via Mistral Vibe; thinking: high) <noreply@anthropic.com>
Fold FloatToString(ConstantFloat) to a constant string again. This was safe
once the bootstrap carries the same Float.toString as the target runtime:
the bootstrap is only published after a compiler rebuilt from it passes the
full test suite (bin/bump_bootstrap.sh), and the bump in this PR promotes an
IR built from the Ryu-based prelude (#1288).

Adds a Runtime test pinning the folded output of constant Float.toString
(including -0.0, nan and inf) to the runtime's shortest round-trip form.

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
Co-Authored-By: Claude Opus 5.5 (Anthropic, via Mistral Vibe; thinking: high) <noreply@anthropic.com>
Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
Co-Authored-By: Claude Opus 5.5 (Anthropic, via Mistral Vibe; thinking: high) <noreply@anthropic.com>
@mbouaziz
mbouaziz force-pushed the bootstrap-float-tostring branch from 5034cf7 to fa7438e Compare November 17, 2026 11:02
@mbouaziz
mbouaziz enabled auto-merge November 17, 2026 11:02
@mbouaziz
mbouaziz merged commit d03dcd5 into main Nov 17, 2026
21 checks passed
@mbouaziz
mbouaziz deleted the bootstrap-float-tostring branch November 17, 2026 11:19
mbouaziz added a commit that referenced this pull request Nov 19, 2026
…tod fallback (#1714)

## What

Unifies `String.toFloat` parsing across native and Wasm, and removes a
locale hazard on native:

- **Native now uses Ryu `s2d` as the primary path** (previously libc
`atof`),
  exactly like Wasm — correctly rounded and locale-independent.
- **Locale safety**: `atof`/`strtod` honor the process locale (under
`de_DE.UTF-8`, `strtod("1.5")` returns `1.0`). The fallback now rewrites
the input's `.` to `localeconv()->decimal_point` before calling
`strtod`,
  so parsing is correct under any installed locale. (The grammar is
validated in `String.toFloatOption` to be decimal-only, so `.` is the
only
  separator that can appear.)
- **>17-nonzero-digit inputs** (an upstream Ryu `s2d` limit) fall back
to
`strtod` on native and JS `Number()` on Wasm; both are correctly rounded
  for decimal input, so native and Wasm agree bit for bit.

## Tests

- New `runtime/tests/to_float_raw_native.c`, wired into `run.sh`
**before**
  the Linux-only section so it runs on macOS too: s2d-path values, the
  `>17`-digit fallback, `-0.0`, overflow/underflow, and a real
comma-decimal locale (`de_DE.UTF-8` when installed). Verified locally on
macOS: under `de_DE`, plain `strtod("1.5")` gives 1.0 while the runtime
  gives 1.5.
- `string_to_float.mjs` (Wasm s2d harness): new accepted edge forms
  (`"5."`, `"0."`, `"1e0"`, `"10e-1"`, `"-0.0e0"`) checked against JS
`Number()`, plus more `>17`-digit rejection cases documenting the
fallback
  trigger. Passed in the Linux container (100k random inputs included).
- `tests/Float.sk`: grammar pins (`toFloatOption` rejects whitespace,
hex
`0x1p4`, `Infinity`/`INF`, leading `+`, `.5`, `1,5`, `00`, `1e+`;
accepts
  `5.`, `0e0`, `1E5`, `10e-1`), long-digit rounding
  (`"0.1000000000000000000000000000001"` -> `0.1`,
`"123456789012345678"` -> `123456789012345680.0`), the subnormal
boundary
(`"2.2250738585072011e-308"` -> largest subnormal
`2.2250738585072009e-308`),
  and a toString round-trip.

## Validation

- `prelude/runtime/tests/run.sh` passes on macOS (native toFloat test
incl.
  the real `de_DE.UTF-8` locale branch) and in the Linux container (full
  suite incl. Wasm s2d vs `Number()` on 100k random inputs).
- `string.c` compiles cleanly on both platforms (`-Wall -Wextra
-Werror`).
- `make check-fmt` failure on the first push was diagnosed and fixed in
  `ae47d93b`: `tests/Float.sk` needed one `expectEq` on a single line.
Re-verified locally with the pinned tool versions — skfmt (stage0
binary),
  clang-format 20 on both `.c` files, prettier 3.4.1 on the `.mjs`,
  shellcheck on `run.sh` — all clean.
- Full stage1 compiler build runs on macOS (gmake 4.4.1; the earlier
local
  build failure was GNU make 3.81 not supporting grouped `&:` targets,
  causing two skargo runs to race on `state.db`); prelude suite with the
  new runtime is run against stage1 locally.

## Notes

- Rebased on latest main (which already carries the `std` 0.7.0 bump, so
  this PR no longer touches `Skargo.toml`).
- Runtime-C-only change, so no bootstrap bump needed (the C runtime is
compiled from source at every stage0 link). CI images republish (already
  pending from #1688) will carry it.
- AI assistance: commits generated with Mistral Vibe (Co-Authored-By
  trailers); validation performed in-session as described above.
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