mirror of
https://github.com/frida/tinycc
synced 2024-12-24 22:16:49 +03:00
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.
This commit is contained in:
parent
4ccb5662cb
commit
5280293d6b
7
Makefile
7
Makefile
@ -157,7 +157,7 @@ tcc$(EXESUF): tcc.o $(LIBTCC)
|
|||||||
|
|
||||||
# Cross Tiny C Compilers
|
# Cross Tiny C Compilers
|
||||||
%-tcc$(EXESUF):
|
%-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\""
|
$(I386_CROSS): DEFINES = -DTCC_TARGET_I386 -DCONFIG_TCCDIR="\"$(tccdir)/i386\""
|
||||||
$(X64_CROSS): DEFINES = -DTCC_TARGET_X86_64
|
$(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)
|
$(ARM_FPA_CROSS) $(ARM_FPA_LD_CROSS) $(ARM_VFP_CROSS) $(ARM_EABI_CROSS): $(ARM_FILES)
|
||||||
|
|
||||||
# libtcc generation and test
|
# libtcc generation and test
|
||||||
ifdef NOTALLINONE
|
ifndef ONE_SOURCE
|
||||||
LIBTCC_OBJ = $(filter-out tcc.o,$(patsubst %.c,%.o,$(filter %.c,$(NATIVE_FILES))))
|
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_INC = $(filter %.h,$(CORE_FILES)) $(filter-out $(CORE_FILES),$(NATIVE_FILES))
|
||||||
$(LIBTCC_OBJ) tcc.o : NATIVE_DEFINES += -DNOTALLINONE
|
|
||||||
else
|
else
|
||||||
LIBTCC_OBJ = libtcc.o
|
LIBTCC_OBJ = libtcc.o
|
||||||
LIBTCC_INC = $(NATIVE_FILES)
|
LIBTCC_INC = $(NATIVE_FILES)
|
||||||
tcc.o : NATIVE_DEFINES += -DNOTALLINONE
|
$(LIBTCC_OBJ) tcc.o : NATIVE_DEFINES += -DONE_SOURCE
|
||||||
endif
|
endif
|
||||||
|
|
||||||
$(LIBTCC_OBJ) tcc.o : %.o : %.c $(LIBTCC_INC)
|
$(LIBTCC_OBJ) tcc.o : %.o : %.c $(LIBTCC_INC)
|
||||||
|
@ -102,10 +102,8 @@ enum {
|
|||||||
//#define FUNC_STRUCT_PARAM_AS_PTR
|
//#define FUNC_STRUCT_PARAM_AS_PTR
|
||||||
|
|
||||||
#if defined(TCC_ARM_EABI) && defined(TCC_ARM_VFP)
|
#if defined(TCC_ARM_EABI) && defined(TCC_ARM_VFP)
|
||||||
#ifdef NEED_FLOAT_TYPES
|
ST_DATA CType float_type, double_type, func_float_type, func_double_type;
|
||||||
static CType float_type, double_type, func_float_type, func_double_type;
|
|
||||||
#define func_ldouble_type func_double_type
|
#define func_ldouble_type func_double_type
|
||||||
#endif
|
|
||||||
#else
|
#else
|
||||||
#define func_float_type func_old_type
|
#define func_float_type func_old_type
|
||||||
#define func_double_type func_old_type
|
#define func_double_type func_old_type
|
||||||
@ -172,6 +170,11 @@ ST_DATA const int reg_classes[NB_REGS] = {
|
|||||||
#endif
|
#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 func_sub_sp_offset, last_itod_magic;
|
||||||
static int leaffunc;
|
static int leaffunc;
|
||||||
|
|
||||||
|
3
libtcc.c
3
libtcc.c
@ -18,7 +18,6 @@
|
|||||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define NEED_FLOAT_TYPES
|
|
||||||
#include "tcc.h"
|
#include "tcc.h"
|
||||||
|
|
||||||
/********************************************************/
|
/********************************************************/
|
||||||
@ -41,7 +40,7 @@ ST_DATA void *rt_prog_main;
|
|||||||
|
|
||||||
/********************************************************/
|
/********************************************************/
|
||||||
|
|
||||||
#ifndef NOTALLINONE
|
#ifdef ONE_SOURCE
|
||||||
#include "tccpp.c"
|
#include "tccpp.c"
|
||||||
#include "tccgen.c"
|
#include "tccgen.c"
|
||||||
#include "tccelf.c"
|
#include "tccelf.c"
|
||||||
|
6
tcc.c
6
tcc.c
@ -18,10 +18,10 @@
|
|||||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if defined NOTALLINONE || defined TCC_USE_LIBTCC
|
#ifdef ONE_SOURCE
|
||||||
#include "tcc.h"
|
|
||||||
#else
|
|
||||||
#include "libtcc.c"
|
#include "libtcc.c"
|
||||||
|
#else
|
||||||
|
#include "tcc.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static char **files;
|
static char **files;
|
||||||
|
4
tcc.h
4
tcc.h
@ -877,7 +877,7 @@ static inline int toup(int c)
|
|||||||
|
|
||||||
#define PUB_FUNC
|
#define PUB_FUNC
|
||||||
|
|
||||||
#ifndef NOTALLINONE
|
#ifdef ONE_SOURCE
|
||||||
#define ST_INLN static inline
|
#define ST_INLN static inline
|
||||||
#define ST_FUNC static
|
#define ST_FUNC static
|
||||||
#define ST_DATA static
|
#define ST_DATA static
|
||||||
@ -1278,7 +1278,7 @@ ST_DATA const int reg_classes[NB_REGS];
|
|||||||
|
|
||||||
/********************************************************/
|
/********************************************************/
|
||||||
#undef ST_DATA
|
#undef ST_DATA
|
||||||
#ifndef NOTALLINONE
|
#ifdef ONE_SOURCE
|
||||||
#define ST_DATA static
|
#define ST_DATA static
|
||||||
#else
|
#else
|
||||||
#define ST_DATA
|
#define ST_DATA
|
||||||
|
2
tccpe.c
2
tccpe.c
@ -376,7 +376,7 @@ static int pe_find_import(TCCState * s1, ElfW(Sym) *sym)
|
|||||||
{
|
{
|
||||||
char buffer[200];
|
char buffer[200];
|
||||||
const char *s, *p;
|
const char *s, *p;
|
||||||
int sym_index, n = 0;
|
int sym_index = 0, n = 0;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
s = pe_export_name(s1, sym);
|
s = pe_export_name(s1, sym);
|
||||||
|
@ -29,11 +29,11 @@ echo>>..\config.h #define CONFIG_SYSROOT ""
|
|||||||
:libtcc
|
:libtcc
|
||||||
if not exist libtcc\nul mkdir libtcc
|
if not exist libtcc\nul mkdir libtcc
|
||||||
copy ..\libtcc.h libtcc\libtcc.h
|
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
|
%AR% rcs libtcc/libtcc.a libtcc.o
|
||||||
|
|
||||||
:tcc
|
: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_std_includes
|
||||||
copy ..\include\*.h include
|
copy ..\include\*.h include
|
||||||
|
Loading…
Reference in New Issue
Block a user