Disable traceback for Tiny C Compiler since it cannot include <link.h> (#510)

* Disable traceback for Tiny C Compiler since it cannot include <link.h>

* Tiny C Compiler does not have <immintrin.h> header
This commit is contained in:
Anonymous Maarten 2025-12-23 15:43:22 +01:00 committed by GitHub
parent 5292048aef
commit 533518c7dd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 21 additions and 5 deletions

View File

@ -37,7 +37,7 @@ Cutscenes = 0
; "hires" mode is 640x480, otherwise default 320x200
Hires = 1
; Only used in 'demo' mode. Default demo time out is 240s (5 mins)
; Only used in 'demo' mode. Default demo time out is 240s (4 mins)
DemoTimeout = 240
; Which directory in the [Games] section to run

View File

@ -110,6 +110,10 @@ if(DETHRACE_PLATFORM_SDL2)
else()
target_link_libraries(harness PRIVATE SDL2::SDL2)
endif()
if(CMAKE_C_COMPILER_ID MATCHES "TinyCC")
set_property(SOURCE "${CMAKE_CURRENT_SOURCE_DIR}/platforms/sdl2.c" APPEND PROPERTY COMPILE_DEFINITIONS "SDL_DISABLE_IMMINTRIN_H")
endif()
endif()
if(DETHRACE_PLATFORM_SDL3)

View File

@ -1,5 +1,12 @@
// Based on https://gist.github.com/jvranish/4441299
#ifdef __TINYC__
/* tcc does potentially not have __int128_t, used in /usr/include/bits/link.h:99 */
#define SUPPORT_TRACEBACK 0
#else
#define SUPPORT_TRACEBACK 1
#endif
#define _GNU_SOURCE
#include "harness/config.h"
#include "harness/os.h"
@ -9,12 +16,10 @@
#include <dirent.h>
#include <err.h>
#include <errno.h>
#include <execinfo.h>
#include <fcntl.h>
#include <ifaddrs.h>
#include <libgen.h>
#include <limits.h>
#include <link.h>
#include <signal.h>
#include <stdbool.h>
#include <stdint.h>
@ -28,10 +33,13 @@
#include <time.h>
#include <unistd.h>
#if SUPPORT_TRACEBACK
#include <execinfo.h>
#include <link.h>
#endif
#define ARRAY_SIZE(A) (sizeof(A) / sizeof(A[0]))
#define MAX_STACK_FRAMES 64
#define TRACER_PID_STRING "TracerPid:"
static int stack_nbr = 0;
static char _program_name[1024];
@ -44,6 +52,7 @@ struct dl_iterate_callback_data {
intptr_t start;
} dethrace_dl_data;
#if SUPPORT_TRACEBACK
static int dl_iterate_callback(struct dl_phdr_info* info, size_t size, void* data) {
struct dl_iterate_callback_data* callback_data = data;
@ -92,6 +101,7 @@ static void print_stack_trace(void) {
free(messages);
}
}
#endif
static void signal_handler(int sig, siginfo_t* siginfo, void* context) {
(void)context;
@ -176,7 +186,9 @@ static void signal_handler(int sig, siginfo_t* siginfo, void* context) {
break;
}
fputs("******************\n", stderr);
#if SUPPORT_TRACEBACK
print_stack_trace();
#endif
exit(1);
}