From ba60fc20382bc75dcb22e8e9db12bb32e45afc56 Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Sun, 17 May 2026 10:24:39 +0300 Subject: [PATCH] ci: enable vtcc test on macOS, fix C codegen for clang compatibility - auto_eq_methods: emit `#define X_struct_eq(a,b) (false)` for opaque C structs (fixes FILE passed by value with clang) - fn.v: skip emitting `typedef struct va_list va_list` (conflicts with cheaders' `__builtin_va_list` definition) - compile_v_with_vtcc.sh: early exit on macOS after verifying vtcc builds (TCC cannot target ARM64) - CI workflow: remove Linux-only condition from vtcc test step --- .github/workflows/compile_v_with_vtcc.sh | 6 ++++++ .github/workflows/v_apps_and_modules_compile_ci.yml | 1 - vlib/v/gen/c/auto_eq_methods.v | 4 ++++ vlib/v/gen/c/fn.v | 4 +++- 4 files changed, 13 insertions(+), 2 deletions(-) diff --git a/.github/workflows/compile_v_with_vtcc.sh b/.github/workflows/compile_v_with_vtcc.sh index 28b1b4682..16b6c62d1 100755 --- a/.github/workflows/compile_v_with_vtcc.sh +++ b/.github/workflows/compile_v_with_vtcc.sh @@ -21,6 +21,12 @@ cd .. ls -la vtcc/vtcc ./vtcc/vtcc --version +if [[ "$(uname)" == "Darwin" ]]; then + show "macOS: vtcc built successfully (TCC cannot target ARM64, skipping full test)" + rm -rf vtcc/ + exit 0 +fi + show "Generate the C file, for the current V version" ./v -o vlang.c cmd/v ls -la vlang.c diff --git a/.github/workflows/v_apps_and_modules_compile_ci.yml b/.github/workflows/v_apps_and_modules_compile_ci.yml index 0733903b4..bd9e745cf 100644 --- a/.github/workflows/v_apps_and_modules_compile_ci.yml +++ b/.github/workflows/v_apps_and_modules_compile_ci.yml @@ -70,7 +70,6 @@ jobs: v . - name: Test vtcc - if: runner.os == 'Linux' || runner.os == 'macOS' run: .github/workflows/compile_v_with_vtcc.sh - name: Test vsql compilation and examples diff --git a/vlib/v/gen/c/auto_eq_methods.v b/vlib/v/gen/c/auto_eq_methods.v index 228dc866c..1c779bc03 100644 --- a/vlib/v/gen/c/auto_eq_methods.v +++ b/vlib/v/gen/c/auto_eq_methods.v @@ -198,6 +198,10 @@ fn (mut g Gen) gen_struct_equality_fn(left_type ast.Type) string { g.generated_eq_fns << left_no_ptr info := left.sym.struct_info() + if left.sym.language == .c && info.fields.len == 0 { + g.definitions.writeln('#define ${fn_name}_struct_eq(a, b) (false)') + return fn_name + } g.definitions.writeln('${g.static_non_parallel}bool ${fn_name}_struct_eq(${ptr_styp} a, ${ptr_styp} b);') mut fn_builder := strings.new_builder(512) diff --git a/vlib/v/gen/c/fn.v b/vlib/v/gen/c/fn.v index a8df04000..2fb9858eb 100644 --- a/vlib/v/gen/c/fn.v +++ b/vlib/v/gen/c/fn.v @@ -942,7 +942,9 @@ fn (mut g Gen) ensure_c_extern_signature_type_decl(typ_ ast.Type) { ast.Struct { if sym.language == .c && sym.cname.starts_with('C__') && !sym.info.is_anon { c_struct_name := sym.cname[3..] - if sym.info.is_typedef { + if c_struct_name == 'va_list' { + // skip: already defined via __builtin_va_list in cheaders + } else if sym.info.is_typedef { g.typedefs.writeln('typedef struct ${c_struct_name} ${c_struct_name};') } else { g.typedefs.writeln('struct ${c_struct_name};') -- 2.39.5