1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

fix building v on alpine with musl libc

This commit is contained in:
Delyan Angelov 2019-08-28 19:26:18 +03:00 committed by Alexander Medvednikov
parent fed9f01b2d
commit c92654a044
2 changed files with 12 additions and 5 deletions

View File

@ -23,6 +23,8 @@ CommonCHeaders = '
#ifdef __linux__
#include <execinfo.h> // backtrace and backtrace_symbols_fd
#pragma weak backtrace
#pragma weak backtrace_symbols_fd
#endif
#ifdef __linux__

View File

@ -19,16 +19,21 @@ fn on_panic(f fn (int) int) {
pub fn print_backtrace_skipping_top_frames(skipframes int) {
$if mac {
buffer := [100]voidptr
buffer := [100]byteptr
nr_ptrs := C.backtrace(buffer, 100)
C.backtrace_symbols_fd(&buffer[skipframes], nr_ptrs-skipframes, 1)
return
}
$if linux {
buffer := [100]voidptr
nr_ptrs := C.backtrace(buffer, 100)
C.backtrace_symbols_fd(&buffer[skipframes], nr_ptrs-skipframes, 1)
return
if C.backtrace_symbols_fd != 0 {
buffer := [100]byteptr
nr_ptrs := C.backtrace(buffer, 100)
C.backtrace_symbols_fd(&buffer[skipframes], nr_ptrs-skipframes, 1)
return
}else{
C.printf('backtrace_symbols_fd is missing, so printing backtraces is not available.\n')
C.printf('Some libc implementations like musl simply do not provide it.\n')
}
}
C.printf('print_backtrace_skipping_top_frames is not implemented on this platform for now...\n')
}