From 50db431cfdef2322245df310f48a38cc14abf308 Mon Sep 17 00:00:00 2001 From: Delyan Angelov Date: Mon, 14 Jul 2025 11:03:56 +0300 Subject: [PATCH] ci: add `-prealloc` self compilation checks on more platforms (#24891) --- .github/workflows/macos_ci.yml | 2 ++ ci/freebsd_ci.vsh | 22 ++++++++++++++++------ ci/linux_ci.vsh | 17 ++++++++++------- ci/macos_ci.vsh | 14 +++++++++++++- 4 files changed, 41 insertions(+), 14 deletions(-) diff --git a/.github/workflows/macos_ci.yml b/.github/workflows/macos_ci.yml index b6462ec043..da8b647ed7 100644 --- a/.github/workflows/macos_ci.yml +++ b/.github/workflows/macos_ci.yml @@ -38,6 +38,8 @@ jobs: run: v run ci/macos_ci.vsh test_symlink - name: v doctor run: v run ci/macos_ci.vsh v_doctor + - name: Build v with -prealloc + run: v run ci/macos_ci.vsh build_v_with_prealloc - name: Test cross compilation to Linux run: v run ci/macos_ci.vsh test_cross_compilation - name: Build V with -cstrict diff --git a/ci/freebsd_ci.vsh b/ci/freebsd_ci.vsh index db576fcdd5..a93918253f 100644 --- a/ci/freebsd_ci.vsh +++ b/ci/freebsd_ci.vsh @@ -18,6 +18,15 @@ fn v_doctor() { } } +fn build_v_with_prealloc() { + exec('v -cg -cstrict -o vstrict1 cmd/v') + exec('./vstrict1 -o vprealloc -prealloc cmd/v') + exec('./vprealloc run examples/hello_world.v') + exec('./vprealloc -o v3 cmd/v') + exec('./v3 -o v4 cmd/v') + exec('./v4 -d debug_malloc -d debug_realloc -o vdebug1 cmd/v') +} + fn verify_v_test_works() { exec('echo \$VFLAGS') exec('v cmd/tools/test_if_v_test_system_works.v') @@ -48,12 +57,13 @@ fn run_essential_tests() { } const all_tasks = { - 'v_doctor': Task{v_doctor, 'Run v doctor'} - 'verify_v_test_works': Task{verify_v_test_works, 'Verify that v test works'} - 'build_fast_script': Task{build_fast_script, 'Check that building fast.v works'} - 'check_math': Task{check_math, 'Check the `math` module works'} - 'check_compress': Task{check_compress, 'Check the `compress` module works'} - 'run_essential_tests': Task{run_essential_tests, 'Run only the essential tests'} + 'v_doctor': Task{v_doctor, 'Run v doctor'} + 'build_v_with_prealloc': Task{build_v_with_prealloc, 'Build V with prealloc'} + 'verify_v_test_works': Task{verify_v_test_works, 'Verify that v test works'} + 'build_fast_script': Task{build_fast_script, 'Check that building fast.v works'} + 'check_math': Task{check_math, 'Check the `math` module works'} + 'check_compress': Task{check_compress, 'Check the `compress` module works'} + 'run_essential_tests': Task{run_essential_tests, 'Run only the essential tests'} } common.run(all_tasks) diff --git a/ci/linux_ci.vsh b/ci/linux_ci.vsh index f4e3163fba..b3f39c8dcc 100644 --- a/ci/linux_ci.vsh +++ b/ci/linux_ci.vsh @@ -41,16 +41,19 @@ fn v_doctor() { exec('v doctor') } +fn build_v_with_prealloc() { + exec('v -cg -cstrict -o vstrict1 cmd/v') + exec('./vstrict1 -o vprealloc -prealloc cmd/v') + exec('./vprealloc run examples/hello_world.v') + exec('./vprealloc -o v3 cmd/v') + exec('./v3 -o v4 cmd/v') + exec('./v4 -d debug_malloc -d debug_realloc -o vdebug1 cmd/v') +} + // // TCC job tasks // -fn build_v_with_prealloc() { - exec('v -d debug_malloc -d debug_realloc -o vdebug1 cmd/v') - exec('v -cg -cstrict -o vstrict1 cmd/v') - exec('v -o vrealloc -prealloc cmd/v && ./vrealloc -o v3 cmd/v && ./v3 -o v4 cmd/v') -} - fn install_dependencies_for_examples_and_tools_tcc() { exec('v retry -- sudo apt update') exec('v retry -- sudo apt install --quiet -y libssl-dev sqlite3 libsqlite3-dev valgrind') @@ -373,8 +376,8 @@ fn native_cross_compilation_to_macos() { // Collect all tasks // const all_tasks = { - // tcc tasks 'build_v_with_prealloc': Task{build_v_with_prealloc, 'Build V with prealloc'} + // tcc tasks 'all_code_is_formatted_tcc': Task{all_code_is_formatted, 'All code is formatted (tcc)'} 'install_dependencies_for_examples_and_tools_tcc': Task{install_dependencies_for_examples_and_tools_tcc, 'Install deps for examples/tools (tcc)'} 'test_v_to_c_tcc': Task{test_v_to_c_tcc, 'Test v->c with tcc'} diff --git a/ci/macos_ci.vsh b/ci/macos_ci.vsh index 3944accc69..da9b1916d5 100644 --- a/ci/macos_ci.vsh +++ b/ci/macos_ci.vsh @@ -87,9 +87,20 @@ fn v_doctor() { exec('v doctor') } +fn build_v_with_prealloc() { + exec('v -cg -cstrict -o vstrict1 cmd/v') + exec('./vstrict1 -d debug_malloc -d debug_realloc -o vdebug1 cmd/v') + exec('./vstrict1 -o vprealloc -prealloc cmd/v') + // TODO: fix prealloc on macos (the rwmutex implementation for shared maps there seems to require that mutexes are allocated by C.malloc directly, and segfaults for arbitrary memory addresses) + // exec('./vprealloc run examples/hello_world.v') + // exec('./vprealloc -o v3 cmd/v') + // exec('./v3 -o v4 cmd/v') +} + fn v_self_compilation_usecache() { exec('unset VFLAGS') - exec('v -usecache examples/hello_world.v && examples/hello_world') + exec('v -usecache examples/hello_world.v') + exec('./examples/hello_world') exec('v -o v2 -usecache cmd/v') exec('./v2 -o v3 -usecache cmd/v') exec('./v3 version') @@ -128,6 +139,7 @@ const all_tasks = { 'build_examples_prod': Task{build_examples_prod, 'Build examples with -prod'} 'build_examples_v_compiled_with_tcc': Task{build_examples_v_compiled_with_tcc, 'Build examples with V build with tcc'} 'v_doctor': Task{v_doctor, 'v doctor'} + 'build_v_with_prealloc': Task{build_v_with_prealloc, 'Build V with prealloc'} 'v_self_compilation_usecache': Task{v_self_compilation_usecache, 'V self compilation with -usecache'} 'v_self_compilation_parallel_cc': Task{v_self_compilation_parallel_cc, 'V self compilation with -parallel-cc'} 'test_password_input': Task{test_password_input, 'Test password input'}