Skip to content

Windows: with.toml is found for drive paths, and PWD is the runtime's (#1082) - #1091

Merged
ehartford merged 1 commit into
mainfrom
fix-1082-windows-pwd
Sep 7, 2026
Merged

ehartford merged 1 commit into
mainfrom
fix-1082-windows-pwd

Conversation

@ehartford

Copy link
Copy Markdown
Contributor

Closes #1082, closes #1083. The one red fixture on both Windows lanes of #1086 (behav_project_overflow_modes): (1) project_config_is_absolute_path only knew POSIX roots, so a drive path was joined onto PWD and with.toml was never found on Windows — every [build] setting silently dropped; (2) the driver trusts PWD and nothing on Windows kept it true (unix spawners set it in the child after chdir; a git-bash parent exports /c/src/with). The Windows runtime now owns PWD at startup and around CreateProcessW; the predicate accepts drive and UNC paths. Verified on the native box: the fixture passes under with test; the nested build under PWD=/c/src/with roots correctly; a spawned child reports its own directory as PWD. #1083's linker-env message came from the repo graph that the stale PWD had rooted.

…#1082)

behav_project_overflow_modes was the one red fixture on both Windows
lanes after the v0.15.2.1 seeds landed. Two Windows-only defects, one
root: the driver trusts PWD, and nothing on Windows keeps it true.

1. project_config_is_absolute_path was `path[0] == '/'`. A Windows drive
   path (C:/... or C:\...) counted as relative, project_config_absolutize_path
   joined it onto PWD, project_config_find_root never found with.toml, and
   every [build] setting -- overflow mode among them -- was silently dropped
   on Windows. `with check <drive path>` on the fixture's project reported
   "integer overflow in comptime" under `overflow = "wrap"`; runtime wrap
   and `+%` worked, isolating the loss to manifest discovery. The predicate
   now accepts a POSIX root, a drive prefix, or a UNC path (the shape
   TrackedInputs.w already used).

2. PWD: the driver reads it for its working directory (main.w
   test_binary_absolute_path, ProjectConfig absolutize, TrackedInputs embed
   anchoring). The unix spawners setenv("PWD", cwd) in the forked child
   after chdir; the Windows spawner passed lpCurrentDirectory and left the
   inherited PWD stale, so a test's nested `with build` in its case directory
   inherited the parent's PWD and built the REPO's graph (replaying the
   nested build with PWD=/c/src/with reproduces it exactly: the repo's
   pcre2-wo-install targets, then "import module not found: 'Lexer'" from
   out/gen/main.w). A git-bash parent also exports the POSIX spelling
   /c/src/with, which Win32 resolves as C:\c\src\with. The Windows runtime
   now owns PWD: rt_store_args sets it from GetCurrentDirectoryW at startup,
   and win_spawn_argv sets it to the child's directory around
   CreateProcessW (restored after), mirroring the unix child. Both backends.

Verified on native Windows with the rebuilt tree: `with check` on the
fixture's drive-path source: ok; the nested build under PWD=/c/src/with
roots at the case directory and builds; behav_project_overflow_modes
passes under `with test`; a child spawned into a directory reports
PWD=C:\src\with\out\tmp\pre-d-p7\overflow_wrap_mode.

#1083's "missing Windows LLVM linker metadata ... no WITH_LLVM_LD" came
from that repo graph rooted by the stale PWD; with correct rooting the
project graph builds with the same environment.
ehartford added a commit that referenced this pull request Sep 7, 2026
)

Fifteen sites decided "join onto the root unless absolute" or "reject a
path that escapes the project" with `path[0] == '/'`. On Windows every
drive path was therefore relative: #1091 fixed the one instance that
dropped [build] settings (the with.toml walk); the build graph had the
same test, so a Test target's `compiler=C:/.../with.exe` was joined onto
the project root and the target reported "could not spawn". The three
lexical normalizers (Resolve's module key, TrackedInputs, ComptimeEval's
tool path) also prefixed "/" only for a POSIX root and let `..` pop a
drive or a UNC share.

compiler.Runtime now owns runtime_path_is_absolute (POSIX root, drive
`X:/` or `X:\`, UNC `\srv\share`, drive-root-relative `\x`) with the
root part count and prefix a normalizer needs; every site reads it.
test/internals/path_absolute_test.w pins the matrix, the build-graph
resolution and containment, and the normalizers' root handling.

Verified with a stage1 built from this tree: the internals matrix, the
phase battery, and a scratch build.w whose Test target names the
compiler by drive path (spawned; before: could not spawn).
@ehartford
ehartford deleted the fix-1082-windows-pwd branch September 24, 2026 16:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant