Replace eval with arrays in native build scripts - #133696
ApparentlyPlus wants to merge 3 commits into
Conversation
|
Azure Pipelines: Successfully started running 3 pipeline(s). 13 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
|
@teo-tsirpanis This should be |
|
Tagging subscribers to this area: @dotnet/runtime-infrastructure |
|
Test are green besides the known failures |
Holistic ReviewMotivation: Preserving CMake argument boundaries addresses a real problem with values containing spaces. Approach: Converting argument handling to arrays is appropriate, but upstream callers still combine multiple CMake options into a single string. Those callers need to migrate alongside the downstream handling. Summary: Detailed Findings❌ Argument forwarding — Multiple CMake options become one settingMerge-blocking: Each Consequently, subsequent This breaks existing usage, including the two-option ARM cross-build example in Requested change: Update upstream argument producers so each CMake option reaches the array separately while preserving spaces within values. Cover repeated top-level options, existing multi-option payloads, and values containing spaces; blindly splitting on whitespace would reintroduce the original problem. Reviewed head Note This review was generated by GitHub Copilot. |
|
I'm a bit busy today, I'll check this one out first thing tomorrow |
|
Good catch, I reproduced it.
<_CMakeArgs Include="$([MSBuild]::Unescape($(CMakeArgs.Trim().Replace(' ', ';'))))" />
Important The split happens above the scripts, so |
|
Tests are green and wider this time because I touched the native build harness. Worth another look from someone or copilot regardless, because it's very tricky to debug everything by hand here. |
|
@akoeplinger Just a nudge; no need to rush on this if you've got other priorities! |
|
@ApparentlyPlus I asked copilot to come up with a potential fix, but I'm not sure I like everything in it. Feel free to use if you want: akoeplinger@03f8c9e |
|
Don't worry, I'll take a look and see what's best here. Thanks! |
Forward Unix user arguments after -- instead of splitting them on whitespace in MSBuild. Preserve command-line property escaping, remove obsolete host-path quoting, and cover all three native build routes with regression tests. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 83232ab6-2c12-470f-9469-6d702d797065
|
Okay, Copilot's solution is actually much better than what I came up with, so I tested it and cherry picked it. Mine split I verified it on linux-x64 and macos-arm64 with Copilot also added |
|
@akoeplinger Interesting finding while I was debugging the Copilot suggestion - this exact eval pattern isn't confined to the native build scripts (yay me!). TL;DR: the same eval problem exists in other build paths (test, managed), and the same "flat string instead of array" shape shows up in cross building. I propose we don't fold either in here, but rather in a follow up. Specifically:
Note *One of them isn't a straight eval removal though. None of it regresses this PR, it's just that the scope got slightly bigger again. Truly a gift that keeps on giving :') I'd say merge this one once it's green, then a follow up for the test and cross build ones, then the quoting sweep I described in the issue. That would cover native, managed and test builds on unix. I'll refine the backlog in the issue thread too, better to break it down than battle the abyss here. We're close though! |

Contributes to #73327.
build_nativeassembled thegen-buildsys.shinvocation as a string and ran it througheval, so the command was parsed twice and any path containing a space was split on the second pass. This replaces the string with a bash array passed straight to the script, so quoting is preserved in one parse.Verified locally with a full
./build.sh -c Releaseon linux-x64 and macos-arm64. At a path with a space, the build now gets past CMake configure and dies later, at the unquoted linker--version-script, which is the next set of fixes.