From 1801798a416a1d83316ec43a5d0102cc21a6d3a9 Mon Sep 17 00:00:00 2001 From: Crying Nights Date: Mon, 18 May 2026 16:36:09 +0800 Subject: [PATCH] builtin,cgen: address Windows compilation errors when using tcc toolchains (#27186) --- CHANGELOG.md | 4 ++-- changelogs0.x/0.5.md | 2 +- vlib/builtin/backtraces_windows.c.v | 9 ++++++--- vlib/v/gen/c/cheaders.v | 2 +- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 943d2b899..a50b66543 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2181,7 +2181,7 @@ - runtime: add free_memory/0 implementation for OpenBSD (fix #23579) (#23583) - Fix `v doctor` output on OpenBSD: get gcc version from egcc; do not run ldd to get the glibc version (fix #23576) (#23578) -- make.bat: add note about antivirus programs on windows and compilation slowdowns (#23586) +- makev.bat: add note about antivirus programs on windows and compilation slowdowns (#23586) - runtime: add free_memory/0 implementation for FreeBSD too (fix #23581) (#23594) - log,sync: fix macos CI failure when log.ThreadSafeLog is used explicitly in `v download` (#23613) - Let `v test .` show the running _test.v files each minute (set by @@ -5254,7 +5254,7 @@ Final steps in making the Option type a first class type: - New official IntelliJ plugin: https://intellij-v.github.io. - Lots of new language documentation, a nicer table of contents. - Improved documentation for most of the vlib modules -- `make.bat` & `v up` improvements on Windows. +- `makev.bat` & `v up` improvements on Windows. - TeamCity test runner support via `v -test-runner teamcity foo_test.v`. - CI optimizations for faster runs. - New official AdventOfCode repo with AOC solutions, also added to CI. diff --git a/changelogs0.x/0.5.md b/changelogs0.x/0.5.md index 5a3e68ebe..bf23a0e01 100644 --- a/changelogs0.x/0.5.md +++ b/changelogs0.x/0.5.md @@ -3663,7 +3663,7 @@ - runtime: add free_memory/0 implementation for OpenBSD (fix #23579) (#23583) - Fix `v doctor` output on OpenBSD: get gcc version from egcc; do not run ldd to get the glibc version (fix #23576) (#23578) -- make.bat: add note about antivirus programs on windows and compilation slowdowns (#23586) +- makev.bat: add note about antivirus programs on windows and compilation slowdowns (#23586) - runtime: add free_memory/0 implementation for FreeBSD too (fix #23581) (#23594) - log,sync: fix macos CI failure when log.ThreadSafeLog is used explicitly in `v download` (#23613) - Let `v test .` show the running _test.v files each minute (set by diff --git a/vlib/builtin/backtraces_windows.c.v b/vlib/builtin/backtraces_windows.c.v index e833c6856..7a81a7772 100644 --- a/vlib/builtin/backtraces_windows.c.v +++ b/vlib/builtin/backtraces_windows.c.v @@ -48,9 +48,12 @@ fn C.SymInitialize(h_process voidptr, p_user_search_path &u8, b_invade_process i fn C.CaptureStackBackTrace(frames_to_skip u32, frames_to_capture u32, p_backtrace voidptr, p_backtrace_hash voidptr) u16 -fn C.SymFromAddr(h_process voidptr, address u64, p_displacement voidptr, p_symbol voidptr) i32 - -fn C.SymGetLineFromAddr64(h_process voidptr, address u64, p_displacement voidptr, p_line &Line64) i32 +$if windows { + $if msvc { + fn C.SymFromAddr(h_process voidptr, address u64, p_displacement voidptr, p_symbol voidptr) i32 + fn C.SymGetLineFromAddr64(h_process voidptr, address u64, p_displacement voidptr, p_line &Line64) i32 + } +} // Ref - https://docs.microsoft.com/en-us/windows/win32/api/dbghelp/nf-dbghelp-symsetoptions const symopt_undname = 0x00000002 diff --git a/vlib/v/gen/c/cheaders.v b/vlib/v/gen/c/cheaders.v index 0260e8c3e..5df3e94c6 100644 --- a/vlib/v/gen/c/cheaders.v +++ b/vlib/v/gen/c/cheaders.v @@ -174,7 +174,7 @@ const c_common_macros = ' #define __NOINLINE #define __IRQHANDLER // #include - int tcc_backtrace(const char *fmt, ...); + // int tcc_backtrace(const char *fmt, ...); #endif // Use __offsetof_ptr instead of __offset_of, when you *do* have a valid pointer, to avoid UB: #ifndef __offsetof_ptr -- 2.39.5