From 1a8e502e2c6f87ce4dd07df566cb1f891021ccf0 Mon Sep 17 00:00:00 2001 From: Ruofan XU <47302112+SleepyRoy@users.noreply.github.com> Date: Thu, 25 Feb 2021 19:52:12 +0800 Subject: [PATCH] ci: add tcc32 CI on windows (#8922) --- .github/workflows/ci.yml | 44 +++++++++++++++++++++++++++++++++++++++- make.bat | 20 ++++++++++-------- vlib/gg/m4/m4_test.v | 6 +++--- vlib/gg/m4/matrix.v | 2 +- vlib/sync/channels.v | 2 +- vlib/v/gen/c/profile.v | 2 +- 6 files changed, 61 insertions(+), 15 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 20f85439ce..7e51fdf033 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -725,7 +725,7 @@ jobs: - name: v2 self compilation run: .\v.exe -o v2.exe cmd/v && .\v2.exe -o v3.exe cmd/v - windows-tcc: + windows-tcc64: runs-on: windows-2019 timeout-minutes: 30 env: @@ -767,6 +767,48 @@ jobs: - name: v2 self compilation run: .\v.exe -o v2.exe cmd/v && .\v2.exe -o v3.exe cmd/v + windows-tcc32: + runs-on: windows-2019 + timeout-minutes: 30 + env: + VFLAGS: -cc tcc -no-retry-compilation + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v1 + with: + node-version: 12.x + - name: Build with make.bat -tcc32 + run: | + .\make.bat -tcc32 + - name: Test new v.c + run: .\v.exe -o v.c cmd/v && .\thirdparty\tcc\tcc.exe -Werror -w -ladvapi32 -bt10 v.c + - name: Install dependencies + run: | + .\v.exe setup-freetype + .\.github\workflows\windows-install-sqlite.bat + ## .\.github\workflows\windows-install-sdl.bat + - name: v doctor + run: | + ./v doctor + - name: Verify `v test` works + run: | + .\v.exe cmd/tools/test_if_v_test_system_works.v + .\cmd\tools\test_if_v_test_system_works.exe + - name: Self tests + run: | + .\v.exe -silent test-self + # - name: Test + # run: | + # .\v.exe -silent test-all + - name: Test v->js + run: ./v -o hi.js examples/hello_v_js.v && node hi.js + - name: Test v binaries + run: ./v build-vbinaries + - name: Build examples + run: ./v build-examples + - name: v2 self compilation + run: .\v.exe -o v2.exe cmd/v && .\v2.exe -o v3.exe cmd/v + compilable-v-c-and-v-win-c: runs-on: ubuntu-20.04 timeout-minutes: 30 diff --git a/make.bat b/make.bat index 647ff839c7..b55b3c0ff9 100644 --- a/make.bat +++ b/make.bat @@ -43,7 +43,9 @@ if !shift_counter! LSS 1 ( ) REM Compiler option -for %%g in (-gcc -msvc -tcc -clang) do ( +for %%g in (-gcc -msvc -tcc -tcc32 -clang) do ( + if "%PROCESSOR_ARCHITECTURE%" == "x86" set "tcc_branch=thirdparty-windows-i386" + if "%~1" == "-tcc32" set "tcc_branch=thirdparty-windows-i386" if "%~1" == "%%g" set compiler=%~1& set compiler=!compiler:~1!& shift& set /a shift_counter+=1& goto :verifyopt ) @@ -282,6 +284,7 @@ if %ERRORLEVEL% NEQ 0 goto :compile_error goto :success :tcc_strap +:tcc32_strap if [!compiler!] == [] set /a invalid_cc=1 echo ^> Attempting to build v_win.c with TCC if !flag_verbose! EQU 1 ( @@ -362,18 +365,19 @@ echo Usage: echo make.bat [target] [compiler] [options] echo. echo Compiler: -echo -msvc ^| -gcc ^| -tcc ^| -clang Set C compiler +echo -msvc ^| -gcc ^| -tcc ^| -tcc32 ^| -clang Set C compiler echo. echo Target: -echo build[default] Compiles V using the given C compiler -echo clean Clean build artifacts and debugging symbols -echo clean-all Cleanup entire ALL build artifacts and vc repository -echo help Display usage help for the given target +echo build[default] Compiles V using the given C compiler +echo clean Clean build artifacts and debugging symbols +echo clean-all Cleanup entire ALL build artifacts and vc repository +echo help Display usage help for the given target echo. echo Examples: echo make.bat -msvc echo make.bat -gcc --local --logpath output.log -echo make.bat build -fresh-tcc --local +echo make.bat build -tcc --local +echo make.bat -tcc32 echo make.bat help clean echo. echo Use "make help " for more information about a target, for instance: "make help clean" @@ -412,7 +416,7 @@ echo Usage: echo make.bat build [compiler] [options] echo. echo Compiler: -echo -msvc ^| -gcc ^| -[fresh-]tcc ^| -clang Set C compiler +echo -msvc ^| -gcc ^| -tcc ^| -tcc32 ^| -clang Set C compiler echo. echo Options: echo --local Use the local vc repository without diff --git a/vlib/gg/m4/m4_test.v b/vlib/gg/m4/m4_test.v index 916b9c986f..02f27f97e4 100644 --- a/vlib/gg/m4/m4_test.v +++ b/vlib/gg/m4/m4_test.v @@ -191,10 +191,10 @@ fn test_vec4() { assert v + m4.Vec4{ e: [f32(5), 6, 7, 8]! } == m4.Vec4{ e: [f32(6), 8, 10, 12]! } assert v - m4.Vec4{ e: [f32(1), 2, 3, 4]! } == m4.Vec4{ e: [f32(0), 0, 0, 0]! } assert v.mul_vec4(m4.Vec4{ e: [f32(2), 2, 2, 2]! }) == m4.Vec4{ e: [f32(2), 4, 6, 8]! } - assert v.normalize().mod() == 1 + assert m4.abs(v.normalize().mod() - 1) < m4.precision v = m4.Vec4{[f32(1), 2, 3, 0]!} - assert v.normalize3().mod3() - 1 < m4.precision - assert v.normalize3().mod() - 1 < m4.precision + assert m4.abs(v.normalize3().mod3() - 1) < m4.precision + assert m4.abs(v.normalize3().mod() - 1) < m4.precision // x y z // 1 2 3 ==> -3 6 -3 0 // 4 5 6 diff --git a/vlib/gg/m4/matrix.v b/vlib/gg/m4/matrix.v index 376ce3d472..0693b4be09 100644 --- a/vlib/gg/m4/matrix.v +++ b/vlib/gg/m4/matrix.v @@ -27,7 +27,7 @@ pub const precision = f32(10e-7) * Utility * *********************************************************************/ -fn abs(a f32) f32 { +pub fn abs(a f32) f32 { if a >= f32(0.0) { return a } else { diff --git a/vlib/sync/channels.v b/vlib/sync/channels.v index 954de2f346..cfabbb820d 100644 --- a/vlib/sync/channels.v +++ b/vlib/sync/channels.v @@ -366,7 +366,7 @@ pub fn (mut ch Channel) try_pop(dest voidptr) ChanState { } fn (mut ch Channel) try_pop_priv(dest voidptr, no_block bool) ChanState { - spinloops_sem_, spinloops_ := if no_block { 1, 1 } else { spinloops, spinloops_sem } + spinloops_sem_, spinloops_ := if no_block { 1, 1 } else { spinloops, spinloops_sem } mut have_swapped := false mut write_in_progress := false for { diff --git a/vlib/v/gen/c/profile.v b/vlib/v/gen/c/profile.v index 044a3de391..602c7b0500 100644 --- a/vlib/v/gen/c/profile.v +++ b/vlib/v/gen/c/profile.v @@ -35,7 +35,7 @@ fn (mut g Gen) profile_fn(fn_decl ast.FnDecl) { pub fn (mut g Gen) gen_vprint_profile_stats() { g.pcs_declarations.writeln('void vprint_profile_stats(){') - fstring := '"%14lu %14.3fms %14.0fns %s \\n"' + fstring := '"%14llu %14.3fms %14.0fns %s \\n"' if g.pref.profile_file == '-' { for pc_meta in g.pcs { g.pcs_declarations.writeln('\tif ($pc_meta.vpc_calls) printf($fstring, $pc_meta.vpc_calls, $pc_meta.vpc_name/1000000.0, $pc_meta.vpc_name/$pc_meta.vpc_calls, "$pc_meta.fn_name" );')