From 7ca2811f3a435ab4bcef463a1fcb7ac9df8eb550 Mon Sep 17 00:00:00 2001 From: Maokaman1 Date: Mon, 4 May 2026 08:25:35 +0300 Subject: [PATCH] ci: fix windows tcc stack (#27084) --- .github/workflows/windows-install-sqlite.bat | 9 +-- .github/workflows/windows-install-sqlite.ps1 | 77 -------------------- .github/workflows/windows_ci_tcc.yml | 46 +----------- 3 files changed, 4 insertions(+), 128 deletions(-) delete mode 100644 .github/workflows/windows-install-sqlite.ps1 diff --git a/.github/workflows/windows-install-sqlite.bat b/.github/workflows/windows-install-sqlite.bat index 92dcc4904..45dd54090 100644 --- a/.github/workflows/windows-install-sqlite.bat +++ b/.github/workflows/windows-install-sqlite.bat @@ -1,10 +1,3 @@ REM This file should be run from the top folder of the V compiler itself. -REM -REM Historically this invoked `v vlib/db/sqlite/install_thirdparty_sqlite.vsh`, -REM which compiled and ran a V script to download the SQLite amalgamation. On -REM tcc-windows CI that .vsh compile reliably crashes with EXCEPTION_STACK_OVERFLOW -REM (0xc00000fd) before the download starts, blocking the entire job. The native -REM PowerShell implementation does the same work without invoking the V compiler, -REM and is faster on every Windows CI variant since it avoids a full V compile. -pwsh.exe -NoProfile -ExecutionPolicy Bypass -File "%~dp0windows-install-sqlite.ps1" +v vlib/db/sqlite/install_thirdparty_sqlite.vsh diff --git a/.github/workflows/windows-install-sqlite.ps1 b/.github/workflows/windows-install-sqlite.ps1 deleted file mode 100644 index b31177a72..000000000 --- a/.github/workflows/windows-install-sqlite.ps1 +++ /dev/null @@ -1,77 +0,0 @@ -$ErrorActionPreference = 'Stop' - -$downloadPage = 'https://sqlite.org/download.html' -Write-Host "> Getting $downloadPage ..." -$page = Invoke-WebRequest -Uri $downloadPage -UseBasicParsing -$line = ($page.Content -split "`n") | - Where-Object { $_ -match '^PRODUCT,.*amalgamation' } | - Select-Object -First 1 -if (-not $line) { - throw "Could not find amalgamation PRODUCT line in $downloadPage" -} -$parts = $line.Split(',') -if ($parts.Length -lt 5) { - throw "Malformed PRODUCT line: $line" -} -$version = $parts[1] -$relpath = $parts[2] -$expectedSize = [int64]$parts[3] -$expectedSha3 = $parts[4].Trim().ToLower() -$zipName = [System.IO.Path]::GetFileName($relpath) -$zipUrl = "https://sqlite.org/$relpath" -$amalgName = ($zipName.ToLower() -replace '\.zip$','') - -Write-Host "> SQLite amalgamation version: $version" -Write-Host "> URL: $zipUrl" -Write-Host "> expected size: $expectedSize" -Write-Host "> expected SHA3: $expectedSha3" - -Write-Host "> Downloading $zipUrl ..." -Invoke-WebRequest -Uri $zipUrl -OutFile $zipName -UseBasicParsing - -$actualSize = (Get-Item $zipName).Length -if ($actualSize -ne $expectedSize) { - throw "Download size $actualSize != expected $expectedSize" -} -Write-Host "> download size: $actualSize matches expected size: $expectedSize" - -# SHA3_256 is supported by Get-FileHash starting in PowerShell 7.4. Probe support -# by attempting one call; if the algorithm is not recognized, fall back to a -# warning rather than failing the build. -$sha3Supported = $true -try { - [void](Get-FileHash -Algorithm SHA3_256 -Path $zipName) -} catch { - $sha3Supported = $false - Write-Warning "SHA3_256 not supported on this PowerShell ($($PSVersionTable.PSVersion)); skipping checksum verification" -} -if ($sha3Supported) { - $hash = (Get-FileHash -Algorithm SHA3_256 -Path $zipName).Hash.ToLower() - if ($hash -ne $expectedSha3) { - throw "SHA3 mismatch: got $hash, expected $expectedSha3" - } - Write-Host "> download sha3: $hash matches" -} - -Write-Host "> Extracting $zipName to thirdparty\ ..." -if (-not (Test-Path thirdparty)) { - New-Item -ItemType Directory -Path thirdparty | Out-Null -} -Expand-Archive -Path $zipName -DestinationPath thirdparty -Force - -if (Test-Path thirdparty\sqlite) { - Remove-Item -Recurse -Force thirdparty\sqlite -} -Move-Item -Path "thirdparty\$amalgName" -Destination thirdparty\sqlite - -if (Test-Path thirdparty\sqlite\shell.c) { - Remove-Item thirdparty\sqlite\shell.c -} - -Get-ChildItem thirdparty\sqlite -File | ForEach-Object { - Write-Host ('> extracted file: {0,-40} | size: {1,8}' -f $_.FullName, $_.Length) -} - -Write-Host "> removing $zipName ..." -Remove-Item $zipName -Write-Host '> done' diff --git a/.github/workflows/windows_ci_tcc.yml b/.github/workflows/windows_ci_tcc.yml index 053ad55fd..65a606953 100644 --- a/.github/workflows/windows_ci_tcc.yml +++ b/.github/workflows/windows_ci_tcc.yml @@ -43,49 +43,9 @@ jobs: - name: Test new v.c run: | v -o v.c cmd/v - .\thirdparty\tcc\tcc.exe -Werror -w -ladvapi32 -lws2_32 -bt10 v.c - - name: Diagnostic - bisect which module triggers the SEH crash - # Last run showed v.exe (tcc-built) crashes while *compiling* - # install_thirdparty_sqlite.vsh, before any -showcc output appears. - # Bisect by compiling tiny scripts that import each transitive dep - # one at a time, so we know exactly which import is fatal. - # Continue on failure so we see *all* the probe results, not just the first crash. - continue-on-error: true - run: | - where gcc; gcc --version - $ErrorActionPreference = 'Continue' - New-Item -ItemType Directory -Force -Path probes | Out-Null - # Use double-quoted strings so `n is interpreted as newline. - # V accepts single-quoted string literals, so we can safely embed them inside PS double-quotes. - Set-Content -Encoding ascii probes\trivial.v "fn main() { println('hi') }" - Set-Content -Encoding ascii probes\imp_os.v "import os`nfn main() { println(os.args.len) }" - Set-Content -Encoding ascii probes\imp_http.v "import net.http`nfn main() { _ := http.new_request(.get, 'http://x', '') }" - Set-Content -Encoding ascii probes\imp_szip.v "import compress.szip`nfn main() { println(int(szip.CompressionLevel.no_compression)) }" - Set-Content -Encoding ascii probes\imp_sha3.v "import crypto.sha3`nfn main() { println(sha3.sum256('hi'.bytes()).hex()) }" - Get-Content probes\imp_http.v - foreach ($cc in 'gcc','tcc') { - foreach ($probe in 'trivial','imp_os','imp_http','imp_szip','imp_sha3') { - $src = "probes\${probe}.v" - $exe = "probes\${probe}_${cc}.exe" - Write-Host "==== probe: $cc / $probe ====" - v -cc $cc -g -stats -o $exe $src - if (Test-Path $exe) { & $exe } else { Write-Host "(no exe produced)" } - } - } - Write-Host "==== full vsh: gcc ====" - v -cc gcc -g -stats -o probes\full_gcc.exe vlib/db/sqlite/install_thirdparty_sqlite.vsh - if (Test-Path probes\full_gcc.exe) { .\probes\full_gcc.exe } else { Write-Host "(no exe)" } - Write-Host "==== full vsh: tcc ====" - v -cc tcc -g -stats -o probes\full_tcc.exe vlib/db/sqlite/install_thirdparty_sqlite.vsh - if (Test-Path probes\full_tcc.exe) { .\probes\full_tcc.exe } else { Write-Host "(no exe)" } - # Rebuild v itself with gcc and retry the script. If THIS works but the tcc-built v - # crashes on the same input, the bug is in tcc's codegen of v.exe, not in v's source. - Write-Host "==== rebuild v with gcc, then compile vsh ====" - v -cc gcc -o v_gcc.exe cmd/v - if (Test-Path v_gcc.exe) { - .\v_gcc.exe -cc gcc -g -stats -o probes\full_vgcc.exe vlib/db/sqlite/install_thirdparty_sqlite.vsh - if (Test-Path probes\full_vgcc.exe) { .\probes\full_vgcc.exe } else { Write-Host "(no exe from gcc-built v)" } - } else { Write-Host "(could not build v_gcc.exe)" } + # Match makev.bat's Windows stack reserve; the direct TCC-built + # compiler can otherwise crash while compiling net.http-heavy scripts. + .\thirdparty\tcc\tcc.exe -Werror -w -ladvapi32 -lws2_32 -bt10 '-Wl,-stack=33554432' v.c - name: Install dependencies run: | v retry -- v setup-freetype -- 2.39.5