Skip to content

Driver: a bare argv[0] on Windows is the current directory's executable, and one function names the running compiler (#2647) - #2737

Merged
ehartford merged 1 commit into
fix-2649from
fix-2647
Oct 26, 2026
Merged

ehartford merged 1 commit into
fix-2649from
fix-2647

Conversation

@ehartford

@ehartford ehartford commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

with_self_exe (LldDriver.w) took a bare argv[0] through PATH. cmd runs a
bare with.exe from the current directory first, so a copy there
re-invoked an older with.exe from PATH for its link ("error: unknown
command '__ld'"), and every self-invocation (__ar, with cc, the
runtime root, install-user's source) read the same answer. On Windows a
bare name is now looked up in the current directory first. The c_import
cache key (Frontend) had its own resolver, which split PATH on : even on
Windows; it reads with_self_exe now and the duplicate is gone.
SEED-BOUND: the OS's own answer (GetModuleFileNameW, _NSGetExecutablePath,
/proc/self/exe) needs a runtime function src/ can call only once a seed
carrying it is pinned.

Test: test/internals/self_exe_names_running_binary_test.w.

Closes #2647

@ehartford
ehartford added this pull request to stack #2743 October 26, 2026 04:07
@ehartford ehartford changed the title fix 2647 Driver: a bare argv[0] on Windows is the current directory's executable, and one function names the running compiler (#2647) Oct 26, 2026
…le, and one function names the running compiler (#2647)

with_self_exe (LldDriver.w) took a bare argv[0] through PATH. cmd runs a
bare `with.exe` from the current directory first, so a copy there
re-invoked an older with.exe from PATH for its link ("error: unknown
command '__ld'"), and every self-invocation (`__ar`, `with cc`, the
runtime root, install-user's source) read the same answer. On Windows a
bare name is now looked up in the current directory first. The c_import
cache key (Frontend) had its own resolver, which split PATH on `:` even on
Windows; it reads with_self_exe now and the duplicate is gone.
SEED-BOUND: the OS's own answer (GetModuleFileNameW, _NSGetExecutablePath,
/proc/self/exe) needs a runtime function src/ can call only once a seed
carrying it is pinned.

Test: test/internals/self_exe_names_running_binary_test.w.
@ehartford
ehartford marked this pull request as ready for review October 26, 2026 04:31
@ehartford
ehartford merged commit 27092dc into main Oct 26, 2026
@ehartford
ehartford deleted the fix-2647 branch October 26, 2026 04:32
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.

Windows: a bare argv[0] resolves through PATH, so the compiler re-invokes a different with.exe (unknown command '__ld')

1 participant