Skip to content

Windows: the #809 selfhost and migrator targets run green, on nothing of the host (#809, #2769, #2773) - #2785

Merged
ehartford merged 7 commits into
fix-811from
fix-809
Oct 28, 2026
Merged

ehartford merged 7 commits into
fix-811from
fix-809

Conversation

@ehartford

@ehartford ehartford commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Commits (each message carries its root cause and evidence):

Restacked 2026-10-28 from the handoff's branches onto main 455ff0b; the wip commits are grouped by issue.

@ehartford
ehartford added this pull request to stack #2786 October 28, 2026 18:16
@ehartford ehartford changed the title fix 809 Windows: the #809 selfhost and migrator targets run green, on nothing of the host (#809, #2769, #2773) Oct 28, 2026
Eric Hartford added 6 commits October 28, 2026 14:18
…reparse point (#809, #2773)

Three defects in the Windows runtime's link support, found running
:cli-selfhost-build-w-tests on win10:

- rt_symlink stored the target verbatim. Windows resolves a relative
  target only with `\` separators, so a tar entry's `nested/a.txt`
  extracted to a link whose read failed with ERROR_INVALID_NAME (123),
  printed as "no protocol option" (strerror of a Win32 code, #2773).
  The separators are converted before CreateSymbolicLinkW.
- rt_symlink chose SYMBOLIC_LINK_FLAG_DIRECTORY by testing a relative
  target against the process's cwd; a relative target names a path
  beside the link, so it is resolved against the link's directory.
- rt_readlink was a stub returning "" (`let _ = path; win_empty_str()`),
  so build_graph_refuse_shared_gen_dir never saw an out/gen link on
  Windows (build_w_gen_link "unexpectedly succeeded"). It now opens the
  link itself (FILE_FLAG_OPEN_REPARSE_POINT | FILE_FLAG_BACKUP_SEMANTICS),
  reads FSCTL_GET_REPARSE_POINT and returns the symlink's or junction's
  print name (the substitute name without `\??\` when no print name is
  stored), "" when the path is not a link, as POSIX readlink answers.
  DeviceIoControl joins the win32 facade's domain rows.

Evidence (win10): build-w-toolfs-archive reads extracted/pkg/link-a.txt
(`<SYMLINK> link-a.txt [nested\a.txt]`); build_w_gen_link reports
"out/gen is a symlink". windows_aarch64.w carries the same change
(D137, unverified there).
…`char` (#2769)

Emitted C on windows-gnu failed to compile the prelude_runtime unit:
"incompatible pointer types passing 'int8_t **' to parameter of type
'char **'" at strtoll/strtoull/strtof calls in migrated mlib code
(facade_shapes.w). c_char is the target's i8 or u8 (D155), which c_type
spells int8_t/uint8_t, while <stdlib.h> declares the parameter `char **`.
C converts `int8_t *` to `char *` with a warning but refuses the
double pointer; clang 22 on mingw makes it an error. The #811 layer
had downgraded the error (-Wno-error=incompatible-pointer-types); that
flag is removed in this stack, and the cast belongs here.

- extern_declared_by_included_headers is the predicate
  should_emit_extern_fn_decl already applied (extracted, one owner).
- A call argument whose parameter is a pointer chain two or more deep
  ending at c_char is cast to the header's spelling (`char **`) when the
  callee is a bodiless extern the headers declare. std.libc's own
  `strtol` is a With function whose emitted prototype says int8_t**: a
  first version keyed on the name alone cast its arguments the wrong way
  (the same unit failed with `char **` to `int8_t **`); callee_is_bodiless
  reads has_body_for_sym.
- The strtod-only special case this generalizes is deleted.

Evidence: :emit-c-smoke "EMIT-C SMOKE OK (34 cases)" on win10 and on
the Mac with no -Wno-error.
)

compile_c_object ran $CC or the host's `cc`. On Windows there is none
(build-w-full-graph: "compile_c_object target 'helper-o' failed with
exit code -2"); on macOS it was Apple's /usr/bin/cc from the Command
Line Tools, a host dependency #1915 rules out. The build depends on
nothing of the host, Unix or Windows (Eric, 2026-10-28).

build_graph_cc_tool's default is now "" (our own), and
build_graph_compile_object runs `<this compiler> cc` (with_self_exe),
the clang the compiler embeds with its sysroot; $CC still names another
compiler explicitly.

Evidence: build-w-full-graph builds helper-o on win10 and the Mac.
, D147, D109)

Un-skipping the c-migrator suites on win10 (windows-gnu clang, MinGW
headers, LLP64) found host-dependent output and silent wrong layouts:

- D147 bitfields: the "Itanium packs across, MSVC starts a new unit"
  refusal was judged from the host's single clang layout, so on an
  MSVC-layout host every such record migrated with MSVC offsets.
  ci_bitfield_abi_divergence simulates both ABIs from declared sizes and
  widths, anchored per run at clang's first offset, and refuses on
  divergence. Checked against clang -fdump-record-layouts for both
  triples on 12 probe records: identical verdicts on both hosts.
- Packed bitfield records: windows-gnu clang drops `packed` for bitfield
  units, so their layout is flavor-defined; refused
  (with_cimport_decl_has_packed_attr, a token scan in ClangBridge).
- NULL evidence: UCRT/MinGW `assert(p)` is `((!!(p)) || (_assert(...),0))`;
  ci_body_null_test_evidence reads a `||`/`&&` short-circuit as a test.
- offsetof naming: the idiom and text paths named the typedef (`md_t`)
  where the builtin path names the record; all canonicalize to the
  record's rendered name.
- Folds (D109 class): a member-address difference and a sizeof ratio
  (D119's `t.len()`) folded to host numbers where a narrowing cast
  routed them through a folding path; never folded now.
- Modeled libc call typing: a generic call took the host declaration's
  return type, so MinGW's `int write(...)` returned through a C `long`
  narrowed silently under LLP64. ci_libc_modeled_return_type reads the
  fixed-width integer return type from the std.libc this compiler
  carries (D90's one table, as ci_libc_constant_known reads constants;
  a first version was a hand list of ten names).
- `__acrt_iob_func(0|1|2)` lowers to libc_stdin/stdout/stderr().

Evidence: :c-migrator-basic-tests and :c-migrator-core-tests green on
win10 and on the Mac; a POSIX-model migration's output is unchanged.
repl_bin_path named the per-line binary without `.exe`, so on Windows
every REPL line exited -2 (the #1081 one-liner class).
:cli-selfhost-one-liner-tests is green on win10.
…ing of the host

The cli-selfhost (smoke, one-liner, project, edge, parallel, build-w),
c-migrator (basic, core) and issue61 targets were skipped on Windows
(bs_windows_skip, now deleted with the issue61 skip in build.w). Each
runs there now; what each needed:

- Paths: bs_is_absolute and bs_default_bin spell Windows absolute paths
  and default executable outputs (`out/bin/<name>.exe`); the build-w
  cases that name an executable (install-two, target-select,
  graph-group) take the host suffix; the seed case links the seed at
  the `src/main` + suffix the seed target writes (#2759).
- No host programs (Eric, 2026-10-28: the build depends on no Unix or
  Windows command). The action fixture's children (env, cwd, timeout,
  streaming) were /usr/bin/env, /bin/cat, /bin/sleep and /bin/echo; they
  are With programs the case writes and the compiler under test runs.
  The never-run names in refusal cases are `with`. The emit-C and C ABI
  checks compile with the compiler under test's own `cc`
  (bs_c_compiler_argv) on every host, not the SDK's clang++ or the
  host's cc; $WITH_EMIT_C_CC/$CC still name one explicitly. The
  -Wno-error=incompatible-pointer-types downgrade from #811 is gone
  (#2769 fixed in codegen).
- issue61: the fixture copies seed.lock (Resolve refused its own rt
  imports on every host since src/ moved to `use rt.*`) and copies lib/
  instead of linking it (a seed-built runner's remove_tree recursed
  through the directory link).
- The two-worker scheduler case runs where a multi-worker fiber core
  exists; Windows has one worker (#2770). The POSIX-path migrator case
  needs POSIX headers MinGW lacks (realpath).
- Migrator expectations follow the C model being migrated: C long
  widths (bs_c_long/bs_c_ulong), MinGW's ULONG_MAX and INTMAX_C
  spellings, the packed-bitfield refusal reason, the model's long
  double (#2771), and the D119 fixture's table is `unsigned long long`
  (5000000000 does not fit LLP64 `unsigned long`).
- SEED-BOUND (#809): the pinned seed's runtime reads a directory link
  as the directory, and its driver overflowed its stack walking the
  build-w gen-link case's out/gen link on the next build (0xC00000FD,
  minidump: two frames alternating). The case makes and then removes
  that link with the compiler under test; with a seed carrying #811's
  rt_file_mode and this stack's rt_symlink, ctx.fs().symlink suffices.

Evidence (win10, pinned seed driving): cli-selfhost-smoke, -one-liner,
-project, -edge, -parallel and -build-w, issue61-regression,
c-migrator-basic and -core, emit-c-smoke, spec-inventory-check and
embedded-runtime-regression green; build-w green on two consecutive runs.
The Mac: :gate and the same targets green.
…ph reads it (#809)

The build graph's C compile runs `<this compiler> cc` (with_self_exe),
but with_self_exe was in compiler.LldDriver, which the build-graph
modules do not import: the internals and behavior tests that compile
BuildGraphOps.w on its own failed with "undefined variable" at
BuildGraphOps.w:178 (the battery's internals-tests and behavior-tests
reds). compiler.Runtime holds the helpers it is built from and every
caller already imports it; it moves there unchanged.
@ehartford

Copy link
Copy Markdown
Contributor Author

Seed-driven Mac battery GREEN on the stack top f8ee22e (379 s, run by this stack's no-shell tools/battery.w with the tree's release compiler). The first full Windows battery on win10 (same top, 696 s) ran end to end and is RED on targets outside #809's list; inventory in the tracking issue filed with this merge.

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