aboutsummaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorShinichiro Hamaji <shinichiro.hamaji _at_ gmail.com>2008-12-02 03:19:25 +0900
committergrischka <grischka>2008-12-02 02:30:47 +0100
commit0a9873aa22731077fad295a4aad2fc1f390c8ac7 (patch)
tree95294fbf05ff654ad927276a72dd4f0779a9bba2 /Makefile
parentfb0ac27691c1a027d3322c2e1d2d0876163314a1 (diff)
downloadtinycc-0a9873aa22731077fad295a4aad2fc1f390c8ac7.tar.gz
tinycc-0a9873aa22731077fad295a4aad2fc1f390c8ac7.tar.bz2
Add support of x86-64.
Most change was done in #ifdef TCC_TARGET_X86_64. So, nothing should be broken by this change. Summary of current status of x86-64 support: - produces x86-64 object files and executables. - the x86-64 code generator is based on x86's. -- for long long integers, we use 64bit registers instead of tcc's generic implementation. -- for float or double, we use SSE. SSE registers are not utilized well (we only use xmm0 and xmm1). -- for long double, we use x87 FPU. - passes make test. - passes ./libtcc_test. - can compile tcc.c. The compiled tcc can compile tcc.c, too. (there should be some bugs since the binary size of tcc2 and tcc3 is differ where tcc tcc.c -o tcc2 and tcc2 tcc.c -o tcc3) - can compile links browser. It seems working. - not tested well. I tested this work only on my linux box with few programs. - calling convention of long-double-integer or struct is not exactly the same as GCC's x86-64 ABI. - implementation of tcc -run is naive (tcc -run tcctest.c works, but tcc -run tcc.c doesn't work). Relocating 64bit addresses seems to be not as simple as 32bit environments. - shared object support isn't unimplemented - no bounds checker support - some builtin functions such as __divdi3 aren't supported
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile23
1 files changed, 22 insertions, 1 deletions
diff --git a/Makefile b/Makefile
index 1e6adad..6ff3eb5 100644
--- a/Makefile
+++ b/Makefile
@@ -9,20 +9,28 @@ LIBS=-lm
ifndef CONFIG_NOLDL
LIBS+=-ldl
endif
+ifneq ($(ARCH),x86-64)
BCHECK_O=bcheck.o
endif
+endif
CFLAGS_P=$(CFLAGS) -pg -static -DCONFIG_TCC_STATIC
LIBS_P=
+ifneq ($(GCC_MAJOR),2)
+CFLAGS+=-fno-strict-aliasing
+endif
+
+ifeq ($(ARCH),i386)
CFLAGS+=-mpreferred-stack-boundary=2
ifeq ($(GCC_MAJOR),2)
CFLAGS+=-m386 -malign-functions=0
else
-CFLAGS+=-march=i386 -falign-functions=0 -fno-strict-aliasing
+CFLAGS+=-march=i386 -falign-functions=0
ifneq ($(GCC_MAJOR),3)
CFLAGS+=-Wno-pointer-sign -Wno-sign-compare
endif
endif
+endif
DISAS=objdump -d
INSTALL=install
@@ -50,6 +58,9 @@ ifdef CONFIG_CROSS
PROGS+=c67-tcc$(EXESUF) i386-win32-tcc$(EXESUF)
endif
endif
+ifeq ($(ARCH),x86-64)
+PROGS=tcc$(EXESUF)
+endif
ifdef CONFIG_USE_LIBGCC
LIBTCC1=
@@ -163,6 +174,10 @@ ARMFLAGS += $(if $(shell grep -l "^Features.* \(vfp\|iwmmxt\) " /proc/cpuinfo),-
tcc$(EXESUF): tcc.c arm-gen.c tccelf.c tccasm.c tcctok.h libtcc.h
$(CC) $(CFLAGS) -DTCC_TARGET_ARM $(ARMFLAGS) -o $@ $< $(LIBS)
endif
+ifeq ($(ARCH),x86-64)
+tcc$(EXESUF): tcc.c tccelf.c tccasm.c tcctok.h libtcc.h x86_64-gen.c
+ $(CC) $(CFLAGS) -DTCC_TARGET_X86_64 -o $@ $< $(LIBS)
+endif
endif
# Cross Tiny C Compilers
@@ -238,7 +253,9 @@ else
ifndef CONFIG_USE_LIBGCC
$(INSTALL) -m644 libtcc1.a "$(DESTDIR)$(tccdir)"
endif
+ifneq ($(ARCH),x86-64)
$(INSTALL) -m644 $(BCHECK_O) "$(DESTDIR)$(tccdir)"
+endif
$(INSTALL) -m644 stdarg.h stddef.h stdbool.h float.h varargs.h \
tcclib.h "$(DESTDIR)$(tccdir)/include"
endif
@@ -272,8 +289,12 @@ libtcc.o: tcc.c i386-gen.c Makefile
ifdef CONFIG_WIN32
$(CC) $(CFLAGS) -DTCC_TARGET_PE -DLIBTCC -c -o $@ $<
else
+ifeq ($(ARCH),x86-64)
+ $(CC) $(CFLAGS) -DTCC_TARGET_X86_64 -DLIBTCC -c -o $@ $<
+else
$(CC) $(CFLAGS) -DLIBTCC -c -o $@ $<
endif
+endif
libtcc.a: libtcc.o
$(AR) rcs $@ $^