From 106e6ec1141d9a4382a13e40641aadee6313c717 Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Mon, 29 Jun 2026 03:08:00 +0300 Subject: [PATCH] all: fix master ci issues --- vlib/clipboard/x11/clipboard.c.v | 13 ++++----- vlib/db/pg/pg_timestamp_test.v | 1 + vlib/net/http/server_tls_test.v | 25 ++++++++++++++--- vlib/sokol/sapp/sapp_linux.c.v | 5 ++-- vlib/strings/builder.c.v | 4 +-- vlib/strings/builder.js.v | 4 +-- vlib/v/gen/c/coutput_test.v | 6 +++++ vlib/v/gen/c/link_generated_c_files_test.v | 4 +-- vlib/v/gen/c/str.v | 10 +++++++ vlib/v/gen/c/utils.v | 27 ++++++++++++------- vlib/v/pref/default.v | 14 ++++++++++ vlib/v/pref/default_tcc_compiler_test.v | 25 +++++++++++++++++ .../string_interpolation_test.v | 6 +++++ 13 files changed, 118 insertions(+), 26 deletions(-) diff --git a/vlib/clipboard/x11/clipboard.c.v b/vlib/clipboard/x11/clipboard.c.v index ac7f5333a..9ae4ce859 100644 --- a/vlib/clipboard/x11/clipboard.c.v +++ b/vlib/clipboard/x11/clipboard.c.v @@ -30,6 +30,7 @@ pub mut: // Local type aliases for convenience type Window = u64 type Atom = u64 +type Time = u64 // Forward declarations for V type checking (actual types from X11 headers) @[typedef] @@ -79,7 +80,7 @@ fn C.XDestroyWindow(d &C.Display, w Window) fn C.XNextEvent(d &C.Display, e &C.XEvent) -fn C.XSetSelectionOwner(d &C.Display, a Atom, w Window, time i32) +fn C.XSetSelectionOwner(d &C.Display, a Atom, w Window, time Time) fn C.XGetSelectionOwner(d &C.Display, a Atom) Window @@ -95,7 +96,7 @@ fn C.XCreateSimpleWindow(d &C.Display, root Window, x i32, y i32, width u32, hei fn C.XOpenDisplay(name &u8) &C.Display -fn C.XConvertSelection(d &C.Display, selection Atom, target Atom, property Atom, requestor Window, time i32) i32 +fn C.XConvertSelection(d &C.Display, selection Atom, target Atom, property Atom, requestor Window, time Time) i32 fn C.XSync(d &C.Display, discard i32) i32 @@ -240,7 +241,7 @@ pub fn (mut cb Clipboard) free() { // clear clears the clipboard (sets it to an empty string). pub fn (mut cb Clipboard) clear() { cb.mutex.lock() - C.XSetSelectionOwner(cb.display, cb.selection, Window(0), C.CurrentTime) + C.XSetSelectionOwner(cb.display, cb.selection, Window(0), Time(C.CurrentTime)) C.XFlush(cb.display) cb.is_owner = false cb.text = '' @@ -253,7 +254,7 @@ pub fn (cb &Clipboard) has_ownership() bool { } fn (cb &Clipboard) take_ownership() { - C.XSetSelectionOwner(cb.display, cb.selection, cb.window, C.CurrentTime) + C.XSetSelectionOwner(cb.display, cb.selection, cb.window, Time(C.CurrentTime)) C.XFlush(cb.display) } @@ -285,7 +286,7 @@ pub fn (mut cb Clipboard) get_text() string { // Request a list of possible conversions, if we're pasting. C.XConvertSelection(cb.display, cb.selection, cb.get_atom(.targets), cb.selection, cb.window, - C.CurrentTime) + Time(C.CurrentTime)) // wait for the text to arrive mut retries := 5 @@ -381,7 +382,7 @@ fn (mut cb Clipboard) start_listener() { to_be_requested = cb.pick_target(prop) if to_be_requested != Atom(0) { C.XConvertSelection(cb.display, cb.selection, to_be_requested, - cb.selection, cb.window, C.CurrentTime) + cb.selection, cb.window, Time(C.CurrentTime)) } } else if event.xselection.target == to_be_requested { sent_request = false diff --git a/vlib/db/pg/pg_timestamp_test.v b/vlib/db/pg/pg_timestamp_test.v index d695714c0..6b5128940 100644 --- a/vlib/db/pg/pg_timestamp_test.v +++ b/vlib/db/pg/pg_timestamp_test.v @@ -1,3 +1,4 @@ +// vtest build: !windows && !musl? module pg import orm diff --git a/vlib/net/http/server_tls_test.v b/vlib/net/http/server_tls_test.v index c489ced72..739c4262c 100644 --- a/vlib/net/http/server_tls_test.v +++ b/vlib/net/http/server_tls_test.v @@ -398,13 +398,32 @@ fn test_server_tls_close_interrupts_idle_keep_alive() { return } mut buf := []u8{len: 4096} - n := client.read(mut buf) or { + mut response_bytes := []u8{cap: 4096} + mut last_read_err := '' + read_sw := time.new_stopwatch() + for read_sw.elapsed() < 2 * time.second { + n := client.read(mut buf) or { + last_read_err = err.msg() + time.sleep(20 * time.millisecond) + continue + } + if n <= 0 { + time.sleep(20 * time.millisecond) + continue + } + response_bytes << buf[..n] + response_so_far := response_bytes.bytestr() + if response_so_far.contains('\r\n\r\n') && response_so_far.contains('tls hello /idle') { + break + } + } + if response_bytes.len == 0 { srv.close() t.wait() - assert false, 'ssl read failed: ${err}' + assert false, 'ssl read failed: ${last_read_err}' return } - response := buf[..n].bytestr() + response := response_bytes.bytestr() assert response.to_lower().contains('connection: keep-alive') assert response.contains('tls hello /idle') diff --git a/vlib/sokol/sapp/sapp_linux.c.v b/vlib/sokol/sapp/sapp_linux.c.v index f4b2ed7a6..0022bf08b 100644 --- a/vlib/sokol/sapp/sapp_linux.c.v +++ b/vlib/sokol/sapp/sapp_linux.c.v @@ -462,8 +462,9 @@ const map_private = 2 #include // X11 C typedefs are unsigned long based. Define them locally so V1 can -// type-check scalar operations while keeping the public aliases C-backed. -pub type C.XID = usize +// type-check scalar operations while keeping the public aliases compatible +// with the shared x11 modules. +pub type C.XID = u64 pub type C.Atom = C.XID pub type C.Window = C.XID pub type C.Colormap = C.XID diff --git a/vlib/strings/builder.c.v b/vlib/strings/builder.c.v index 7e21bd153..594d270a9 100644 --- a/vlib/strings/builder.c.v +++ b/vlib/strings/builder.c.v @@ -71,8 +71,8 @@ pub fn (mut b Builder) write_byte(data u8) { b << data } -// write_decimal appends a decimal representation of the number `n` into the builder `b`, -// without dynamic allocation. The higher order digits come first, i.e. 6123 will be written +// write_decimal appends a decimal representation of `n` without dynamic allocation. +// The higher order digits come first, i.e. 6123 will be written // with the digit `6` first, then `1`, then `2` and `3` last. pub fn (mut b Builder) write_decimal(n i64) { if n == 0 { diff --git a/vlib/strings/builder.js.v b/vlib/strings/builder.js.v index 8134b51ef..3a287d57f 100644 --- a/vlib/strings/builder.js.v +++ b/vlib/strings/builder.js.v @@ -46,8 +46,8 @@ pub fn (mut b Builder) write_decimal(n i64) { b.write_u_decimal(mag) } -// write_u_decimal appends a decimal representation of the unsigned number `n` into the -// builder `b`. Unlike `write_decimal`, it covers the entire `u64` range (values above +// write_u_decimal appends a decimal representation of unsigned `n` to the builder. +// Unlike `write_decimal`, it covers the entire `u64` range (values above // `max_i64`). The higher order digits come first. pub fn (mut b Builder) write_u_decimal(n u64) { if n == 0 { diff --git a/vlib/v/gen/c/coutput_test.v b/vlib/v/gen/c/coutput_test.v index 9faa2436d..70a305798 100644 --- a/vlib/v/gen/c/coutput_test.v +++ b/vlib/v/gen/c/coutput_test.v @@ -670,6 +670,12 @@ fn generated_c_symbol_with_prefix(output string, prefix string) string { } fn test_auxiliary_c_symbols_use_stable_type_hashes() { + $if windows { + $if tinyc { + eprintln('> skipping ${@FN} on windows-tcc, since deep GC scope pins (and thus their keepalive helpers) are intentionally not emitted there: the bundled Windows tcc libgc archive lacks GC_remove_roots()') + return + } + } os.chdir(vroot) or {} test_dir := os.join_path(os.vtmp_dir(), 'coutput_stable_type_symbol_hash_${os.getpid()}') dir_a := os.join_path(test_dir, 'a') diff --git a/vlib/v/gen/c/link_generated_c_files_test.v b/vlib/v/gen/c/link_generated_c_files_test.v index 90c297fb0..0742b07cc 100644 --- a/vlib/v/gen/c/link_generated_c_files_test.v +++ b/vlib/v/gen/c/link_generated_c_files_test.v @@ -43,8 +43,8 @@ int main(void) { } ')! for cmd in [ - '${test_vexe} -gc none -no-skip-unused -is_o -o ${os.quoted_path(a_c)} ${os.quoted_path(a_v)}', - '${test_vexe} -gc none -no-skip-unused -is_o -o ${os.quoted_path(b_c)} ${os.quoted_path(b_v)}', + '${test_vexe} -cc ${cc} -gc none -no-skip-unused -is_o -o ${os.quoted_path(a_c)} ${os.quoted_path(a_v)}', + '${test_vexe} -cc ${cc} -gc none -no-skip-unused -is_o -o ${os.quoted_path(b_c)} ${os.quoted_path(b_v)}', '${cc} -o ${os.quoted_path(prog)} ${os.quoted_path(a_c)} ${os.quoted_path(b_c)} ${os.quoted_path(host_c)} -lm', ] { res := os.execute(cmd) diff --git a/vlib/v/gen/c/str.v b/vlib/v/gen/c/str.v index cfa37a868..8ea1308f6 100644 --- a/vlib/v/gen/c/str.v +++ b/vlib/v/gen/c/str.v @@ -38,6 +38,12 @@ fn (mut g Gen) string_inter_literal_sb_optimized(call_expr ast.CallExpr) { g.expr(call_expr.left) g.write(', ') typ := node.expr_types[i] + if typ == ast.float_literal_type { + g.write('builtin__f64_str((f64)(') + g.expr(node.exprs[i]) + g.writeln('));') + continue + } g.write2(g.styp(typ), '_str(') sym := g.table.sym(typ) if sym.kind != .function { @@ -180,6 +186,10 @@ fn (mut g Gen) gen_expr_to_string(expr ast.Expr, etype ast.Type) { g.write('${str_fn_name}(') g.expr(expr) g.write(')') + } else if typ == ast.float_literal_type { + g.write('builtin__f64_str((f64)(') + g.expr(expr) + g.write('))') } else if typ == ast.string_type { if expr_type.is_ptr() { g.write('*') diff --git a/vlib/v/gen/c/utils.v b/vlib/v/gen/c/utils.v index 079e529f8..e3c0e0b65 100644 --- a/vlib/v/gen/c/utils.v +++ b/vlib/v/gen/c/utils.v @@ -30,14 +30,8 @@ fn (mut g Gen) stable_type_symbol_key(typ ast.Type, mut seen map[string]bool) st return '0' } sym := g.table.final_sym(resolved_typ) - type_name := g.table.type_to_str(resolved_typ) - styp := g.styp(resolved_typ) flags := stable_type_symbol_flags(resolved_typ) - base := '${sym.kind}:${type_name}:${styp}:${flags}' - if resolved_typ.nr_muls() > 0 || resolved_typ.is_any_kind_of_pointer() - || resolved_typ.has_option_or_result() { - return base - } + base := '${sym.kind}:${stable_type_symbol_nominal_name(sym)}:${flags}' if seen[base] { return 'recursive:${base}' } @@ -66,8 +60,8 @@ fn (mut g Gen) stable_type_symbol_key(typ ast.Type, mut seen map[string]bool) st } } ast.GenericInst { - parent_name := g.table.type_to_str(ast.new_type(sym.info.parent_idx)) - parts << 'generic_inst:${parent_name}' + parent_sym := g.table.sym(ast.new_type(sym.info.parent_idx)) + parts << 'generic_inst:${parent_sym.kind}:${stable_type_symbol_nominal_name(parent_sym)}' for concrete_type in sym.info.concrete_types { parts << g.stable_type_symbol_key(concrete_type, mut seen) } @@ -119,6 +113,21 @@ fn (mut g Gen) stable_type_symbol_key(typ ast.Type, mut seen map[string]bool) st return parts.join('|') } +// stable_type_symbol_nominal_name serializes source-level identity for named types. +fn stable_type_symbol_nominal_name(sym &ast.TypeSymbol) string { + if sym.name.starts_with('_VAnonStruct') || sym.name.starts_with('_VAnonUnion') { + return '' + } + return match sym.kind { + .alias, .enum, .interface, .struct, .sum_type, .aggregate { + '${sym.language}:${sym.mod}:${sym.name}' + } + else { + '' + } + } +} + // stable_type_symbol_flags serializes the type flags that affect generated helper identity. fn stable_type_symbol_flags(typ ast.Type) string { mut flags := []string{cap: 8} diff --git a/vlib/v/pref/default.v b/vlib/v/pref/default.v index df9585962..0373f0d3e 100644 --- a/vlib/v/pref/default.v +++ b/vlib/v/pref/default.v @@ -455,6 +455,14 @@ fn (mut p Preferences) find_cc_if_cross_compiling() { p.ccompiler = p.vcross_compiler_name() } +fn (p &Preferences) macos_default_tcc_output_needs_system_cc() bool { + if get_host_os() != .macos { + return false + } + return p.vroot.contains(' ') || p.vroot.contains('\t') || p.out_name.contains(' ') + || p.out_name.contains('\t') +} + fn (mut p Preferences) try_to_use_tcc_by_default() { preferred_tcc := default_tcc_compiler() if p.ccompiler == 'tcc' { @@ -477,6 +485,12 @@ fn (mut p Preferences) try_to_use_tcc_by_default() { if p.is_prod { return } + // The macOS bundled tcc invokes codesign for the produced executable. + // It does not quote that output path internally, so use the platform cc + // by default when the output path needs quoting. + if p.macos_default_tcc_output_needs_system_cc() { + return + } p.ccompiler = preferred_tcc return } diff --git a/vlib/v/pref/default_tcc_compiler_test.v b/vlib/v/pref/default_tcc_compiler_test.v index e74aeb18f..38f6105e8 100644 --- a/vlib/v/pref/default_tcc_compiler_test.v +++ b/vlib/v/pref/default_tcc_compiler_test.v @@ -134,6 +134,31 @@ fn test_try_to_use_tcc_by_default_skips_tcc_for_prealloc() { assert prefs.ccompiler == '' } +fn test_try_to_use_tcc_by_default_skips_bundled_tcc_for_macos_space_output() { + $if !macos { + return + } + test_root := os.join_path(os.vtmp_dir(), 'v pref default tcc compiler test') + prepare_test_tcc_binary(test_root, 'exit 0') + fake_vexe := os.join_path(test_root, 'v') + old_vexe := os.getenv('VEXE') + os.setenv('VEXE', fake_vexe, true) + defer { + if old_vexe == '' { + os.unsetenv('VEXE') + } else { + os.setenv('VEXE', old_vexe, true) + } + os.rmdir_all(test_root) or {} + } + mut prefs := Preferences{ + vroot: test_root + out_name: os.join_path(test_root, 'v') + } + prefs.try_to_use_tcc_by_default() + assert prefs.ccompiler == '' +} + fn test_usable_system_tcc_compiler_prefers_termux_tcc_from_path() { $if windows { return diff --git a/vlib/v/tests/builtin_strings_and_interpolation/string_interpolation_test.v b/vlib/v/tests/builtin_strings_and_interpolation/string_interpolation_test.v index 487c36abf..5f3ecad68 100644 --- a/vlib/v/tests/builtin_strings_and_interpolation/string_interpolation_test.v +++ b/vlib/v/tests/builtin_strings_and_interpolation/string_interpolation_test.v @@ -296,3 +296,9 @@ fn test_float_exponent_sign() { assert '${a:6.2e}' == '1.23e+09' assert '${a:6.5e}' == '1.23457e+09' } + +const float_literal_zero_for_interpolation = 0.0 + +fn test_const_float_literal_string_interpolation() { + assert '${float_literal_zero_for_interpolation}' == '0.0' +} -- 2.39.5