Skip to content

Commit 940529f

Browse files
committed
review 4
1 parent cf21f06 commit 940529f

2 files changed

Lines changed: 19 additions & 12 deletions

File tree

vlib/builtin/builtin_d_use_libbacktrace.c.v

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ $if openbsd {
1010
@[noinline]
1111
fn eprint_libbacktrace(frames_to_skip int) {
1212
}
13-
} $else {
13+
} $else $if !tinyc {
14+
// full libbacktrace implementation for gcc/clang (TCC can't compile libbacktrace's C code)
1415
#flag -I@VEXEROOT/thirdparty/libbacktrace
1516
#flag @VEXEROOT/thirdparty/libbacktrace/backtrace.o
1617
#include <backtrace.h>
@@ -31,16 +32,13 @@ $if openbsd {
3132
__global bt_state = init_bt_state()
3233

3334
fn init_bt_state() &C.backtrace_state {
34-
$if !tinyc {
35-
mut filename := &char(unsafe { nil })
36-
$if windows {
37-
filename = unsafe { string_from_wide(&&u16(g_main_argv)[0]).str }
38-
} $else {
39-
filename = unsafe { &&char(g_main_argv)[0] }
40-
}
41-
return C.backtrace_create_state(filename, 1, bt_error_handler, 0)
35+
mut filename := &char(unsafe { nil })
36+
$if windows {
37+
filename = unsafe { string_from_wide(&&u16(g_main_argv)[0]).str }
38+
} $else {
39+
filename = unsafe { &&char(g_main_argv)[0] }
4240
}
43-
return &C.backtrace_state(unsafe { nil })
41+
return C.backtrace_create_state(filename, 1, bt_error_handler, 0)
4442
}
4543

4644
// for bt_error_callback
@@ -116,4 +114,13 @@ $if openbsd {
116114
}
117115
C.backtrace_full(bt_state, frames_to_skip, bt_print_callback, bt_error_callback, data)
118116
}
117+
} $else {
118+
// no-op stubs for TCC (TCC can't compile libbacktrace's C code, and
119+
// it has its own built-in backtrace via tcc_backtrace instead)
120+
fn print_libbacktrace(frames_to_skip int) {
121+
}
122+
123+
@[noinline]
124+
fn eprint_libbacktrace(frames_to_skip int) {
125+
}
119126
}

vlib/builtin/panicing.c.v

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ fn panic_debug(line_no int, file string, mod string, fn_name string, s string) {
5050
}
5151
C.exit(1)
5252
} $else {
53-
$if use_libbacktrace ? {
53+
$if use_libbacktrace ? && !tinyc {
5454
$if openbsd {
5555
print_backtrace_skipping_top_frames(1)
5656
} $else {
@@ -121,7 +121,7 @@ pub fn panic(s string) {
121121
}
122122
C.exit(1)
123123
} $else {
124-
$if use_libbacktrace ? {
124+
$if use_libbacktrace ? && !tinyc {
125125
$if openbsd {
126126
print_backtrace_skipping_top_frames(1)
127127
} $else {

0 commit comments

Comments
 (0)