fix(agent): through the work drive, clang runs its compile in-process and finds its linker there #47

Merged
HumanBean merged 1 commit from HumanBean/Beanstalk:fix/win-clang-drive into main 2026-11-16 06:35:43 +00:00
Owner

Why

#46 works as far as it goes. On futondestroyer's PC (nightly-86, rp_d3667d4312a3f2db, Longshot #910) the sandbox sees the work drive (BEANSTALK_WORK_DRIVE Z:), and clang-23.exe --version runs: directly, through the launcher, and with CreateProcessW. GetLongPathNameW succeeds too. But make_game.py's compile-and-link check still failed:

<home>/work/tools/llvm-mingw/bin/clang-23.exe: Permission denied

That's the real path again, not Z:\. clang's driver resolves its own path through the drive back to the real folder ("canonical prefixes", GetExecutablePath → getMainExecutable → real_path). It then starts its compile (-cc1) and its linker from that real path, and LLVM's start is refused there exactly as before. --version never starts either, which is why the probe passed.

The driver decides canonical prefixes before it reads CCC_OVERRIDE_OPTIONS (clang/tools/driver/driver.cpp, around lines 282–325), so -no-canonical-prefixes can't be added through that variable. Two things it decides after reading it can:

  • -fintegrated-cc1: run the compile in the same process, so nothing is started from the real path;
  • -B<drive>\tools\llvm-mingw\bin: look up the linker (ld.lld) there first, so it starts from the drive.

What changed

  • WinDrive.ClangOverride: #+-fintegrated-cc1 +-B<llvm-mingw on the drive>\bin. The # makes clang apply it silently. It returns null when llvm-mingw isn't on the drive, or when its path has a space, because the variable splits on spaces.
  • WinSandbox.Prepare: when the drive is used, sandboxed commands get that as CCC_OVERRIDE_OPTIONS, unless it's already set.
  • The probe now compiles and links a test program the way make_game.py does, once with the override and once without. It also prints CCC_OVERRIDE_OPTIONS.

Testing

  • Agent checks: 1704 passed. New checks cover the override on the drive, nothing when llvm-mingw isn't on the drive, and nothing when the path has a space.
  • dotnet build agent/App -c Release: 0 warnings.
  • Not tested on Windows. The next Windows job's probe lines show whether the compile works with the override (@@probe spawn compile … exit 0) and fails without it. Its report shows how far main's build gets. Another tool started by its canonical path could still fail the same way; the probe and the build log would show that.
## Why #46 works as far as it goes. On futondestroyer's PC (nightly-86, [rp_d3667d4312a3f2db](https://beanstalk.magicbean.dev/reports/rp_d3667d4312a3f2db), Longshot #910) the sandbox sees the work drive (`BEANSTALK_WORK_DRIVE Z:`), and `clang-23.exe --version` runs: directly, through the launcher, and with `CreateProcessW`. `GetLongPathNameW` succeeds too. But `make_game.py`'s compile-and-link check still failed: ``` <home>/work/tools/llvm-mingw/bin/clang-23.exe: Permission denied ``` That's the real path again, not `Z:\`. clang's driver resolves its own path through the drive back to the real folder ("canonical prefixes", `GetExecutablePath` → `getMainExecutable` → `real_path`). It then starts its compile (`-cc1`) and its linker from that real path, and LLVM's start is refused there exactly as before. `--version` never starts either, which is why the probe passed. The driver decides canonical prefixes before it reads `CCC_OVERRIDE_OPTIONS` (`clang/tools/driver/driver.cpp`, around lines 282–325), so `-no-canonical-prefixes` can't be added through that variable. Two things it decides after reading it can: - `-fintegrated-cc1`: run the compile in the same process, so nothing is started from the real path; - `-B<drive>\tools\llvm-mingw\bin`: look up the linker (`ld.lld`) there first, so it starts from the drive. ## What changed - `WinDrive.ClangOverride`: `#+-fintegrated-cc1 +-B<llvm-mingw on the drive>\bin`. The `#` makes clang apply it silently. It returns null when llvm-mingw isn't on the drive, or when its path has a space, because the variable splits on spaces. - `WinSandbox.Prepare`: when the drive is used, sandboxed commands get that as `CCC_OVERRIDE_OPTIONS`, unless it's already set. - The probe now compiles and links a test program the way `make_game.py` does, once with the override and once without. It also prints `CCC_OVERRIDE_OPTIONS`. ## Testing - Agent checks: 1704 passed. New checks cover the override on the drive, nothing when llvm-mingw isn't on the drive, and nothing when the path has a space. - `dotnet build agent/App -c Release`: 0 warnings. - **Not tested on Windows.** The next Windows job's probe lines show whether the compile works with the override (`@@probe spawn compile … exit 0`) and fails without it. Its report shows how far `main`'s build gets. Another tool started by its canonical path could still fail the same way; the probe and the build log would show that.
fix(agent): through the work drive, clang runs its compile in-process and finds its linker there
Some checks are pending
CI / Coordinator tests (pull_request) Waiting to run
CI / Agent build and checks (pull_request) Waiting to run
CI / Coordinator image (pull_request) Waiting to run
CI / Conventional Commit title (pull_request) Successful in 3s
CI / Workflow lint (actionlint) (pull_request) Successful in 3s
de32b4a0d8
With #46 the sandbox sees the work drive and clang-23.exe --version works
(Longshot #910 on nightly-86, rp_d3667d4312a3f2db), but a real compile still
failed: "<home>/work/tools/llvm-mingw/bin/clang-23.exe: Permission denied".
clang's driver resolves its own path (canonical prefixes) through the drive
back to the real folder, then starts its compile (-cc1) and its linker from
there, where LLVM's start is refused as before. It decides that before it
reads CCC_OVERRIDE_OPTIONS (clang/tools/driver/driver.cpp), so
-no-canonical-prefixes can't be added that way, but what it decides after
can: -fintegrated-cc1 (the compile in the same process) and -B<drive's
llvm-mingw\bin> (the linker looked up there first).

When the drive is used, sandboxed commands get CCC_OVERRIDE_OPTIONS with
both ("#": silent), unless it is set already. The probe now also compiles
and links a test program, with the override and without it.

Assisted-by: Claude Opus 5.5
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
MagicBeanDev/Beanstalk!47
No description provided.