Skip to content

v3: make V3 the default compiler on Linux, report fallback bugs, and enforce it in CI #6136

v3: make V3 the default compiler on Linux, report fallback bugs, and enforce it in CI

v3: make V3 the default compiler on Linux, report fallback bugs, and enforce it in CI #6136

name: CI Windows TCC
on:
push:
branches:
- master
paths-ignore:
- 'vlib/v3/**'
- '**.md'
- '**.yml'
- '!**.bat'
- '!**/windows_ci_tcc.yml'
- 'cmd/tools/**'
- '!cmd/tools/builders/**.v'
pull_request:
paths-ignore:
- 'vlib/v3/**'
- '**.md'
- '**.yml'
- '!**.bat'
- '!**/windows_ci_tcc.yml'
- '!**/windows-install-sqlite.bat'
- 'cmd/tools/**'
- '!cmd/tools/builders/**.v'
concurrency:
group: windows-${{ github.workflow }}-${{ github.ref == 'refs/heads/master' && github.sha || github.ref }}
cancel-in-progress: true
jobs:
tcc-windows:
runs-on: windows-2022
timeout-minutes: 60
env:
VFLAGS: -cc tcc -no-retry-compilation
VTEST_SHOW_LONGEST_BY_RUNTIME: 3
VTEST_SHOW_LONGEST_BY_COMPTIME: 3
VTEST_SHOW_LONGEST_BY_TOTALTIME: 3
steps:
- uses: actions/checkout@v7
- name: Install OpenSSL
run: |
choco install openssl -y --no-progress
# choco's openssl package (Win64OpenSSL installer under the hood)
# deploys to `C:\Program Files\OpenSSL\`, matching
# ecdsa.c.v/rsa_pss.c.v's SECOND `#flag windows` fallback path --
# NOT the first one (`...OpenSSL-Win64\...`), confirmed by an
# actual CI run after guessing wrong the first time.
$opensslBin = 'C:\Program Files\OpenSSL\bin'
if (-not (Test-Path $opensslBin)) {
throw "OpenSSL bin directory not found at $opensslBin after choco install"
}
Add-Content -Path $env:GITHUB_PATH -Value $opensslBin
Write-Host "OpenSSL install:"
Get-ChildItem 'C:\Program Files\OpenSSL\lib\VC\x64\MD'
Write-Host "OpenSSL bin DLLs:"
Get-ChildItem $opensslBin -Filter *.dll
# TCC resolves `-lcrypto`/`-lssl` by searching the -L dir for
# `lib<name>.def` FIRST (confirmed against tinycc's own source,
# tcc_add_library's PE search-pattern array: "%s/%s.def",
# "%s/lib%s.def", "%s/%s.dll", "%s/lib%s.dll"), and when a .def
# file is found, tccpe.c's pe_load_def reads the file's own
# `LIBRARY <name>` directive via get_token() to get the DLL
# filename to embed in the import table. Confirmed against
# tinycc's own source that get_token() does NOT strip surrounding
# double quotes, and the extracted name is used AS-IS with no
# `.dll` extension appended. This OpenSSL 4.0.1 package's
# libcrypto.def/libssl.def declare `LIBRARY "libcrypto-4-x64"` /
# `LIBRARY "libssl-4-x64"` -- quoted, no extension -- so TCC
# embeds the LITERAL string `"libcrypto-4-x64"` (quote characters
# included, no `.dll`) as the runtime DLL name. `"` is illegal in
# a Windows filename, so NO real file can ever match that name --
# guaranteeing STATUS_DLL_NOT_FOUND (exit -1073741515, empty
# output) for every TCC-linked test touching
# crypto.ecdsa/crypto.rsa_pss/net.quic, confirmed via an actual CI
# failure, regardless of what DLLs actually exist in bin\ (MSVC
# is unaffected: it reads the DLL name from the .lib's own
# build-time metadata, which is already a valid, unquoted,
# extensioned filename). A file-aliasing workaround (mirroring
# msvc-windows' crypto.lib/libcrypto.lib alias) CANNOT fix this --
# you cannot create a file whose name contains a literal `"` on
# Windows. Fix at the source instead: rewrite each .def's LIBRARY
# line in place, stripping the quotes and appending `.dll` if
# missing, before TCC ever reads it. The rewritten name
# (`libcrypto-4-x64.dll`) already exists as a real file in bin\
# (this package ships both v3 and v4 runtime DLLs side by side),
# so no aliasing is needed once the .def itself is correct.
$libDir = 'C:\Program Files\OpenSSL\lib\VC\x64\MD'
foreach ($name in @('libcrypto', 'libssl')) {
$defPath = Join-Path $libDir "$name.def"
if (-not (Test-Path $defPath)) {
Write-Host "$name.def not found at $defPath, skipping LIBRARY-line fix"
continue
}
$lines = Get-Content $defPath
$fixedAny = $false
$newLines = $lines | ForEach-Object {
if ($_ -match '^(\s*LIBRARY\s+)"?([^"\s]+)"?\s*$') {
$dllName = $Matches[2]
if ($dllName -notmatch '\.dll$') {
$dllName = "$dllName.dll"
}
Write-Host "${name}: rewriting LIBRARY line '$_' -> 'LIBRARY $dllName'"
$fixedAny = $true
"LIBRARY $dllName"
} else {
$_
}
}
if ($fixedAny) {
Set-Content -Path $defPath -Value $newLines
} else {
Write-Host "${name}: no LIBRARY line found to rewrite in $defPath"
}
}
- name: Build with makev.bat -tcc
run: |
.\makev.bat -tcc
.\v.exe symlink
- name: Pkg-config regression (TCC dynamic isolation)
run: |
.\v.exe -cc tcc -no-retry-compilation test vlib\v\checker\pkgconfig_static_mode_test.v
if ($LASTEXITCODE -ne 0) {
throw "pkg-config TCC isolation regression failed with exit code $LASTEXITCODE"
}
- name: All code is formatted
run: v -silent test-cleancode
- name: Test new v.c
run: |
v -o v.c cmd/v
$direct_c_flags = @(
'-Ithirdparty/zip'
'-Ithirdparty/cJSON'
'-Ithirdparty/mbedtls/library'
'-Ithirdparty/mbedtls/include'
'-Ithirdparty/mbedtls/3rdparty/everest/include'
'-Ithirdparty/mbedtls/3rdparty/everest/include/everest'
'-Ithirdparty/mbedtls/3rdparty/everest/include/everest/kremlib'
'-Ithirdparty/vschannel'
)
# 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 @direct_c_flags -ladvapi32 -lws2_32 -bt10 '-Wl,-stack=33554432' v.c
- name: Install dependencies
run: |
v retry -- v setup-freetype
.\.github\workflows\windows-install-sqlite.bat
- name: v -g self
run: v -g self
- name: v doctor
run: |
v doctor
- name: Verify `v test` works
run: |
v cmd/tools/test_if_v_test_system_works.v
.\cmd\tools\test_if_v_test_system_works.exe
- name: Legacy gg import multiwindow isolation
run: v test vlib/gg/legacy_import_multiwindow_isolation_test.v
- name: Verify `v vlib/v/gen/c/coutput_test.v` works
run: v vlib/v/gen/c/coutput_test.v
- name: Make sure running TCC64 instead of TCC32
run: v test .github\workflows\make_sure_ci_run_with_64bit_compiler_test.v
- name: Test ./v doc -v clipboard *BEFORE building tools*
run: v doc -v clipboard
- name: Test v build-tools
run: v -silent -W build-tools
- name: Test pure V math module
run: v -silent -exclude @vlib/math/*.c.v test vlib/math/
- name: Multiwindow render runtime contract
run: .\v.exe -silent vlib\gg\multiwindow_render_runtime_contract_test.v
- name: Self tests
run: v -silent test-self vlib
- name: Test v->js
run: v -o hi.js examples/js_hello_world.v && node hi.js
- name: Test v binaries
run: v build-vbinaries
- name: Build examples
run: v build-examples
- name: Compile and run the veb example (fasthttp) and check its HTML
run: v run .github/workflows/veb_example_windows_smoke.v
- name: v2 self compilation
run: v -o v2.exe cmd/v && .\v2.exe -o v3.exe cmd/v && .\v3.exe -o v4.exe cmd/v