cross-compilers: allow individual configuration
since configure supports only native configuration
a file 'cross-tcc.mak' needs to be created manually.
It is included in the Makefile if present.
# ----------------------------------------------------
# Example config-cross.mak:
#
# windows -> i386-linux cross-compiler
# (it expects the linux files in <prefix>/i386-linux)
ROOT-i386 = {B}/i386-linux
CRT-i386 = $(ROOT-i386)/usr/lib
LIB-i386 = $(ROOT-i386)/lib:$(ROOT-i386)/usr/lib
INC-i386 = {B}/lib/include:$(ROOT-i386)/usr/include
DEF-i386 += -D__linux__
# ----------------------------------------------------
Also:
- use libtcc1-<target>.a instead of directories
- add dummy arm assembler
- remove include dependencies from armeabi.c/lib-arm64.c
- tccelf/ld_add_file: add SYSROOT (when defined) to absolute
filenames coming from ld-scripts
This commit is contained in:
78
lib/Makefile
78
lib/Makefile
@ -6,34 +6,15 @@ TOP = ..
|
||||
include $(TOP)/Makefile
|
||||
VPATH = $(TOPSRC)/lib $(TOPSRC)/win32/lib
|
||||
|
||||
ifndef TARGET
|
||||
# we're building the native libtcc1.a
|
||||
ifdef CONFIG_WIN32
|
||||
ifeq ($(ARCH),x86_64)
|
||||
TARGET = x86_64-win32
|
||||
else
|
||||
TARGET = i386-win32
|
||||
endif
|
||||
else ifeq ($(ARCH),i386)
|
||||
TARGET = i386
|
||||
else ifeq ($(ARCH),x86_64)
|
||||
TARGET = x86_64
|
||||
else ifeq ($(ARCH),arm)
|
||||
TARGET = arm
|
||||
else ifeq ($(ARCH),arm64)
|
||||
TARGET = arm64
|
||||
endif
|
||||
ifneq ($(CROSS),yes)
|
||||
TCC = $(TOP)/tcc$(EXESUF)
|
||||
OUT = ../libtcc1.a
|
||||
BCHECK_O = bcheck.o
|
||||
else
|
||||
TCC = $(TOP)/$(TARGET)-tcc$(EXESUF)
|
||||
OUT = libtcc1-$(TARGET).a
|
||||
endif
|
||||
|
||||
DIR = $(TARGET)
|
||||
|
||||
native : ../libtcc1.a
|
||||
cross : $(DIR)/libtcc1.a
|
||||
|
||||
native : TCC = $(TOP)/tcc$(EXESUF)
|
||||
cross : TCC = $(TOP)/$(TARGET)-tcc$(EXESUF)
|
||||
|
||||
XCC = $(TCC) -B$(TOPSRC)
|
||||
XAR = $(TCC) -ar
|
||||
|
||||
@ -41,33 +22,39 @@ I386_O = libtcc1.o alloca86.o alloca86-bt.o $(BCHECK_O)
|
||||
X86_64_O = libtcc1.o alloca86_64.o alloca86_64-bt.o $(BCHECK_O)
|
||||
ARM_O = libtcc1.o armeabi.o alloca-arm.o
|
||||
ARM64_O = lib-arm64.o
|
||||
WIN32_O = crt1.o crt1w.o wincrt1.o wincrt1w.o dllcrt1.o dllmain.o chkstk.o
|
||||
WIN_O = crt1.o crt1w.o wincrt1.o wincrt1w.o dllcrt1.o dllmain.o
|
||||
|
||||
ifeq "$(TARGET)" "i386-win32"
|
||||
OBJ = $(addprefix $(DIR)/,$(I386_O) $(WIN32_O))
|
||||
OBJ = $(I386_O) chkstk.o $(WIN_O)
|
||||
TGT = -DTCC_TARGET_I386 -DTCC_TARGET_PE
|
||||
XCC = $(TCC) -B$(TOPSRC)/win32 -I$(TOPSRC)/include
|
||||
else ifeq "$(TARGET)" "x86_64-win32"
|
||||
OBJ = $(addprefix $(DIR)/,$(X86_64_O) $(WIN32_O))
|
||||
OBJ = $(X86_64_O) chkstk.o $(WIN_O)
|
||||
TGT = -DTCC_TARGET_X86_64 -DTCC_TARGET_PE
|
||||
XCC = $(TCC) -B$(TOPSRC)/win32 -I$(TOPSRC)/include
|
||||
else ifeq "$(TARGET)" "arm-wince"
|
||||
OBJ = $(ARM_O) $(WIN_O)
|
||||
TGT = -DTCC_TARGET_ARM -DTCC_TARGET_PE
|
||||
XCC = $(TCC) -B$(TOPSRC)/win32 -I$(TOPSRC)/include
|
||||
else ifeq "$(TARGET)" "i386"
|
||||
OBJ = $(addprefix $(DIR)/,$(I386_O))
|
||||
OBJ = $(I386_O)
|
||||
TGT = -DTCC_TARGET_I386
|
||||
else ifeq "$(TARGET)" "x86_64"
|
||||
OBJ = $(addprefix $(DIR)/,$(X86_64_O))
|
||||
OBJ = $(X86_64_O)
|
||||
TGT = -DTCC_TARGET_X86_64
|
||||
else ifeq "$(TARGET)" "arm"
|
||||
OBJ = $(addprefix $(DIR)/,$(ARM_O))
|
||||
else ifeq "$(TARGET)" "arm-eabihf"
|
||||
OBJ = $(ARM_O)
|
||||
TGT = -DTCC_TARGET_ARM
|
||||
ifneq ($(CROSS),yes)
|
||||
# using gcc, need asm
|
||||
XCC = $(CC)
|
||||
XFLAGS = $(CFLAGS) -fPIC
|
||||
XAR = $(AR)
|
||||
endif
|
||||
else ifeq "$(TARGET)" "arm64"
|
||||
OBJ = $(addprefix $(DIR)/,$(ARM64_O))
|
||||
OBJ = $(ARM64_O)
|
||||
TGT = -DTCC_TARGET_ARM64
|
||||
else
|
||||
else ifneq "$(TARGET)" ""
|
||||
$(error libtcc1.a not supported on target '$(TARGET)')
|
||||
endif
|
||||
|
||||
@ -76,21 +63,18 @@ ifeq ($(TARGETOS),Darwin)
|
||||
BCHECK_O =
|
||||
endif
|
||||
|
||||
$(DIR)/libtcc1.a ../libtcc1.a : $(OBJ)
|
||||
$(XAR) rcs $@ $(OBJ)
|
||||
$(DIR)/%.o : %.c
|
||||
all : $(OUT)
|
||||
|
||||
$(OUT) : $(patsubst %.o,%-$(TARGET).o,$(OBJ))
|
||||
$(XAR) rcs $@ $^
|
||||
%-$(TARGET).o : %.c
|
||||
$(XCC) -c $< -o $@ $(TGT) $(XFLAGS)
|
||||
$(DIR)/%.o : %.S
|
||||
%-$(TARGET).o : %.S
|
||||
$(XCC) -c $< -o $@ $(TGT) $(XFLAGS)
|
||||
|
||||
$(DIR)/crt1w.o : crt1.c
|
||||
$(DIR)/wincrt1w.o : wincrt1.c
|
||||
|
||||
$(OBJ) : $(DIR)/exists
|
||||
|
||||
%/exists :
|
||||
mkdir -p $(DIR)
|
||||
@echo $@ > $@
|
||||
crt1w-$(TARGET).o : crt1.c
|
||||
wincrt1w-$(TARGET).o : wincrt1.c
|
||||
bcheck-$(TARGET).o : XFLAGS += -w
|
||||
|
||||
clean :
|
||||
rm -rf i386-win32 x86_64-win32 i386 x86_64 arm arm64
|
||||
rm -f *.a *.o $(OUT)
|
||||
|
||||
@ -3,8 +3,15 @@
|
||||
.global alloca
|
||||
.type alloca, %function
|
||||
alloca:
|
||||
#ifdef __TINYC__
|
||||
.int 0xe060d00d
|
||||
.int 0xe3cdd007
|
||||
.int 0xe1a0000d
|
||||
.int 0xe1a0f00e
|
||||
#else
|
||||
rsb sp, r0, sp
|
||||
bic sp, sp, #7
|
||||
mov r0, sp
|
||||
mov pc, lr
|
||||
#endif
|
||||
.size alloca, .-alloca
|
||||
|
||||
@ -19,7 +19,19 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.*/
|
||||
|
||||
#ifdef __TINYC__
|
||||
#define INT_MIN (-2147483647 - 1)
|
||||
#define INT_MAX 2147483647
|
||||
#define UINT_MAX 0xffffffff
|
||||
#define LONG_MIN (-2147483647L - 1)
|
||||
#define LONG_MAX 2147483647L
|
||||
#define ULONG_MAX 0xffffffffUL
|
||||
#define LLONG_MAX 9223372036854775807LL
|
||||
#define LLONG_MIN (-9223372036854775807LL - 1)
|
||||
#define ULLONG_MAX 0xffffffffffffffffULL
|
||||
#else
|
||||
#include <limits.h>
|
||||
#endif
|
||||
|
||||
/* We rely on the little endianness and EABI calling convention for this to
|
||||
work */
|
||||
|
||||
@ -9,8 +9,20 @@
|
||||
* without any warranty.
|
||||
*/
|
||||
|
||||
#ifdef __TINYC__
|
||||
typedef signed char int8_t;
|
||||
typedef unsigned char uint8_t;
|
||||
typedef short int16_t;
|
||||
typedef unsigned short uint16_t;
|
||||
typedef int int32_t;
|
||||
typedef unsigned uint32_t;
|
||||
typedef long long int64_t;
|
||||
typedef unsigned long long uint64_t;
|
||||
void *memcpy(void*,void*,__SIZE_TYPE__);
|
||||
#else
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#endif
|
||||
|
||||
void __clear_cache(void *beg, void *end)
|
||||
{
|
||||
|
||||
@ -693,7 +693,7 @@ void *__va_arg(__va_list_struct *ap,
|
||||
}
|
||||
#endif /* __x86_64__ */
|
||||
|
||||
#ifdef TCC_TARGET_ARM
|
||||
#if defined TCC_TARGET_ARM && !defined __TINYC__
|
||||
#define _GNU_SOURCE
|
||||
#include <unistd.h>
|
||||
#include <sys/syscall.h>
|
||||
|
||||
Reference in New Issue
Block a user