Skip to content

Flag 0.5 - #3

Merged
FramaLuna merged 14 commits into
mainfrom
release-0.5
Nov 3, 2026
Merged

FramaLuna merged 14 commits into
mainfrom
release-0.5

Conversation

@FramaLuna

@FramaLuna FramaLuna commented Nov 3, 2026 •

Copy link
Copy Markdown
Owner

Flag 0.5: SIMD, shared libraries and a C FFI without workarounds, processes and UDP, flagc test, and faster generated code.

Five works built in parallel, merged one commit each, then reviewed by three independent reviewers and fixed:

  • faster code: signed indexes without a multiply, positional literals packed only when constant, an inliner that counts what survives, switch on a union by binary search. The integration of rigid bodies goes from 5.9 to 2.4 times C -O2.
  • tests and fixes: flagc test (each test in its own process, in parallel, with a timeout), @embed, -> never that narrows, not (x is T) narrows, .len of arrays, maps of &str take a &strview, and Flag's main is C's main.
  • system: start for processes that run beside the program, random_bytes, fs.modified, UDP and ready in net, UTF-16 on Windows, and try_reserve.
  • linking: -shared on Linux and macOS, libraries that start on their own, union tags from the name of the type, load/symbol/close, extern func, link names with = "symbol", offset_of, and the where of extern blocks.
  • simd: simd[T, n] in registers, with a new register class v in QBE on amd64 (x86-64-v2) and arm64. A 4-lane contact solver runs at about 1.5 ns per contact, next to 1.3 for C with SSE. The operators of arrays are gone, except ==.

Then the leftovers of that review, in two more commits:

  • c0c3bb8:
    • a simd in a tagged union goes at byte 16, aligned as C expects it;
    • -memory warns about a thread that runs alone in a library, which nothing waits for before the program closes it;
    • [...] and {k: v} take the one array, simd or map of a union, like {...} takes its one struct;
    • ptr of a lane of a mask is documented as a copy.
  • acc6563: in QBE, v[i] reads and writes its lane in the register (vget/vset in the cut of small slots), on amd64 and arm64. A loop that sets a lane and then works on the whole simd is 4 times as fast.

The changelog section is in CHANGELOG.md (0.5.0, not released yet). The version in build.sh is still 0.4.0 and will be bumped when the release is ready.

Testing done locally

  • Linux x86_64: ./build.sh (stage 2 and stage 3 agree, built from the new seeds), ./test.sh build/flagc: 1111 passed, 0 failed (main has 992). ./build.sh sanitize is clean.
  • Linux arm64 under qemu: 429 pass, 30 fail. main fails 22 in the same environment. The extra failures come from the environment: gdb, programs that run themselves, and dynamic loading under -static. The last two commits add no new failures.
  • Windows through WSL interop: 428 pass, 13 fail. 10 of those fail the same way on main, and 3 need the Linux flagc. After the last two commits, a run that executes each test from a temporary folder gives 427 pass, 17 fail, the same 17 as before them.
  • macOS: only linked with zig (110 of 110), and the new tests link too. CI runs it.

🤖 Generated with Claude Code

FramaLuna and others added 14 commits November 3, 2026 11:08
…acked only when constant, the inliner counts what survives, switch on a union by binary search; qbe: struct copies of 4 bytes, floats on the stack on Windows

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…rrays, maps of &str take a &strview, array constants take the type of the place, main is the main of C; refresh seeds

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ed, net: UDP and ready, UTF-16 on Windows, try_reserve

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…tags from the name of the type, load, symbol and close, extern func, link names, offset_of, the where of extern blocks

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…he operators of arrays are gone

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…program, LoadLibraryW, a simd as a key, QBE changes counted; refresh seeds

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…t without files, late reads in literals, user functions next to lane functions, masks, QBE on arm64 and rv64; refresh seeds

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…t macOS writes its own way

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…in hex, 0xc0000005, and its test reads it as the 139 of Linux and macOS

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…s about a thread that runs alone in a library, a literal takes the one array, simd or map of a union, ptr of a lane of a mask is a copy; refresh seeds

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…get and vset in the cut of small slots, so v[i] keeps the simd there

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…eads that gdb sees start on Windows

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@FramaLuna
FramaLuna merged commit 4c55984 into main Nov 3, 2026
4 checks passed
@FramaLuna
FramaLuna deleted the release-0.5 branch November 3, 2026 21:22
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