Skip to content

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

Closed

Description

@ehartford

Found while verifying #1145 on the Windows VM (win10).

Repro: put the published with-windows-x86_64.exe (nightly-20261025-local-1-c88f3eeff0bc) in an empty directory as with.exe, with an older with.exe (v0.15.2.1) on PATH, and from cmd in that directory:

C:\t> with.exe run hello.w
...usage...
error: unknown command '__ld'
error: run failed
C:\t> C:\t\with.exe run hello.w
hi

Root cause: with_self_exe (src/compiler/LldDriver.w, "argv[0] when it names a path, else argv[0] found on PATH") resolves a bare with.exe through PATH. cmd ran the copy in the current directory, but the link spawned the older one on PATH as with.exe __ld -flavor link …, and that copy has no __ld. Every self-invocation reads the same function: __ld, __ar, with cc, link_stage_compiler_dir, the runtime root, and install-user's source.

Expected: the compiler re-invokes the executable that is running. That is the OS's own answer (GetModuleFileNameW; _NSGetExecutablePath; /proc/self/exe), not a PATH guess. The runtime exposes none today, so this needs a runtime function, which is seed-gated for src/. Until then, a bare argv[0] on Windows should be looked up in the current directory before PATH, as cmd does.

Activity

  1. ehartford commented on Oct 26, 2026

    @ehartford
    ContributorAuthor

    Fixed on main by 27092dc (stack #2743, battery GREEN on its top ddb68e8: behavior-tests 1949/1949, gate, uat and battery-checks green).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions