Skip to content

emitc selfbuild - #2819

Merged
ehartford merged 2 commits into
atomic-new-by-argfrom
emitc-selfbuild
Oct 29, 2026
Merged

ehartford merged 2 commits into
atomic-new-by-argfrom
emitc-selfbuild

Conversation

@ehartford

Copy link
Copy Markdown
Contributor

Stack created with GitHub Stacks CLI • Give Feedback 💬

Eric Hartford added 2 commits October 29, 2026 14:26
…oint (#983 follow-up)

emit-c-test had been red on main, hidden behind earlier stops (nothing in
the battery runs it). Once the whole compiler emitted as C, the C
compiler found about 250 errors in these classes, each a C-backend
defect, and the C-built compiler then misread its own flags:

- a plain enum's discriminant read as `.tag`: an enum with no payloads
  is its discriminant (enum_tag_text)
- method owners matched by substring: `TokenList.len` and
  `TokenList.new` were taken for List's; owners now match exactly
- a field named as a C keyword (`signed`): every member is spelled
  through cc_member, which escapes C keywords
- with_runtime.h disagreed with the runtime (`with_arg_at` takes an
  isize; `with_vec_get_ptr_es` a byte pointer), and the emitter declared
  them again: the header follows rt_core and the emitter defers to it
- a raw pointer to a fn value was laid out as the {fn_ptr, ctx} pair
  itself; a `&fn` view, the pair by value, is now read and taken
  consistently
- `==` on an Option, a tuple or a struct was C's `==` on a struct: it is
  structural (#2137), through the walk map keys compare by; a distinct
  type compares as its underlying type
- `&raw const` of a str rendered the `&str` view, not the address
- a local MIR declares as an Option was re-typed from a downcast read
  through it (`Option[&i32]` became `Option[i32]`); MIR's type wins (D65)
- an extern fn's `@[link_name("unlink")]` was ignored: the C called
  `ci_unlink`
- `List.contains` compared elements by their bytes, so a str matched only
  itself: `["--emit-c"].contains(arg)` was false and the C-built
  compiler refused every flag; elements compare by their type's `==`

:emit-c-test and :emit-c-fixpoint are green: the compiler built from C
builds itself to identical C. Tests: test/emit_c/map_get_option_view,
test/emit_c/list_contains_by_value; all 37 test/emit_c fixtures pass
through C.
…piler, no MSVC paths (#2782)

emit-c-test and emit-c-fixpoint compiled the emitted compiler with
$LLVM_PREFIX's or the SDK's clang++, falling back to the host's `cc`
(`clang++.exe` on Windows), and on Windows targeted
*-pc-windows-msvc and linked Visual Studio and Windows Kits library
directories. The build runs no host command (Eric, 2026-10-28; Law 8):
the C compiler is now `<compiler under test> cc`, its embedded clang
driver, sysroot and lld, as the emit-c smoke's is (bs_c_compiler_argv);
WITH_EMIT_C_CC or CC is the user's explicit choice. Windows takes the
windows-gnu target the real link uses (#1915) and rt.o's import
libraries (ws2_32, dbghelp, crypt32).

Verified on darwin-arm64: :emit-c-test and :emit-c-fixpoint green.

Fixes #2782
@ehartford
ehartford added this pull request to stack #2820 October 29, 2026 18:37
@ehartford

Copy link
Copy Markdown
Contributor Author

Seed-driven battery GREEN on the stack top 1fbaa5d (with run tools/battery.w). Also green on the top: :emit-c-test and :emit-c-fixpoint (the compiler emitted as C, compiled with <compiler> cc, rebuilds itself to identical C); all 37 test/emit_c fixtures through C.

@ehartford
ehartford marked this pull request as ready for review October 29, 2026 18:37
@ehartford
ehartford merged commit 707d538 into main Oct 29, 2026
@ehartford
ehartford deleted the emitc-selfbuild branch October 29, 2026 18:37
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