From ee7c72bf24ba96746b7e31a975b23d284cbc89e2 Mon Sep 17 00:00:00 2001 From: cloudwalk Date: Sat, 11 Jul 2020 01:51:42 +0000 Subject: [PATCH] Improve clang support. Add tcc support. Clang builds now perform as good as gcc tcc builds perform like crap, but it's nice to support a fourth compiler. There is an issue on Linux with a Pulseaudio library not linking correctly, however. git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@12795 d7cf8633-e32d-0410-b094-e92efae38249 --- crypto.c | 2 +- makefile | 4 +++- makefile.inc | 9 ++++++++- prvm_exec.c | 2 +- qtypes.h | 2 +- quakedef.h | 4 ++-- sys_shared.c | 2 +- 7 files changed, 17 insertions(+), 8 deletions(-) diff --git a/crypto.c b/crypto.c index a6ff7452..4589741a 100644 --- a/crypto.c +++ b/crypto.c @@ -158,7 +158,7 @@ static size_t Crypto_UnParsePack(char *buf, size_t len, unsigned long header, co // d0_blind_id interface #define D0_EXPORT -#ifdef __GNUC__ +#if defined (__GNUC__) || (__clang__) || (__TINYC__) #define D0_WARN_UNUSED_RESULT __attribute__((warn_unused_result)) #else #define D0_WARN_UNUSED_RESULT diff --git a/makefile b/makefile index 621c73e9..973113d1 100644 --- a/makefile +++ b/makefile @@ -308,8 +308,10 @@ endif ##### Extra CFLAGS ##### +ifneq ($(CC), tcc) + CFLAGS_MAKEDEP?=-MMD +endif -CFLAGS_MAKEDEP?=-MMD ifdef DP_FS_BASEDIR CFLAGS_FS=-DDP_FS_BASEDIR=\"$(DP_FS_BASEDIR)\" else diff --git a/makefile.inc b/makefile.inc index f903bef1..0297c489 100644 --- a/makefile.inc +++ b/makefile.inc @@ -190,7 +190,14 @@ ifeq ($(PEDANTIC),1) else CFLAGS_STANDARD= endif -CFLAGS_COMMON=$(CFLAGS_STANDARD) $(CFLAGS_MAKEDEP) $(CFLAGS_PRELOAD) $(CFLAGS_FS) $(CFLAGS_WARNINGS) $(CFLAGS_LIBZ) $(CFLAGS_LIBJPEG) $(CFLAGS_SND_XMP) $(CFLAGS_NET) $(CFLAGS_SDL) -D_FILE_OFFSET_BITS=64 -D__KERNEL_STRICT_NAMES -I../../../ + +CFLAGS_TCC= + +ifeq ($(CC), tcc) + CFLAGS_TCC=-DSDL_DISABLE_IMMINTRIN_H +endif + +CFLAGS_COMMON=$(CFLAGS_STANDARD) $(CFLAGS_TCC) $(CFLAGS_MAKEDEP) $(CFLAGS_PRELOAD) $(CFLAGS_FS) $(CFLAGS_WARNINGS) $(CFLAGS_LIBZ) $(CFLAGS_LIBJPEG) $(CFLAGS_SND_XMP) $(CFLAGS_NET) $(CFLAGS_SDL) -D_FILE_OFFSET_BITS=64 -D__KERNEL_STRICT_NAMES -I../../../ CFLAGS_CLIENT=-DCONFIG_MENU $(CFLAGS_VIDEO_CAPTURE) CFLAGS_SERVER= CFLAGS_DEBUG=-ggdb diff --git a/prvm_exec.c b/prvm_exec.c index c82b9e01..452f2803 100644 --- a/prvm_exec.c +++ b/prvm_exec.c @@ -716,7 +716,7 @@ static void PRVM_StatementCoverageEvent(prvm_prog_t *prog, mfunction_t *func, in Con_Printf("prvm_coverage: %s just executed a statement at %s for the first time. Coverage: %.2f%%.\n", prog->name, PRVM_WhereAmI(vabuf, sizeof(vabuf), prog, func, statement), prog->statements_covered * 100.0 / prog->numstatements); } -#if defined (__GNUC__) || (__clang__) +#if defined (__GNUC__) || (__clang__) || (__TINYC__) # ifndef CONFIG_PEDANTIC # define HAVE_COMPUTED_GOTOS 1 # endif diff --git a/qtypes.h b/qtypes.h index e385e286..7bbc212d 100644 --- a/qtypes.h +++ b/qtypes.h @@ -21,7 +21,7 @@ typedef bool qboolean; // fall over #define ROLL 2 -#if defined(__GNUC__) || (defined(_MSC_VER) && _MSC_VER >= 1400) +#if defined(__GNUC__) || (__clang__) || (__TINYC__) || (_MSC_VER >= 1400) #define RESTRICT __restrict #else #define RESTRICT diff --git a/quakedef.h b/quakedef.h index 107ccc7a..da267345 100644 --- a/quakedef.h +++ b/quakedef.h @@ -26,7 +26,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # include #endif -#if defined(__GNUC__) && (__GNUC__ > 2) +#if (__GNUC__ > 2) || defined (__clang__) || (__TINYC__) #define DP_FUNC_PRINTF(n) __attribute__ ((format (printf, n, n+1))) #define DP_FUNC_PURE __attribute__ ((pure)) #define DP_FUNC_NORETURN __attribute__ ((noreturn)) @@ -471,7 +471,7 @@ extern cvar_t sessionid; # define DP_OS_STR "unknown" #endif -#if defined(__GNUC__) +#if defined(__GNUC__) || (__clang__) # if defined(__i386__) # define DP_ARCH_STR "686" # define SSE_POSSIBLE diff --git a/sys_shared.c b/sys_shared.c index d6081605..81e25e00 100644 --- a/sys_shared.c +++ b/sys_shared.c @@ -534,7 +534,7 @@ void Sys_ProvideSelfFD(void) static int CPUID_Features(void) { int features = 0; -# if defined(__GNUC__) && defined(__i386__) +# if defined((__GNUC__) || (__clang__) || (__TINYC__)) && defined(__i386__) __asm__ ( " movl %%ebx,%%edi\n" " xorl %%eax,%%eax \n" -- 2.39.2