mirror of
https://github.com/frida/tinycc
synced 2024-11-27 18:19:35 +03:00
final adjustments for release
- configure/Makefiles: minor adjustments
- build-tcc.bat: add -static to gcc options
(avoids libgcc_s*.dll dependency with some mingw versions)
- tccpe.c/tcctools.c: eliminate MAX_PATH
(not available for cross compilers)
- tccasm.c: use uint64_t/strtoull in unary()
(unsigned long sometimes is only uint32_t, as always on windows)
- tccgen.c: Revert (f077d16c
) "tccgen: gen_cast: cast FLOAT to DOUBLE"
Was a rather experimental, tentative commit, not really necessary
and somewhat ugly too.
- cleanup recent osx support:
- Makefile/libtcc.c: cleanup copy&paste code
- tccpp.c: restore deleted function
This commit is contained in:
parent
fb4f57666c
commit
7acf9aa862
114
Makefile
114
Makefile
@ -4,8 +4,8 @@
|
||||
#
|
||||
|
||||
ifndef TOP
|
||||
TOP = .
|
||||
INCLUDED = no
|
||||
TOP = .
|
||||
INCLUDED = no
|
||||
endif
|
||||
|
||||
include $(TOP)/config.mak
|
||||
@ -31,26 +31,11 @@ VPATH = $(TOPSRC)
|
||||
|
||||
ifdef CONFIG_WIN32
|
||||
ifneq ($(DISABLE_STATIC),no)
|
||||
LIBTCC = libtcc.dll
|
||||
LIBTCC = libtcc$(DLLSUF)
|
||||
LIBTCCDEF = libtcc.def
|
||||
endif
|
||||
CFGWIN = -win
|
||||
NATIVE_TARGET = $(ARCH)-$(if $(eq $(ARCH),arm),wince,win32)
|
||||
else ifdef CONFIG_OSX
|
||||
LIBS=-lm
|
||||
ifndef CONFIG_NOLDL
|
||||
LIBS+=-ldl
|
||||
endif
|
||||
# make libtcc as static or dynamic library?
|
||||
ifeq ($(DISABLE_STATIC),yes)
|
||||
LIBTCC=libtcc.dylib
|
||||
ifndef DISABLE_RPATH
|
||||
LINK_LIBTCC += -Wl,-rpath,"$(libdir)"
|
||||
export LD_LIBRARY_PATH := $(CURDIR)/$(TOP)
|
||||
endif
|
||||
endif
|
||||
CFGWIN =-unx
|
||||
NATIVE_TARGET = $(ARCH)-osx
|
||||
NATIVE_TARGET = $(ARCH)-win$(if $(findstring arm,$(ARCH)),ce,32)
|
||||
else
|
||||
LIBS=-lm
|
||||
ifndef CONFIG_NOLDL
|
||||
@ -58,19 +43,19 @@ else
|
||||
endif
|
||||
# make libtcc as static or dynamic library?
|
||||
ifeq ($(DISABLE_STATIC),yes)
|
||||
LIBTCC=libtcc.so
|
||||
LIBTCC=libtcc$(DLLSUF)
|
||||
export LD_LIBRARY_PATH := $(CURDIR)/$(TOP)
|
||||
ifndef DISABLE_RPATH
|
||||
LINK_LIBTCC += -Wl,-rpath,"$(libdir)"
|
||||
export LD_LIBRARY_PATH := $(CURDIR)/$(TOP)
|
||||
endif
|
||||
endif
|
||||
CFGWIN =-unx
|
||||
NATIVE_TARGET = $(ARCH)
|
||||
endif
|
||||
|
||||
ifeq ($(TARGETOS),Darwin)
|
||||
LDFLAGS += -flat_namespace -undefined warning
|
||||
export MACOSX_DEPLOYMENT_TARGET:=10.2
|
||||
ifdef CONFIG_OSX
|
||||
NATIVE_TARGET = $(ARCH)-osx
|
||||
LDFLAGS += -flat_namespace -undefined warning
|
||||
export MACOSX_DEPLOYMENT_TARGET := 10.2
|
||||
endif
|
||||
endif
|
||||
|
||||
# run local version of tcc with local libraries and includes
|
||||
@ -78,16 +63,19 @@ TCCFLAGS-unx = -B$(TOP) -I$(TOPSRC)/include -I$(TOPSRC) -I$(TOP)
|
||||
TCCFLAGS-win = -B$(TOPSRC)/win32 -I$(TOPSRC)/include -I$(TOPSRC) -I$(TOP) -L$(TOP)
|
||||
TCCFLAGS = $(TCCFLAGS$(CFGWIN))
|
||||
TCC = $(TOP)/tcc$(EXESUF) $(TCCFLAGS)
|
||||
ifdef CONFIG_OSX
|
||||
TCCFLAGS += -D_ANSI_SOURCE
|
||||
endif
|
||||
|
||||
CFLAGS_P = $(CFLAGS) -pg -static -DCONFIG_TCC_STATIC -DTCC_PROFILE
|
||||
LIBS_P= $(LIBS)
|
||||
LIBS_P = $(LIBS)
|
||||
LDFLAGS_P = $(LDFLAGS)
|
||||
|
||||
CONFIG_$(ARCH) = yes
|
||||
NATIVE_DEFINES_$(CONFIG_i386) += -DTCC_TARGET_I386
|
||||
NATIVE_DEFINES_$(CONFIG_x86_64) += -DTCC_TARGET_X86_64
|
||||
NATIVE_DEFINES_$(CONFIG_WIN32) += -DTCC_TARGET_PE
|
||||
NATIVE_DEFINES_$(CONFIG_OSX) += -DTCC_TARGET_X86_64 -DTCC_TARGET_MACHO
|
||||
NATIVE_DEFINES_$(CONFIG_OSX) += -DTCC_TARGET_MACHO
|
||||
NATIVE_DEFINES_$(CONFIG_uClibc) += -DTCC_UCLIBC
|
||||
NATIVE_DEFINES_$(CONFIG_musl) += -DTCC_MUSL
|
||||
NATIVE_DEFINES_$(CONFIG_arm) += -DTCC_TARGET_ARM
|
||||
@ -117,12 +105,8 @@ LIBTCC1_X = i386 x86_64 i386-win32 x86_64-win32 x86_64-osx arm arm64 arm-wince
|
||||
PROGS_CROSS = $(foreach X,$(TCC_X),$X-tcc$(EXESUF))
|
||||
LIBTCC1_CROSS = $(foreach X,$(LIBTCC1_X),libtcc1-$X.a)
|
||||
|
||||
ifdef CONFIG_CROSS
|
||||
all : $(LIBTCC1_CROSS) $(PROGS_CROSS)
|
||||
endif
|
||||
|
||||
# build cross compilers & libs
|
||||
cross: all $(LIBTCC1_CROSS) $(PROGS_CROSS)
|
||||
cross: $(LIBTCC1_CROSS) $(PROGS_CROSS)
|
||||
|
||||
# build specific cross compiler & lib
|
||||
cross-%: %-tcc$(EXESUF) libtcc1-%.a ;
|
||||
@ -130,6 +114,10 @@ cross-%: %-tcc$(EXESUF) libtcc1-%.a ;
|
||||
install: install$(CFGWIN)
|
||||
uninstall: uninstall$(CFGWIN)
|
||||
|
||||
ifdef CONFIG_CROSS
|
||||
all : cross
|
||||
endif
|
||||
|
||||
# --------------------------------------------
|
||||
|
||||
T = $(or $(CROSS_TARGET),$(NATIVE_TARGET),unknown)
|
||||
@ -206,7 +194,7 @@ $(X)tcc.o : tcctools.c
|
||||
$(X)arm-gen.o : arm-asm.c
|
||||
|
||||
# Host Tiny C Compiler
|
||||
tcc$(EXESUF): $(X)tcc.o $(LIBTCC)
|
||||
tcc$(EXESUF): tcc.o $(LIBTCC)
|
||||
$(CC) -o $@ $^ $(DEFINES) $(CFLAGS) $(LIBS) $(LDFLAGS) $(LINK_LIBTCC)
|
||||
|
||||
# Cross Tiny C Compilers
|
||||
@ -218,7 +206,7 @@ $(CROSS_TARGET)-tcc$(EXESUF): $(TCC_FILES)
|
||||
|
||||
# profiling version
|
||||
tcc_p$(EXESUF): $($T_FILES)
|
||||
$(CC) -o $@ $< -$(DEFINES) $(CFLAGS_P) $(LIBS_P) $(LDFLAGS_P)
|
||||
$(CC) -o $@ $< $(DEFINES) -DONE_SOURCE $(CFLAGS_P) $(LIBS_P) $(LDFLAGS_P)
|
||||
|
||||
# static libtcc library
|
||||
libtcc.a: $(LIBTCC_OBJ)
|
||||
@ -226,13 +214,13 @@ libtcc.a: $(LIBTCC_OBJ)
|
||||
|
||||
# dynamic libtcc library
|
||||
libtcc.so: $(LIBTCC_OBJ)
|
||||
$(CC) -shared -Wl,-soname,$@ -o $@ $^ $(LDFLAGS)
|
||||
$(CC) -shared -Wl,-soname,$@ -o $@ $^ $(CFLAGS) $(LDFLAGS)
|
||||
|
||||
libtcc.so: CFLAGS+=-fPIC
|
||||
|
||||
# windows dynamic libtcc library
|
||||
libtcc.dll : $(LIBTCC_OBJ)
|
||||
$(CC) -shared $(LIBTCC_OBJ) -o $@ $(LDFLAGS)
|
||||
$(CC) -shared -o $@ $^ $(CFLAGS) $(LDFLAGS)
|
||||
|
||||
libtcc.def : libtcc.dll tcc$(EXESUF)
|
||||
./tcc$(EXESUF) -impdef $< -o $@
|
||||
@ -241,11 +229,11 @@ libtcc.dll : DEFINES += -DLIBTCC_AS_DLL
|
||||
|
||||
# TinyCC runtime libraries
|
||||
libtcc1.a : tcc$(EXESUF) FORCE
|
||||
@$(MAKE) -f lib/Makefile BIN=$@ $@ TOP=. --no-print-directory
|
||||
@$(MAKE) -C lib
|
||||
|
||||
# Cross libtcc1.a
|
||||
libtcc1-%.a : %-tcc$(EXESUF) FORCE
|
||||
@$(MAKE) -f lib/Makefile BIN=$@ $@ CROSS_TARGET=$* TOP=. --no-print-directory
|
||||
@$(MAKE) -C lib CROSS_TARGET=$*
|
||||
|
||||
FORCE:
|
||||
|
||||
@ -290,19 +278,21 @@ install-unx:
|
||||
$(call TRY-INSTALL,tcc.1,"$(mandir)/man1")
|
||||
$(call TRY-INSTALL,tcc-doc.info,"$(infodir)")
|
||||
$(call TRY-INSTALL,tcc-doc.html,"$(docdir)")
|
||||
mkdir -p "$(tccdir)/win32/include"
|
||||
cp -r $(TOPSRC)/include/. "$(tccdir)/win32/include"
|
||||
cp -r $(TOPSRC)/win32/include/. "$(tccdir)/win32/include"
|
||||
ifneq "$(LIBTCC1_W)" ""
|
||||
mkdir -p "$(tccdir)/win32/lib"
|
||||
$(INSTALL) $(TOPSRC)/win32/lib/*.def $(LIBTCC1_W) "$(tccdir)/win32/lib"
|
||||
mkdir -p "$(tccdir)/win32/include"
|
||||
cp -r $(TOPSRC)/win32/include/. "$(tccdir)/win32/include"
|
||||
$(INSTALL) $(TOPSRC)/include/*.h $(TOPSRC)/tcclib.h "$(tccdir)/win32/include"
|
||||
endif
|
||||
|
||||
# uninstall
|
||||
uninstall-unx:
|
||||
rm -fv $(foreach P,$(PROGS) $(PROGS_CROSS),"$(bindir)/$P")
|
||||
rm -fv "$(libdir)/$(LIBTCC)" "$(includedir)/libtcc.h"
|
||||
rm -fv "$(mandir)/man1/tcc.1" "$(infodir)/tcc-doc.info"
|
||||
rm -fv "$(docdir)/tcc-doc.html"
|
||||
rm -rv "$(tccdir)"
|
||||
@rm -fv $(foreach P,$(PROGS) $(PROGS_CROSS),"$(bindir)/$P")
|
||||
@rm -fv "$(libdir)/libtcc.a" "$(libdir)/libtcc.so" "$(includedir)/libtcc.h"
|
||||
@rm -fv "$(mandir)/man1/tcc.1" "$(infodir)/tcc-doc.info"
|
||||
@rm -fv "$(docdir)/tcc-doc.html"
|
||||
rm -r "$(tccdir)"
|
||||
|
||||
# install progs & libs on windows
|
||||
install-win:
|
||||
@ -310,12 +300,10 @@ install-win:
|
||||
$(INSTALL) $(PROGS) $(subst libtcc.a,,$(LIBTCC)) $(PROGS_X) "$(tccdir)"
|
||||
mkdir -p "$(tccdir)/lib"
|
||||
$(INSTALL) $(TOPSRC)/win32/lib/*.def "$(tccdir)/lib"
|
||||
$(INSTALL) libtcc1.a $(LIBTCC1_W) $(LIBTCC1_U) "$(tccdir)/lib"
|
||||
$(INSTALL) libtcc1.a $(LIBTCC1_W) "$(tccdir)/lib"
|
||||
mkdir -p "$(tccdir)/include"
|
||||
cp -r $(TOPSRC)/win32/include/. "$(tccdir)/include"
|
||||
$(INSTALL) $(TOPSRC)/include/*.h $(TOPSRC)/tcclib.h "$(tccdir)/include"
|
||||
mkdir -p "$(tccdir)/lib/include";
|
||||
$(INSTALL) $(TOPSRC)/include/*.h $(TOPSRC)/tcclib.h "$(tccdir)/lib/include"
|
||||
mkdir -p "$(tccdir)/examples"
|
||||
cp -r $(TOPSRC)/win32/examples/. "$(tccdir)/examples"
|
||||
$(INSTALL) $(TOPSRC)/tests/libtcc_test.c "$(tccdir)/examples"
|
||||
@ -323,13 +311,18 @@ install-win:
|
||||
$(INSTALL) $(TOPSRC)/libtcc.h $(subst .dll,.def,$(LIBTCC)) "$(tccdir)/libtcc"
|
||||
mkdir -p "$(tccdir)/doc"
|
||||
$(INSTALL) $(TOPSRC)/win32/tcc-win32.txt $(wildcard tcc-doc.html) "$(tccdir)/doc"
|
||||
ifneq "$(LIBTCC1_U)" ""
|
||||
$(INSTALL) $(LIBTCC1_U) "$(tccdir)/lib"
|
||||
mkdir -p "$(tccdir)/lib/include";
|
||||
$(INSTALL) $(TOPSRC)/include/*.h $(TOPSRC)/tcclib.h "$(tccdir)/lib/include"
|
||||
endif
|
||||
|
||||
# the msys-git shell works to configure && make except it does not have install
|
||||
install-win : INSTALL = cp
|
||||
|
||||
# uninstall on windows
|
||||
uninstall-win:
|
||||
rm -rfv "$(tccdir)/"*
|
||||
rm -r "$(tccdir)/"*
|
||||
|
||||
# --------------------------------------------------------------------------
|
||||
# other stuff
|
||||
@ -341,7 +334,7 @@ ETAGS : ; etags $(TAGFILES)
|
||||
|
||||
# create release tarball from *current* git branch (including tcc-doc.html
|
||||
# and converting two files to CRLF)
|
||||
TCC-VERSION = $(VERSION)
|
||||
TCC-VERSION = tcc-$(VERSION)
|
||||
tar: tcc-doc.html
|
||||
mkdir $(TCC-VERSION)
|
||||
( cd $(TCC-VERSION) && git --git-dir ../.git checkout -f )
|
||||
@ -361,11 +354,10 @@ test:
|
||||
$(MAKE) -C tests
|
||||
|
||||
clean:
|
||||
rm -f $(PROGS) $(PROGS_CROSS) tcc_p$(EXESUF) tcc.pod \
|
||||
*~ *.o *.a *.so* *.out *.log lib*.def *.exe *.dll a.out \
|
||||
tags TAGS libtcc_test$(EXESUF)
|
||||
$(MAKE) -C tests $@
|
||||
$(MAKE) -C lib $@
|
||||
rm -f $(PROGS) $(PROGS_CROSS) tcc_p$(EXESUF) tcc.pod
|
||||
rm -f *~ *.o *.a *.so* *.out *.log lib*.def *.exe *.dll a.out tags TAGS
|
||||
@$(MAKE) -C tests $@
|
||||
@$(MAKE) -C lib $@
|
||||
|
||||
distclean: clean
|
||||
rm -f config.h config.mak config.texi tcc.1 tcc-doc.info tcc-doc.html
|
||||
@ -389,12 +381,12 @@ help:
|
||||
@echo "Cross compiler configuration:"
|
||||
@echo " make will read custom configuration for cross compilers from a file"
|
||||
@echo " 'config-cross.mak' if present. For example for a windows->i386-linux"
|
||||
@echo " cross-compiler that expects the linux files in <prefix>/i386-linux:"
|
||||
@echo " cross-compiler that expects the linux files in <tccdir>/i386-linux:"
|
||||
@echo ""
|
||||
@echo " ROOT-i386 = {B}/i386-linux"
|
||||
@echo " CRT-i386 = $(ROOT-i386)/usr/lib"
|
||||
@echo " LIB-i386 = $(ROOT-i386)/lib:$(ROOT-i386)/usr/lib"
|
||||
@echo " INC-i386 = {B}/lib/include:$(ROOT-i386)/usr/include"
|
||||
@echo " CRT-i386 = {B}/i386-linux/usr/lib"
|
||||
@echo " LIB-i386 = {B}/i386-linux/lib:{B}/i386-linux/usr/lib"
|
||||
@echo " INC-i386 = {B}/lib/include:{B}/i386-linux/usr/include"
|
||||
@echo " DEF-i386 += -D__linux__"
|
||||
@echo ""
|
||||
@echo "Other supported make targets:"
|
||||
|
34
configure
vendored
Executable file → Normal file
34
configure
vendored
Executable file → Normal file
@ -33,7 +33,7 @@ cross_prefix=""
|
||||
cc="gcc"
|
||||
ar="ar"
|
||||
strip="strip"
|
||||
cygwin="no"
|
||||
noldl="no"
|
||||
gprof="no"
|
||||
bigendian="no"
|
||||
mingw32="no"
|
||||
@ -53,28 +53,26 @@ cpu=
|
||||
# OS specific
|
||||
targetos=`uname`
|
||||
case $targetos in
|
||||
Darwin) osx=yes;;
|
||||
MINGW*) mingw32=yes;;
|
||||
MSYS*) mingw32=yes;;
|
||||
CYGWIN*) mingw32=yes; cygwin=yes; cross_prefix="mingw32-";;
|
||||
DragonFly) noldl=yes;;
|
||||
OpenBSD) noldl=yes;;
|
||||
FreeBSD) noldl=yes;;
|
||||
NetBSD) noldl=yes;;
|
||||
*) ;;
|
||||
Darwin)
|
||||
osx=yes
|
||||
;;
|
||||
MINGW*|MSYS*|CYGWIN*)
|
||||
mingw32=yes
|
||||
;;
|
||||
DragonFly|OpenBSD|FreeBSD|NetBSD)
|
||||
noldl=yes
|
||||
;;
|
||||
*)
|
||||
;;
|
||||
esac
|
||||
|
||||
# find source path
|
||||
# XXX: we assume an absolute path is given when launching configure,
|
||||
# except in './configure' case.
|
||||
source_path=${0%configure}
|
||||
source_path=${source_path%/}
|
||||
source_path_used="yes"
|
||||
if test -z "$source_path" -o "$source_path" = "." ; then
|
||||
source_path=`pwd`
|
||||
source_path_used="no"
|
||||
# mingw compilers might not understand cygwin paths
|
||||
if test $cygwin = "yes"; then source_path="."; fi
|
||||
fi
|
||||
|
||||
for opt do
|
||||
@ -130,7 +128,7 @@ for opt do
|
||||
;;
|
||||
--enable-gprof) gprof="yes"
|
||||
;;
|
||||
--enable-mingw32) mingw32="yes" ; cross_prefix="i686-pc-mingw32-" ; cpu=x86
|
||||
--enable-mingw32) mingw32="yes"
|
||||
;;
|
||||
--enable-cross) build_cross="yes"
|
||||
;;
|
||||
@ -211,6 +209,12 @@ if test -z "$CFLAGS"; then
|
||||
fi
|
||||
|
||||
if test "$mingw32" = "yes" ; then
|
||||
if test "$source_path_used" = "no"; then
|
||||
source_path="."
|
||||
fi
|
||||
if test "$cc" = gcc; then
|
||||
test -z "$LDFLAGS" && LDFLAGS="-static"
|
||||
fi
|
||||
if test x"$tccdir" = x""; then
|
||||
tccdir="tcc"
|
||||
fi
|
||||
|
18
lib/Makefile
18
lib/Makefile
@ -7,6 +7,7 @@ include $(TOP)/Makefile
|
||||
VPATH = $(TOPSRC)/lib $(TOPSRC)/win32/lib
|
||||
T = $(or $(CROSS_TARGET),$(NATIVE_TARGET),unknown)
|
||||
X = $(if $(CROSS_TARGET),$(CROSS_TARGET)-)
|
||||
BIN = $(TOP)/libtcc1$(if $(CROSS_TARGET),-$(CROSS_TARGET)).a
|
||||
|
||||
TCC = $(TOP)/$(X)tcc$(EXESUF)
|
||||
XCC = $(TCC)
|
||||
@ -25,25 +26,24 @@ ifeq ($(X),)
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(TARGETOS),Darwin)
|
||||
ifdef CONFIG_OSX
|
||||
XFLAGS += -D_ANSI_SOURCE
|
||||
BCHECK_O =
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_musl),yes)
|
||||
BCHECK_O =
|
||||
endif
|
||||
|
||||
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)
|
||||
I386_O = libtcc1.o alloca86.o alloca86-bt.o
|
||||
X86_64_O = libtcc1.o alloca86_64.o alloca86_64-bt.o
|
||||
ARM_O = libtcc1.o armeabi.o alloca-arm.o
|
||||
ARM64_O = lib-arm64.o
|
||||
WIN_O = crt1.o crt1w.o wincrt1.o wincrt1w.o dllcrt1.o dllmain.o
|
||||
|
||||
OBJ-i386 = $(I386_O)
|
||||
OBJ-i386 = $(I386_O) $(BCHECK_O)
|
||||
TGT-i386 = -DTCC_TARGET_I386
|
||||
|
||||
OBJ-x86_64 = $(X86_64_O)
|
||||
OBJ-x86_64 = $(X86_64_O) $(BCHECK_O)
|
||||
TGT-x86_64 = -DTCC_TARGET_X86_64
|
||||
|
||||
OBJ-x86_64-osx = $(X86_64_O)
|
||||
@ -55,17 +55,15 @@ TGT-arm = -DTCC_TARGET_ARM
|
||||
OBJ-arm64 = $(ARM64_O)
|
||||
TGT-arm64 = -DTCC_TARGET_ARM64
|
||||
|
||||
OBJ-i386-win32 = $(I386_O) chkstk.o $(WIN_O)
|
||||
OBJ-i386-win32 = $(I386_O) chkstk.o bcheck.o $(WIN_O)
|
||||
TGT-i386-win32 = -DTCC_TARGET_I386 -DTCC_TARGET_PE
|
||||
|
||||
OBJ-x86_64-win32 = $(X86_64_O) chkstk.o $(WIN_O)
|
||||
OBJ-x86_64-win32 = $(X86_64_O) chkstk.o bcheck.o $(WIN_O)
|
||||
TGT-x86_64-win32 = -DTCC_TARGET_X86_64 -DTCC_TARGET_PE
|
||||
|
||||
OBJ-arm-wince = $(ARM_O) $(WIN_O)
|
||||
TGT-arm-wince = -DTCC_TARGET_ARM -DTCC_TARGET_PE
|
||||
|
||||
all : $(BIN)
|
||||
|
||||
$(BIN) : $(patsubst %.o,$(X)%.o,$(OBJ-$T))
|
||||
$(XAR) rcs $@ $^
|
||||
|
||||
|
27
libtcc.c
27
libtcc.c
@ -1054,6 +1054,11 @@ ST_FUNC int tcc_add_file_internal(TCCState *s1, const char *filename, int flags)
|
||||
/* do not display line number if error */
|
||||
file->line_num = 0;
|
||||
|
||||
#ifdef TCC_TARGET_MACHO
|
||||
if (0 == obj_type && 0 == strcmp(tcc_fileextension(filename), "dylib"))
|
||||
obj_type = AFF_BINTYPE_DYN;
|
||||
#endif
|
||||
|
||||
switch (obj_type) {
|
||||
case AFF_BINTYPE_REL:
|
||||
ret = tcc_load_object_file(s1, fd, 0);
|
||||
@ -1081,19 +1086,7 @@ ST_FUNC int tcc_add_file_internal(TCCState *s1, const char *filename, int flags)
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
#if defined(TCC_TARGET_MACHO)
|
||||
if (s1->output_type == TCC_OUTPUT_MEMORY) {
|
||||
ret = 0;
|
||||
#ifdef TCC_IS_NATIVE
|
||||
if (NULL == dlopen(filename, RTLD_GLOBAL | RTLD_LAZY)) {
|
||||
ret = -1;
|
||||
}
|
||||
#endif /* TCC_TARGET_MACHO */
|
||||
} else {
|
||||
ret = tcc_load_dll(s1, fd, filename,
|
||||
(flags & AFF_REFERENCED_DLL) != 0);
|
||||
}
|
||||
#elif defined(TCC_TARGET_PE)
|
||||
#ifdef TCC_TARGET_PE
|
||||
ret = pe_load_file(s1, filename, fd);
|
||||
#else
|
||||
/* as GNU ld, consider it is an ld script if not recognized */
|
||||
@ -1155,12 +1148,12 @@ ST_FUNC int tcc_add_crt(TCCState *s, const char *filename)
|
||||
/* the library name is the same as the argument of the '-l' option */
|
||||
LIBTCCAPI int tcc_add_library(TCCState *s, const char *libraryname)
|
||||
{
|
||||
#if defined(TCC_TARGET_MACHO)
|
||||
const char *libs[] = { "%s/lib%s.dylib", "%s/lib%s.a", NULL };
|
||||
const char **pp = s->static_link ? libs + 1 : libs;
|
||||
#elif defined(TCC_TARGET_PE)
|
||||
#if defined TCC_TARGET_PE
|
||||
const char *libs[] = { "%s/%s.def", "%s/lib%s.def", "%s/%s.dll", "%s/lib%s.dll", "%s/lib%s.a", NULL };
|
||||
const char **pp = s->static_link ? libs + 4 : libs;
|
||||
#elif defined TCC_TARGET_MACHO
|
||||
const char *libs[] = { "%s/lib%s.dylib", "%s/lib%s.a", NULL };
|
||||
const char **pp = s->static_link ? libs + 1 : libs;
|
||||
#else
|
||||
const char *libs[] = { "%s/lib%s.so", "%s/lib%s.a", NULL };
|
||||
const char **pp = s->static_link ? libs + 1 : libs;
|
||||
|
4
tccasm.c
4
tccasm.c
@ -87,13 +87,13 @@ static void asm_expr_unary(TCCState *s1, ExprValue *pe)
|
||||
{
|
||||
Sym *sym;
|
||||
int op, label;
|
||||
unsigned long n;
|
||||
uint64_t n;
|
||||
const char *p;
|
||||
|
||||
switch(tok) {
|
||||
case TOK_PPNUM:
|
||||
p = tokc.str.data;
|
||||
n = strtoul(p, (char **)&p, 0);
|
||||
n = strtoull(p, (char **)&p, 0);
|
||||
if (*p == 'b' || *p == 'f') {
|
||||
/* backward or forward label */
|
||||
label = asm_get_local_label_name(s1, n);
|
||||
|
9
tccgen.c
9
tccgen.c
@ -906,10 +906,6 @@ ST_FUNC void save_reg_upstack(int r, int n)
|
||||
#else
|
||||
type = &int_type;
|
||||
#endif
|
||||
if ((type->t & VT_BTYPE) == VT_FLOAT) {
|
||||
/* cast to DOUBLE to avoid precision loss */
|
||||
type->t = (type->t & ~VT_BTYPE) | VT_DOUBLE;
|
||||
}
|
||||
size = type_size(type, &align);
|
||||
loc = (loc - size) & -align;
|
||||
sv.type.t = type->t;
|
||||
@ -2383,11 +2379,6 @@ static void gen_cast(CType *type)
|
||||
vpushi(0);
|
||||
gen_op(TOK_NE);
|
||||
} else {
|
||||
if (sbt == VT_FLOAT) {
|
||||
/* cast to DOUBLE to avoid precision loss */
|
||||
gen_cvt_ftof(VT_DOUBLE);
|
||||
vtop->type.t = (vtop->type.t & ~VT_BTYPE) | VT_DOUBLE;
|
||||
}
|
||||
/* we handle char/short/etc... with generic code */
|
||||
if (dbt != (VT_INT | VT_UNSIGNED) &&
|
||||
dbt != (VT_LLONG | VT_UNSIGNED) &&
|
||||
|
6
tccpe.c
6
tccpe.c
@ -28,10 +28,6 @@
|
||||
#define strnicmp strncasecmp
|
||||
#endif
|
||||
|
||||
#ifndef MAX_PATH
|
||||
#define MAX_PATH 260
|
||||
#endif
|
||||
|
||||
#ifdef TCC_TARGET_X86_64
|
||||
# define ADDR3264 ULONGLONG
|
||||
# define REL_TYPE_DIRECT R_X86_64_64
|
||||
@ -907,7 +903,7 @@ static void pe_build_exports(struct pe_info *pe)
|
||||
struct pe_sort_sym **sorted, *p;
|
||||
|
||||
FILE *op;
|
||||
char buf[MAX_PATH];
|
||||
char buf[260];
|
||||
const char *dllname;
|
||||
const char *name;
|
||||
|
||||
|
32
tccpp.c
32
tccpp.c
@ -1021,8 +1021,38 @@ ST_FUNC void restore_parse_state(ParseState *s)
|
||||
tokc = s->tokc;
|
||||
}
|
||||
|
||||
/* token string handling */
|
||||
#if 0
|
||||
/* return the number of additional 'ints' necessary to store the
|
||||
token */
|
||||
static inline int tok_size(const int *p)
|
||||
{
|
||||
switch(*p) {
|
||||
/* 4 bytes */
|
||||
case TOK_CINT:
|
||||
case TOK_CUINT:
|
||||
case TOK_CCHAR:
|
||||
case TOK_LCHAR:
|
||||
case TOK_CFLOAT:
|
||||
case TOK_LINENUM:
|
||||
return 1 + 1;
|
||||
case TOK_STR:
|
||||
case TOK_LSTR:
|
||||
case TOK_PPNUM:
|
||||
case TOK_PPSTR:
|
||||
return 1 + ((sizeof(CString) + ((CString *)(p+1))->size + 3) >> 2);
|
||||
case TOK_CDOUBLE:
|
||||
case TOK_CLLONG:
|
||||
case TOK_CULLONG:
|
||||
return 1 + 2;
|
||||
case TOK_CLDOUBLE:
|
||||
return 1 + LDOUBLE_SIZE / 4;
|
||||
default:
|
||||
return 1 + 0;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* token string handling */
|
||||
ST_INLN void tok_str_new(TokenString *s)
|
||||
{
|
||||
s->str = NULL;
|
||||
|
@ -304,15 +304,15 @@ the_end:
|
||||
ST_FUNC int tcc_tool_impdef(TCCState *s1, int argc, char **argv)
|
||||
{
|
||||
int ret, v, i;
|
||||
char infile[MAX_PATH];
|
||||
char outfile[MAX_PATH];
|
||||
char infile[260];
|
||||
char outfile[260];
|
||||
|
||||
const char *file;
|
||||
char *p, *q;
|
||||
FILE *fp, *op;
|
||||
|
||||
#ifdef _WIN32
|
||||
char path[MAX_PATH];
|
||||
char path[260];
|
||||
#endif
|
||||
|
||||
infile[0] = outfile[0] = 0;
|
||||
|
@ -5,7 +5,7 @@
|
||||
TOP = ..
|
||||
include $(TOP)/Makefile
|
||||
VPATH = $(TOPSRC)/tests $(TOPSRC) $(TOP)
|
||||
CFLAGS := $(filter-out -W% -g% -O%,$(CFLAGS)) -I$(TOPSRC)
|
||||
CFLAGS := $(filter-out -W% -g% -O%,$(CFLAGS)) -I$(TOPSRC) $(LDFLAGS)
|
||||
|
||||
# what tests to run
|
||||
TESTS = \
|
||||
@ -34,8 +34,8 @@ endif
|
||||
ifdef CONFIG_WIN32
|
||||
TESTS := $(filter-out $(BTESTS),$(TESTS))
|
||||
endif
|
||||
ifeq ($(TARGETOS),Darwin)
|
||||
TESTS := $(filter-out hello-exe test3 $(BTESTS),$(TESTS))
|
||||
ifdef CONFIG_OSX # -run only
|
||||
TESTS := hello-run libtest tests2-dir pp-dir
|
||||
endif
|
||||
ifeq (,$(filter arm64 i386 x86_64,$(ARCH)))
|
||||
TESTS := $(filter-out vla_test-run,$(TESTS))
|
||||
@ -51,28 +51,23 @@ ifndef CONFIG_CROSS
|
||||
endif
|
||||
|
||||
ifdef CONFIG_WIN32
|
||||
PATH := $(CURDIR)/$(TOP):$(PATH) # for libtcc_test to find libtcc.dll
|
||||
endif
|
||||
|
||||
ifeq ($(TARGETOS),Darwin)
|
||||
CFLAGS += -Wl,-flat_namespace,-undefined,warning
|
||||
TCCFLAGS += -D_ANSI_SOURCE
|
||||
export MACOSX_DEPLOYMENT_TARGET:=10.2
|
||||
SEP = $(if $(findstring :\,$(PATH)),;,:)
|
||||
PATH := $(CURDIR)/$(TOP)$(SEP)$(PATH) # for libtcc_test to find libtcc.dll
|
||||
endif
|
||||
|
||||
RUN_TCC = $(NATIVE_DEFINES) -DONE_SOURCE -run $(TOPSRC)/tcc.c $(TCCFLAGS)
|
||||
|
||||
DISAS = objdump -d
|
||||
DUMPTCC = (set -x; $(TOP)/tcc -vv; ldd $(TOP)/tcc; exit 1)
|
||||
|
||||
all test : clean-s $(TESTS)
|
||||
|
||||
hello-exe: ../examples/ex1.c
|
||||
@echo ------------ $@ ------------
|
||||
$(TCC) $< -o hello$(EXESUF) || ($(TOP)/tcc -vv; exit 1) && ./hello$(EXESUF)
|
||||
$(TCC) $< -o hello$(EXESUF) && ./hello$(EXESUF) || $(DUMPTCC)
|
||||
|
||||
hello-run: ../examples/ex1.c
|
||||
@echo ------------ $@ ------------
|
||||
$(TCC) -run $<
|
||||
$(TCC) -run $< || $(DUMPTCC)
|
||||
|
||||
libtest: libtcc_test$(EXESUF)
|
||||
@echo ------------ $@ ------------
|
||||
@ -263,11 +258,11 @@ cache: tcc_g
|
||||
|
||||
# clean
|
||||
clean:
|
||||
rm -f *~ *.o *.a *.bin *.i *.ref *.out *.out? *.out?b *.cc *.gcc \
|
||||
*-cc *-gcc *-tcc *.exe hello libtcc_test vla_test tcctest[1234] \
|
||||
ex? tcc_g *.def weaktest.*.txt
|
||||
$(MAKE) -C tests2 $@
|
||||
$(MAKE) -C pp $@
|
||||
rm -f *~ *.o *.a *.bin *.i *.ref *.out *.out? *.out?b *.cc *.gcc
|
||||
rm -f *-cc *-gcc *-tcc *.exe hello libtcc_test vla_test tcctest[1234]
|
||||
rm -f ex? tcc_g weaktest.*.txt *.def
|
||||
@$(MAKE) -C tests2 $@
|
||||
@$(MAKE) -C pp $@
|
||||
|
||||
# silent clean, used before running tests
|
||||
clean-s:
|
||||
|
@ -5,23 +5,6 @@ VPATH = $(SRC)
|
||||
|
||||
TESTS = $(patsubst %.c,%.test,$(sort $(notdir $(wildcard $(SRC)/*.c))))
|
||||
|
||||
# 34_array_assignment.test -- array assignment is not in C standard
|
||||
SKIP = 34_array_assignment.test
|
||||
|
||||
# some tests do not pass on all platforms, remove them for now
|
||||
ifeq ($(CONFIG_arm_eabi),yes) # not ARM soft-float
|
||||
SKIP += 22_floating_point.test
|
||||
endif
|
||||
ifeq ($(TARGETOS),Darwin)
|
||||
SKIP += 40_stdio.test
|
||||
endif
|
||||
ifeq ($(ARCH),x86_64)
|
||||
SKIP += 73_arm64.test
|
||||
endif
|
||||
ifeq (,$(filter i386 x86_64,$(ARCH)))
|
||||
SKIP += 85_asm-outside-function.test
|
||||
endif
|
||||
|
||||
# Some tests might need arguments
|
||||
ARGS =
|
||||
31_args.test : ARGS = arg1 arg2 arg3 arg4 arg5
|
||||
@ -42,6 +25,22 @@ ifeq (-$(findstring arm,$(ARCH))-,-arm-)
|
||||
FILTER += 2>&1 | grep -v 'warning: soft float ABI currently not supported'
|
||||
endif
|
||||
|
||||
# some tests do not pass on all platforms, remove them for now
|
||||
SKIP = 34_array_assignment.test # array assignment is not in C standard
|
||||
ifeq ($(CONFIG_arm_eabi),yes) # not ARM soft-float
|
||||
SKIP += 22_floating_point.test
|
||||
endif
|
||||
ifdef CONFIG_OSX
|
||||
SKIP += 40_stdio.test 42_function_pointer.test
|
||||
FLAGS += -w
|
||||
endif
|
||||
ifeq ($(ARCH),x86_64)
|
||||
SKIP += 73_arm64.test
|
||||
endif
|
||||
ifeq (,$(filter i386 x86_64,$(ARCH)))
|
||||
SKIP += 85_asm-outside-function.test
|
||||
endif
|
||||
|
||||
all test: $(filter-out $(SKIP),$(TESTS))
|
||||
|
||||
%.test: %.c %.expect
|
||||
|
@ -5,7 +5,7 @@
|
||||
@echo off
|
||||
setlocal
|
||||
|
||||
set CC=gcc -Os -s
|
||||
set CC=gcc -Os -s -static
|
||||
set /p VERSION= < ..\VERSION
|
||||
set INST=
|
||||
set DOC=no
|
||||
|
@ -165,5 +165,6 @@ typedef struct localeinfo_struct _locale_tstruct,*_locale_t;
|
||||
#define __C89_NAMELESS
|
||||
#define __MINGW_EXTENSION
|
||||
#define WINAPI_FAMILY_PARTITION(X) 1
|
||||
#define MINGW_HAS_SECURE_API
|
||||
|
||||
#endif /* __MINGW_H */
|
||||
|
Loading…
Reference in New Issue
Block a user