Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions scripts/build-cso-windows.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,13 @@ try {
$output = Join-Path $temporary 'probe.exe'
Set-Content -LiteralPath $source -Encoding Ascii -NoNewline -Value 'int main(void) { return 0; }'
$object = Join-Path $temporary 'probe.obj'
& $compiler /nologo /std:c11 /W4 /WX /O2 /MT /GS /guard:cf /D_CRT_SECURE_NO_WARNINGS "/Fo$object" "/Fe$output" $source /link /DYNAMICBASE /NXCOMPAT /HIGHENTROPYVA
# /wd5105: warning C5105 ("macro expansion producing 'defined' has
# undefined behavior") is raised by the Windows SDK's own winbase.h
# (observed on SDK 10.0.19041.0 with current MSVC). With /W4 /WX it is
# promoted to error C2220 and the build aborts inside a system header,
# for a warning the project cannot act on. Disable that one diagnostic
# rather than dropping /WX for real warnings.
& $compiler /nologo /std:c11 /W4 /WX /wd5105 /O2 /MT /GS /guard:cf /D_CRT_SECURE_NO_WARNINGS "/Fo$object" "/Fe$output" $source /link /DYNAMICBASE /NXCOMPAT /HIGHENTROPYVA
if ($LASTEXITCODE -ne 0) { throw "Native CSO Windows compiler probe failed ($LASTEXITCODE)." }
if (-not (Test-Path -LiteralPath $output -PathType Leaf)) { throw 'Native CSO Windows compiler probe was not produced.' }
} else {
Expand All @@ -78,7 +84,9 @@ try {
foreach ($build in $builds) {
$object = Join-Path $temporary $build.Object
$forcedInclude = if ($build.Binding) { "/FI$binding" } else { @() }
& $compiler /nologo /std:c11 /W4 /WX /O2 /MT /GS /guard:cf /D_CRT_SECURE_NO_WARNINGS $forcedInclude "/Fo$object" "/Fe$($build.Output)" $build.Source /link /DYNAMICBASE /NXCOMPAT /HIGHENTROPYVA
# /wd5105: see the probe comment above — C5105 comes from the Windows
# SDK's winbase.h and must not abort a /WX build inside a system header.
& $compiler /nologo /std:c11 /W4 /WX /wd5105 /O2 /MT /GS /guard:cf /D_CRT_SECURE_NO_WARNINGS $forcedInclude "/Fo$object" "/Fe$($build.Output)" $build.Source /link /DYNAMICBASE /NXCOMPAT /HIGHENTROPYVA
if ($LASTEXITCODE -ne 0) { throw "Native CSO Windows helper compilation failed ($LASTEXITCODE)." }
if (-not (Test-Path -LiteralPath $build.Output -PathType Leaf)) { throw 'Native CSO Windows output was not produced.' }
}
Expand Down
8 changes: 6 additions & 2 deletions setup
Original file line number Diff line number Diff line change
Expand Up @@ -1005,9 +1005,13 @@ probe_cso_build_prerequisites() {
_cso_unavailable "windows-git"
return 0
fi
if ! powershell.exe -NoProfile -NonInteractive -ExecutionPolicy Bypass \
-File "$_ps_script" -RepoRoot "$_repo_root" -GitExePath "$(cygpath -aw "$_git_path")" -CheckOnly >/dev/null 2>&1; then
if ! _cso_probe_out="$(powershell.exe -NoProfile -NonInteractive -ExecutionPolicy Bypass \
-File "$_ps_script" -RepoRoot "$_repo_root" -GitExePath "$(cygpath -aw "$_git_path")" -CheckOnly 2>&1)"; then
# The probe's own diagnostics matter: "install Visual Studio 2022 Build
# Tools" is wrong whenever vswhere already resolves the MSVC toolchain and
# the failure came from a compile step instead. Keep the message visible.
_cso_unavailable "windows-msvc-toolchain"
[ -n "$_cso_probe_out" ] && printf '%s\n' "$_cso_probe_out" >&2
fi
return 0
fi
Expand Down