Hello!
I'm currently using TCC for testing and experimenting because it's
blazing fast (amazing work, by the way), and some libraries depend on
GNU C features which are actually implemented in the `mob` branch, but
the libraries only check for GCC and Clang, so I would like to send a
few patches that would make them check for TCC > 0.9.27 too.
The problem is, as far as I know, there is currently no way to detect
a build from the `mob` branch, and using `__TINYC__` wouldn't an
option since it doesn't change anymore.
I made a small patch that defines `__TINYC_MOB__` as the number of
commits since 0.9.27, and could be used like the following:
/* Detect support for the cleanup attribute */
#if defined(__GNUC__) || defined(__clang__) ||
defined(__TINYC_MOB__) && __TINYC_MOB__ >= 68
/* ... */
I wonder if there is a better way to do this, and if it would be OK to
add something like this?
Thanks,
Álvaro.
diff --git a/Makefile b/Makefile
index fca50dd..5cbb13d 100644
--- a/Makefile
+++ b/Makefile
@@ -180,6 +180,14 @@ DEF-win += -DCONFIG_TCCDIR="\"$(tccdir)/win32\""
endif
endif
+GITHASH := $(shell git rev-parse >/dev/null 2>&1 && git rev-parse --short HEAD || echo no)
+GITCOUNT := $(shell git rev-list --count release_0_9_27..HEAD || echo -1)
+
+DEF_GITINFO := -DTCC_MOB="$(GITCOUNT)"
+ifneq ($(GITHASH),no)
+DEF_GITINFO += -DTCC_GITHASH="\"$(GITHASH)$(shell git diff --quiet || echo '-mod')\""
+endif
+
# include custom configuration (see make help)
-include config-extra.mak
@@ -222,11 +230,6 @@ $(TCC_FILES) : DEFINES += -DONE_SOURCE=0
$(X)tccpp.o : $(TCCDEFS_H)
endif
-GITHASH := $(shell git rev-parse >/dev/null 2>&1 && git rev-parse --short HEAD || echo no)
-ifneq ($(GITHASH),no)
-DEF_GITHASH := -DTCC_GITHASH="\"$(GITHASH)$(shell git diff --quiet || echo '-mod')\""
-endif
-
ifeq ($(CONFIG_debug),yes)
CFLAGS += -g
LDFLAGS += -g
@@ -246,7 +249,8 @@ $(X)%.o : %.c $(LIBTCC_INC)
# additional dependencies
$(X)tcc.o : tcctools.c
-$(X)tcc.o : DEFINES += $(DEF_GITHASH)
+$(X)tcc.o : DEFINES += $(DEF_GITINFO)
+$(X)tccpp.o : DEFINES += $(DEF_GITINFO)
# Host Tiny C Compiler
tcc$(EXESUF): tcc.o $(LIBTCC)
diff --git a/tccpp.c b/tccpp.c
index 897ef15..3812843 100644
--- a/tccpp.c
+++ b/tccpp.c
@@ -3712,6 +3712,7 @@ static void tcc_predefs(TCCState *s1, CString *cs, int is_asm)
sscanf(TCC_VERSION, "%d.%d.%d", &a, &b, &c);
cstr_printf(cs, "#define __TINYC__ %d\n", a*10000 + b*100 + c);
+ cstr_printf(cs, "#define __TINYC_MOB__ %d\n", TCC_MOB);
for (a = 0; defs[a]; ++a)
for (p = defs[a]; *p; p = strchr(p, 0) + 1)
putdef(cs, p);
_______________________________________________
Tinycc-devel mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/tinycc-devel