From 5280293d6b16bbe24dfda76e37f32322fa2874ca Mon Sep 17 00:00:00 2001 From: grischka Date: Thu, 14 Jul 2011 18:45:37 +0200 Subject: [PATCH] make: create native tcc from separate objects This was already possible using make NOTALLINONE=1 and is now the default. To build as previously from one big source, use make ONE_SOURCE=1 Cross compilers are still build from one source because using separate objects requires separate build directories one per platform which currently is not (yet) supported by the makefile. We could probably use gnu-makeish target variables like $(I386_CROSS): OUTDIR=build/i386 $(X64_CROSS): OUTDIR=build/x86-64 and so on ... Also NEED_FLOAT_TYPES for arm-gen is removed. It was about variables that are referenced from outside (libtcc, tccgen). We could declare them in tcc.h (as with reg_classes) or have them twice in arm-gen.c. I chose option 2. --- Makefile | 7 +++---- arm-gen.c | 9 ++++++--- libtcc.c | 3 +-- tcc.c | 6 +++--- tcc.h | 4 ++-- tccpe.c | 2 +- win32/build-tcc.bat | 4 ++-- 7 files changed, 18 insertions(+), 17 deletions(-) diff --git a/Makefile b/Makefile index d1dfbdac..f60f4651 100644 --- a/Makefile +++ b/Makefile @@ -157,7 +157,7 @@ tcc$(EXESUF): tcc.o $(LIBTCC) # Cross Tiny C Compilers %-tcc$(EXESUF): - $(CC) -o $@ tcc.c $(DEFINES) $(CFLAGS) $(LIBS) $(LDFLAGS) + $(CC) -o $@ tcc.c -DONE_SOURCE $(DEFINES) $(CFLAGS) $(LIBS) $(LDFLAGS) $(I386_CROSS): DEFINES = -DTCC_TARGET_I386 -DCONFIG_TCCDIR="\"$(tccdir)/i386\"" $(X64_CROSS): DEFINES = -DTCC_TARGET_X86_64 @@ -179,14 +179,13 @@ $(C67_CROSS): $(C67_FILES) $(ARM_FPA_CROSS) $(ARM_FPA_LD_CROSS) $(ARM_VFP_CROSS) $(ARM_EABI_CROSS): $(ARM_FILES) # libtcc generation and test -ifdef NOTALLINONE +ifndef ONE_SOURCE LIBTCC_OBJ = $(filter-out tcc.o,$(patsubst %.c,%.o,$(filter %.c,$(NATIVE_FILES)))) LIBTCC_INC = $(filter %.h,$(CORE_FILES)) $(filter-out $(CORE_FILES),$(NATIVE_FILES)) -$(LIBTCC_OBJ) tcc.o : NATIVE_DEFINES += -DNOTALLINONE else LIBTCC_OBJ = libtcc.o LIBTCC_INC = $(NATIVE_FILES) -tcc.o : NATIVE_DEFINES += -DNOTALLINONE +$(LIBTCC_OBJ) tcc.o : NATIVE_DEFINES += -DONE_SOURCE endif $(LIBTCC_OBJ) tcc.o : %.o : %.c $(LIBTCC_INC) diff --git a/arm-gen.c b/arm-gen.c index 9feae1b9..5cb5c2ec 100644 --- a/arm-gen.c +++ b/arm-gen.c @@ -102,10 +102,8 @@ enum { //#define FUNC_STRUCT_PARAM_AS_PTR #if defined(TCC_ARM_EABI) && defined(TCC_ARM_VFP) -#ifdef NEED_FLOAT_TYPES -static CType float_type, double_type, func_float_type, func_double_type; +ST_DATA CType float_type, double_type, func_float_type, func_double_type; #define func_ldouble_type func_double_type -#endif #else #define func_float_type func_old_type #define func_double_type func_old_type @@ -172,6 +170,11 @@ ST_DATA const int reg_classes[NB_REGS] = { #endif }; +/* keep in sync with line 104 above */ +#if defined(TCC_ARM_EABI) && defined(TCC_ARM_VFP) +ST_DATA CType float_type, double_type, func_float_type, func_double_type; +#endif + static int func_sub_sp_offset, last_itod_magic; static int leaffunc; diff --git a/libtcc.c b/libtcc.c index 46a13fc9..9fa0dd82 100644 --- a/libtcc.c +++ b/libtcc.c @@ -18,7 +18,6 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#define NEED_FLOAT_TYPES #include "tcc.h" /********************************************************/ @@ -41,7 +40,7 @@ ST_DATA void *rt_prog_main; /********************************************************/ -#ifndef NOTALLINONE +#ifdef ONE_SOURCE #include "tccpp.c" #include "tccgen.c" #include "tccelf.c" diff --git a/tcc.c b/tcc.c index 570a61c6..cab257d6 100644 --- a/tcc.c +++ b/tcc.c @@ -18,10 +18,10 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#if defined NOTALLINONE || defined TCC_USE_LIBTCC -#include "tcc.h" -#else +#ifdef ONE_SOURCE #include "libtcc.c" +#else +#include "tcc.h" #endif static char **files; diff --git a/tcc.h b/tcc.h index ce7ee226..eaf0e65f 100644 --- a/tcc.h +++ b/tcc.h @@ -877,7 +877,7 @@ static inline int toup(int c) #define PUB_FUNC -#ifndef NOTALLINONE +#ifdef ONE_SOURCE #define ST_INLN static inline #define ST_FUNC static #define ST_DATA static @@ -1278,7 +1278,7 @@ ST_DATA const int reg_classes[NB_REGS]; /********************************************************/ #undef ST_DATA -#ifndef NOTALLINONE +#ifdef ONE_SOURCE #define ST_DATA static #else #define ST_DATA diff --git a/tccpe.c b/tccpe.c index ed57c632..22b61a69 100644 --- a/tccpe.c +++ b/tccpe.c @@ -376,7 +376,7 @@ static int pe_find_import(TCCState * s1, ElfW(Sym) *sym) { char buffer[200]; const char *s, *p; - int sym_index, n = 0; + int sym_index = 0, n = 0; do { s = pe_export_name(s1, sym); diff --git a/win32/build-tcc.bat b/win32/build-tcc.bat index 42dc8f67..3b2bb1e1 100644 --- a/win32/build-tcc.bat +++ b/win32/build-tcc.bat @@ -29,11 +29,11 @@ echo>>..\config.h #define CONFIG_SYSROOT "" :libtcc if not exist libtcc\nul mkdir libtcc copy ..\libtcc.h libtcc\libtcc.h -%CC% %target% -fno-strict-aliasing ../libtcc.c -c -o libtcc.o +%CC% %target% -fno-strict-aliasing -DONE_SOURCE ../libtcc.c -c -o libtcc.o %AR% rcs libtcc/libtcc.a libtcc.o :tcc -%CC% %target% -fno-strict-aliasing ../tcc.c -o tcc.exe -DTCC_USE_LIBTCC -ltcc -Llibtcc +%CC% %target% -fno-strict-aliasing ../tcc.c -o tcc.exe -ltcc -Llibtcc :copy_std_includes copy ..\include\*.h include