Repository navigation
scripts: start _build.cmd with cmd /s /c ""path"" so & and ^ survive - #3554
Conversation
build_runtime.ps1 and build_llvm_mc.ps1 started the generated batch with `cmd.exe /c "path"`. cmd.exe drops those quotes when the path holds a special character such as & or ^, then runs only the part before it, so a checkout (build_runtime) or -Temp/%TEMP% (build_llvm_mc) in a folder like `a & b` failed at once with "C:\...\a is not recognized". With /s and a second pair of quotes, cmd.exe strips only the outer pair. tests/test_build_batch_launch.py takes each script's launch line as written and runs it on a stub batch in folders named plain, `a & b`, `a&b`, `x^y`, `sp (x)` and `東京 & co`: the stub must run and its exit code (0 and 7) must come back. It also checks that the old form fails there. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Code read (no test run: this machine is in a no-background-work window). This is the canonical form: The comment you added is the part that keeps it from being "fixed" back later; worth keeping it in both places, as you did. |
slint6614-dev
left a comment
There was a problem hiding this comment.
Independent Windows validation of fc3bda5c (PowerShell 5.1.26100.9818, Python 3.12.10): python -I tests/test_build_batch_launch.py passed 2/2. It exercises both scripts with paths containing spaces, &, ^, parentheses and Unicode, and verifies child exit codes 0 and 7. The negative control also confirms the old /c "path" form fails for & and ^. I did not run the full compiler/toolchain builds. No blocking issue in this focused change.
|
Tested
|
VeTkN
left a comment
There was a problem hiding this comment.
Tested fc3bda5 on Windows 11 Pro (26200), MSVC 19.51 (VS 2026 Build Tools): a full scripts/build_runtime.ps1 build from a git worktree of this PR at C:\LT\amp&caret^dir, the run the description lists as not done.
- With this PR's scripts the launch works: CMake configures and Ninja starts. Step 13 of 431, linking
gta6rt_xtaskqueue.lib, then fails, and Ninja stops at step 18. Ninja runslib.exethroughcmd.exe /Cwith the object paths unquoted, and those paths contain the folder name, because the xtaskqueue sources sit outsideruntime/(CMakeFiles\gta6rt_xtaskqueue.dir\C_\LT\amp&caret^dir\third_party\xtaskqueue\...). cmd splits at the&:fatal error LNK1181onCMakeFiles\gta6rt_xtaskqueue.dir\C_\LT\amp. - With main's two scripts in the same folder: exit 1 at once, with no build output. So the launch fix itself works.
- Control, this PR in a plain folder (
C:\LT\plain): exit 0, 248 s, all 431 steps,gta6rt.exebuilt.
So the launcher part is fixed, but a full runtime build from a folder with & still fails in the generated build, outside this PR's scope. Maybe worth a Known problems row or a follow-up item. I only tried a name with both & and ^ (the cut is at the &), and didn't run build_llvm_mc.ps1.
AI-assisted (Claude).
Claim: #3381 (comment)
What changed and why
scripts/build_runtime.ps1andscripts/build_llvm_mc.ps1started the generated batch withStart-Process cmd.exe -ArgumentList "/c", "\"$bat\"". cmd.exe drops those quotes when the path holds a special character such as&or^, then runs only the part before it. So a checkout (build_runtime.ps1) or a-Temp/%TEMP%(build_llvm_mc.ps1) in a folder likeC:\src\a & bfailed straight away with"C:\src\a" is not recognized. Both now use"/s", "/c", "\"\"$bat\"\"": with/scmd.exe strips only the outer pair of quotes, so the path stays quoted. One line in each script; the batch body is unchanged, and its paths are already quoted inside the.cmd.New
tests/test_build_batch_launch.pytakes each script's$p = Start-Process cmd.exe -ArgumentList ...line as written and runs it on a stub_build.cmdin folders namedplain,a & b,a&b,x^y,sp (x)and東京 & co. The stub must run, and its exit code (0 and 7) must come back. A second case checks that the old form fails in the&/^folders, so the check can't pass by accident.Touches the same scripts as #3250, #3363, #3029, #2975, #2717, #2648, #2515, #2497, #1797, #802 and #157. None of them changes this line except #1797, which rewrites it but keeps
/c "path".Tests (Windows 11, Windows PowerShell 5.1, Python 3.12.10, CPU only, no GPU used)
python -I tests/test_build_batch_launch.py: 2 tests OK.mainf847748c, it fails for both scripts: all 8&/^cases of the 12 break, and the 4plainandsp (x)cases pass.100%andit's), each with exit 0 and 7: old 8/16, new 16/16.python -I tests/test_ci_registration.py,tests/test_text_write_line_endings.py: OK.tests/test_build_runtime_fallback.pyandtests/test_build_llvm_mc_batch.py: OK withNoDefaultCurrentDirectoryInExePathunset; with it set they fail onmaintoo (fixed separately in tests: start _build.cmd as .\_build.cmd in the two batch-writer tests #3380).build_runtime.ps1/build_llvm_mc.ps1build from such a folder (needs MSVC plus the full toolchain); only the launch line was exercised, with a stub batch.AI-assisted (Claude Code).