diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c90f8d7ce0..1ab8f1bb5b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -102,6 +102,45 @@ jobs: run: | ./v tutorials/building_a_simple_web_blog_with_vweb/code/blog + ubuntu-tcc-boehm-gc: + runs-on: ubuntu-20.04 + timeout-minutes: 30 + env: + VFLAGS: -cc tcc -no-retry-compilation + steps: + - uses: actions/checkout@v2 + - name: Install dependencies + run: | + sudo rm -f /etc/apt/sources.list.d/dotnetdev.list /etc/apt/sources.list.d/microsoft-prod.list; sudo apt-get update; + sudo apt-get install --quiet -y libssl-dev sqlite3 libsqlite3-dev valgrind + sudo apt-get install --quiet -y libglfw3 libglfw3-dev libfreetype6-dev libxi-dev libxcursor-dev libasound2-dev + sudo apt-get install --quiet -y libgc-dev + ## sudo apt-get install --quiet -y libsdl2-dev libsdl2-ttf-dev libsdl2-mixer-dev libsdl2-image-dev + ## The following is needed for examples/wkhtmltopdf.v + wget https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6-1/wkhtmltox_0.12.6-1.focal_amd64.deb + sudo apt-get install xfonts-75dpi xfonts-base + sudo dpkg -i wkhtmltox_0.12.6-1.focal_amd64.deb + - name: Build v + run: | + echo $VFLAGS + make + - name: Test v->c + run: | + thirdparty/tcc/tcc.exe -version + ./v -cg -o v cmd/v # Make sure vtcc can build itself twice + - name: v self compilation with -gc boehm + run: ./v -gc boehm -o v2 cmd/v && ./v2 -gc boehm -o v3 cmd/v && ./v3 -gc boehm -o v4 cmd/v + - name: v doctor + run: | + ./v doctor + - name: Verify `v -gc boehm test` works + run: | + ./v -gc boehm cmd/tools/test_if_v_test_system_works.v + ./cmd/tools/test_if_v_test_system_works + - name: Self tests with `-gc boehm` + ## The test cases are run with non-gc `v` for now + run: ./v -gc boehm -silent test-self + misc-tooling: runs-on: ubuntu-20.04 timeout-minutes: 30 diff --git a/vlib/builtin/map.v b/vlib/builtin/map.v index 6acbd49484..0763c8f2aa 100644 --- a/vlib/builtin/map.v +++ b/vlib/builtin/map.v @@ -108,7 +108,11 @@ mut: [inline] fn new_dense_array(key_bytes int, value_bytes int) DenseArray { - slot_bytes := key_bytes + value_bytes + mut slot_bytes := key_bytes + value_bytes + $if gcboehm ? { + align, mask := $if x64 { 7, int(0xfffffff8) } $else { 3, int(0xfffffffc) } + slot_bytes = (slot_bytes + align) & mask + } cap := 8 return DenseArray{ key_bytes: key_bytes diff --git a/vlib/v/gen/c/cmain.v b/vlib/v/gen/c/cmain.v index 21e335ecda..61391e05ea 100644 --- a/vlib/v/gen/c/cmain.v +++ b/vlib/v/gen/c/cmain.v @@ -67,6 +67,11 @@ fn (mut g Gen) gen_c_main_function_header() { fn (mut g Gen) gen_c_main_header() { g.gen_c_main_function_header() + if g.pref.gc_mode == .boehm { + g.writeln('#if defined(_VGCBOEHM)') + g.writeln('\tGC_INIT();') + g.writeln('#endif') + } g.writeln('\t_vinit(___argc, (voidptr)___argv);') if g.pref.is_prof { g.writeln('') @@ -150,6 +155,11 @@ pub fn (mut g Gen) gen_c_main_for_tests() { main_fn_start_pos := g.out.len g.writeln('') g.gen_c_main_function_header() + if g.pref.gc_mode == .boehm { + g.writeln('#if defined(_VGCBOEHM)') + g.writeln('\tGC_INIT();') + g.writeln('#endif') + } g.writeln('\t_vinit(___argc, (voidptr)___argv);') all_tfuncs := g.get_all_test_function_names() if g.pref.is_stats {