misc. fixes
- tccgen: error out for cast to void, as in void foo(void) { return 1; } This avoids an assertion failure in x86_64-gen.c, also. also fix tests2/03_struct.c accordingly - Error: "memory full" - be more specific - Makefiles: remove circular dependencies, lookup tcctest.c from VPATH - tcc.h: cleanup lib, include, crt and libgcc search paths" avoid duplication or trailing slashes with no CONFIG_MULTIARCHDIR (as from9382d6f1a0
) - tcc.h: remove ";{B}" from PE search path ince5e12c2f9
James Lyon wrote: "... I'm not sure this is the right way to fix this problem." And the answer is: No, please. (copying libtcc1.a for tests instead) - win32/build_tcc.bat: do not move away a versioned file
This commit is contained in:
parent
d443644de3
commit
2bd0daabbe
10 changed files with 46 additions and 54 deletions
3
Makefile
3
Makefile
|
@ -362,9 +362,6 @@ tar: tcc-doc.html
|
||||||
rm -rf $(TCC-VERSION)
|
rm -rf $(TCC-VERSION)
|
||||||
git reset
|
git reset
|
||||||
|
|
||||||
Makefile: $(top_srcdir)/Makefile
|
|
||||||
cp $< $@
|
|
||||||
|
|
||||||
.PHONY: all clean tar distclean install uninstall FORCE
|
.PHONY: all clean tar distclean install uninstall FORCE
|
||||||
|
|
||||||
endif # ifeq ($(TOP),.)
|
endif # ifeq ($(TOP),.)
|
||||||
|
|
|
@ -111,6 +111,3 @@ $(DIR)/exists :
|
||||||
|
|
||||||
clean :
|
clean :
|
||||||
rm -rfv i386-win32 x86_64-win32 i386 x86_64
|
rm -rfv i386-win32 x86_64-win32 i386 x86_64
|
||||||
|
|
||||||
Makefile: $(top_srcdir)/lib/Makefile
|
|
||||||
cp $< $@
|
|
||||||
|
|
4
libtcc.c
4
libtcc.c
|
@ -214,7 +214,7 @@ PUB_FUNC void *tcc_malloc(unsigned long size)
|
||||||
void *ptr;
|
void *ptr;
|
||||||
ptr = malloc(size);
|
ptr = malloc(size);
|
||||||
if (!ptr && size)
|
if (!ptr && size)
|
||||||
tcc_error("memory full");
|
tcc_error("memory full (malloc)");
|
||||||
#ifdef MEM_DEBUG
|
#ifdef MEM_DEBUG
|
||||||
mem_cur_size += malloc_usable_size(ptr);
|
mem_cur_size += malloc_usable_size(ptr);
|
||||||
if (mem_cur_size > mem_max_size)
|
if (mem_cur_size > mem_max_size)
|
||||||
|
@ -239,7 +239,7 @@ PUB_FUNC void *tcc_realloc(void *ptr, unsigned long size)
|
||||||
#endif
|
#endif
|
||||||
ptr1 = realloc(ptr, size);
|
ptr1 = realloc(ptr, size);
|
||||||
if (!ptr1 && size)
|
if (!ptr1 && size)
|
||||||
tcc_error("memory full");
|
tcc_error("memory full (realloc)");
|
||||||
#ifdef MEM_DEBUG
|
#ifdef MEM_DEBUG
|
||||||
/* NOTE: count not correct if alloc error, but not critical */
|
/* NOTE: count not correct if alloc error, but not critical */
|
||||||
mem_cur_size += malloc_usable_size(ptr1);
|
mem_cur_size += malloc_usable_size(ptr1);
|
||||||
|
|
30
tcc.h
30
tcc.h
|
@ -169,13 +169,18 @@
|
||||||
#ifndef CONFIG_LDDIR
|
#ifndef CONFIG_LDDIR
|
||||||
# define CONFIG_LDDIR "lib"
|
# define CONFIG_LDDIR "lib"
|
||||||
#endif
|
#endif
|
||||||
#ifndef CONFIG_MULTIARCHDIR
|
|
||||||
#define CONFIG_MULTIARCHDIR
|
#ifdef CONFIG_MULTIARCHDIR
|
||||||
|
# define USE_MUADIR(s) s "/" CONFIG_MULTIARCHDIR
|
||||||
|
# define ALSO_MUADIR(s) s "/" CONFIG_MULTIARCHDIR ":" s
|
||||||
|
#else
|
||||||
|
# define USE_MUADIR(s) s
|
||||||
|
# define ALSO_MUADIR(s) s
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* path to find crt1.o, crti.o and crtn.o */
|
/* path to find crt1.o, crti.o and crtn.o */
|
||||||
#ifndef CONFIG_TCC_CRTPREFIX
|
#ifndef CONFIG_TCC_CRTPREFIX
|
||||||
# define CONFIG_TCC_CRTPREFIX CONFIG_SYSROOT "/usr/" CONFIG_LDDIR "/" CONFIG_MULTIARCHDIR
|
# define CONFIG_TCC_CRTPREFIX USE_MUADIR(CONFIG_SYSROOT "/usr/" CONFIG_LDDIR)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Below: {B} is substituted by CONFIG_TCCDIR (rsp. -B option) */
|
/* Below: {B} is substituted by CONFIG_TCCDIR (rsp. -B option) */
|
||||||
|
@ -186,10 +191,8 @@
|
||||||
# define CONFIG_TCC_SYSINCLUDEPATHS "{B}/include;{B}/include/winapi"
|
# define CONFIG_TCC_SYSINCLUDEPATHS "{B}/include;{B}/include/winapi"
|
||||||
# else
|
# else
|
||||||
# define CONFIG_TCC_SYSINCLUDEPATHS \
|
# define CONFIG_TCC_SYSINCLUDEPATHS \
|
||||||
CONFIG_SYSROOT "/usr/local/include/" CONFIG_MULTIARCHDIR \
|
ALSO_MUADIR(CONFIG_SYSROOT "/usr/local/include") \
|
||||||
":" CONFIG_SYSROOT "/usr/local/include" \
|
":" ALSO_MUADIR(CONFIG_SYSROOT "/usr/include") \
|
||||||
":" CONFIG_SYSROOT "/usr/include/" CONFIG_MULTIARCHDIR \
|
|
||||||
":" CONFIG_SYSROOT "/usr/include" \
|
|
||||||
":" "{B}/include"
|
":" "{B}/include"
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
@ -197,15 +200,12 @@
|
||||||
/* library search paths */
|
/* library search paths */
|
||||||
#ifndef CONFIG_TCC_LIBPATHS
|
#ifndef CONFIG_TCC_LIBPATHS
|
||||||
# ifdef TCC_TARGET_PE
|
# ifdef TCC_TARGET_PE
|
||||||
# define CONFIG_TCC_LIBPATHS "{B}/lib;{B}"
|
# define CONFIG_TCC_LIBPATHS "{B}/lib"
|
||||||
# else
|
# else
|
||||||
# define CONFIG_TCC_LIBPATHS \
|
# define CONFIG_TCC_LIBPATHS \
|
||||||
CONFIG_SYSROOT "/usr/" CONFIG_LDDIR "/" CONFIG_MULTIARCHDIR \
|
ALSO_MUADIR(CONFIG_SYSROOT "/usr/" CONFIG_LDDIR) \
|
||||||
":" CONFIG_SYSROOT "/usr/" CONFIG_LDDIR \
|
":" ALSO_MUADIR(CONFIG_SYSROOT "/" CONFIG_LDDIR) \
|
||||||
":" CONFIG_SYSROOT "/" CONFIG_LDDIR "/" CONFIG_MULTIARCHDIR \
|
":" ALSO_MUADIR(CONFIG_SYSROOT "/usr/local/" CONFIG_LDDIR)
|
||||||
":" CONFIG_SYSROOT "/" CONFIG_LDDIR \
|
|
||||||
":" CONFIG_SYSROOT "/usr/local/" CONFIG_LDDIR "/" CONFIG_MULTIARCHDIR \
|
|
||||||
":" CONFIG_SYSROOT "/usr/local/" CONFIG_LDDIR
|
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -237,7 +237,7 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* library to use with CONFIG_USE_LIBGCC instead of libtcc1.a */
|
/* library to use with CONFIG_USE_LIBGCC instead of libtcc1.a */
|
||||||
#define TCC_LIBGCC CONFIG_SYSROOT "/" CONFIG_LDDIR "/" CONFIG_MULTIARCHDIR "/libgcc_s.so.1"
|
#define TCC_LIBGCC USE_MUADIR(CONFIG_SYSROOT "/" CONFIG_LDDIR) "/libgcc_s.so.1"
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
/* include the target specific definitions */
|
/* include the target specific definitions */
|
||||||
|
|
8
tccgen.c
8
tccgen.c
|
@ -309,7 +309,7 @@ static void vsetc(CType *type, int r, CValue *vc)
|
||||||
int v;
|
int v;
|
||||||
|
|
||||||
if (vtop >= vstack + (VSTACK_SIZE - 1))
|
if (vtop >= vstack + (VSTACK_SIZE - 1))
|
||||||
tcc_error("memory full");
|
tcc_error("memory full (vstack)");
|
||||||
/* cannot let cpu flags if other instruction are generated. Also
|
/* cannot let cpu flags if other instruction are generated. Also
|
||||||
avoid leaving VT_JMP anywhere except on the top of the stack
|
avoid leaving VT_JMP anywhere except on the top of the stack
|
||||||
because it would complicate the code generator. */
|
because it would complicate the code generator. */
|
||||||
|
@ -483,7 +483,7 @@ ST_FUNC void vswap(void)
|
||||||
ST_FUNC void vpushv(SValue *v)
|
ST_FUNC void vpushv(SValue *v)
|
||||||
{
|
{
|
||||||
if (vtop >= vstack + (VSTACK_SIZE - 1))
|
if (vtop >= vstack + (VSTACK_SIZE - 1))
|
||||||
tcc_error("memory full");
|
tcc_error("memory full (vstack)");
|
||||||
vtop++;
|
vtop++;
|
||||||
*vtop = *v;
|
*vtop = *v;
|
||||||
}
|
}
|
||||||
|
@ -2348,8 +2348,8 @@ static void gen_assign_cast(CType *dt)
|
||||||
st = &vtop->type; /* source type */
|
st = &vtop->type; /* source type */
|
||||||
dbt = dt->t & VT_BTYPE;
|
dbt = dt->t & VT_BTYPE;
|
||||||
sbt = st->t & VT_BTYPE;
|
sbt = st->t & VT_BTYPE;
|
||||||
if (sbt == VT_VOID)
|
if (sbt == VT_VOID || dbt == VT_VOID)
|
||||||
tcc_error("Cannot assign void value");
|
tcc_error("cannot cast from/to void");
|
||||||
if (dt->t & VT_CONSTANT)
|
if (dt->t & VT_CONSTANT)
|
||||||
tcc_warning("assignment of read-only location");
|
tcc_warning("assignment of read-only location");
|
||||||
switch(dbt) {
|
switch(dbt) {
|
||||||
|
|
4
tccpp.c
4
tccpp.c
|
@ -197,7 +197,7 @@ static TokenSym *tok_alloc_new(TokenSym **pts, const char *str, int len)
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (tok_ident >= SYM_FIRST_ANOM)
|
if (tok_ident >= SYM_FIRST_ANOM)
|
||||||
tcc_error("memory full");
|
tcc_error("memory full (symbols)");
|
||||||
|
|
||||||
/* expand token table if needed */
|
/* expand token table if needed */
|
||||||
i = tok_ident - TOK_IDENT;
|
i = tok_ident - TOK_IDENT;
|
||||||
|
@ -1528,7 +1528,7 @@ include_done:
|
||||||
c = (define_find(tok) != 0) ^ c;
|
c = (define_find(tok) != 0) ^ c;
|
||||||
do_if:
|
do_if:
|
||||||
if (s1->ifdef_stack_ptr >= s1->ifdef_stack + IFDEF_STACK_SIZE)
|
if (s1->ifdef_stack_ptr >= s1->ifdef_stack + IFDEF_STACK_SIZE)
|
||||||
tcc_error("memory full");
|
tcc_error("memory full (ifdef)");
|
||||||
*s1->ifdef_stack_ptr++ = c;
|
*s1->ifdef_stack_ptr++ = c;
|
||||||
goto test_skip;
|
goto test_skip;
|
||||||
case TOK_ELSE:
|
case TOK_ELSE:
|
||||||
|
|
|
@ -27,7 +27,7 @@ ifneq ($(ARCH),i386)
|
||||||
TESTS := $(filter-out btest,$(TESTS))
|
TESTS := $(filter-out btest,$(TESTS))
|
||||||
endif
|
endif
|
||||||
ifdef CONFIG_WIN32
|
ifdef CONFIG_WIN32
|
||||||
TESTS := $(filter-out test3,$(TESTS))
|
TESTS := w32-prep $(filter-out test3,$(TESTS))
|
||||||
endif
|
endif
|
||||||
ifeq ($(TARGETOS),Darwin)
|
ifeq ($(TARGETOS),Darwin)
|
||||||
TESTS := $(filter-out hello-exe test3 btest,$(TESTS))
|
TESTS := $(filter-out hello-exe test3 btest,$(TESTS))
|
||||||
|
@ -84,6 +84,9 @@ moretests:
|
||||||
@echo ------------ $@ ------------
|
@echo ------------ $@ ------------
|
||||||
$(MAKE) -C tests2
|
$(MAKE) -C tests2
|
||||||
|
|
||||||
|
w32-prep:
|
||||||
|
cp ../libtcc1.a ../lib
|
||||||
|
|
||||||
# test.ref - generate using gcc
|
# test.ref - generate using gcc
|
||||||
# copy only tcclib.h so GCC's stddef and stdarg will be used
|
# copy only tcclib.h so GCC's stddef and stdarg will be used
|
||||||
test.ref: tcctest.c
|
test.ref: tcctest.c
|
||||||
|
@ -91,41 +94,41 @@ test.ref: tcctest.c
|
||||||
./tcctest.gcc > $@
|
./tcctest.gcc > $@
|
||||||
|
|
||||||
# auto test
|
# auto test
|
||||||
test1: test.ref
|
test1: tcctest.c test.ref
|
||||||
@echo ------------ $@ ------------
|
@echo ------------ $@ ------------
|
||||||
$(TCC) -run $(SRCDIR)/tcctest.c > test.out1
|
$(TCC) -run $< > test.out1
|
||||||
@if diff -u test.ref test.out1 ; then echo "Auto Test OK"; fi
|
@if diff -u test.ref test.out1 ; then echo "Auto Test OK"; fi
|
||||||
|
|
||||||
# iterated test2 (compile tcc then compile tcctest.c !)
|
# iterated test2 (compile tcc then compile tcctest.c !)
|
||||||
test2: test.ref
|
test2: tcctest.c test.ref
|
||||||
@echo ------------ $@ ------------
|
@echo ------------ $@ ------------
|
||||||
$(TCC) $(RUN_TCC) $(RUN_TCC) -run $(SRCDIR)/tcctest.c > test.out2
|
$(TCC) $(RUN_TCC) $(RUN_TCC) -run $< > test.out2
|
||||||
@if diff -u test.ref test.out2 ; then echo "Auto Test2 OK"; fi
|
@if diff -u test.ref test.out2 ; then echo "Auto Test2 OK"; fi
|
||||||
|
|
||||||
# iterated test3 (compile tcc then compile tcc then compile tcctest.c !)
|
# iterated test3 (compile tcc then compile tcc then compile tcctest.c !)
|
||||||
test3: test.ref
|
test3: tcctest.c test.ref
|
||||||
@echo ------------ $@ ------------
|
@echo ------------ $@ ------------
|
||||||
$(TCC) $(RUN_TCC) $(RUN_TCC) $(RUN_TCC) -run $(SRCDIR)/tcctest.c > test.out3
|
$(TCC) $(RUN_TCC) $(RUN_TCC) $(RUN_TCC) -run $< > test.out3
|
||||||
@if diff -u test.ref test.out3 ; then echo "Auto Test3 OK"; fi
|
@if diff -u test.ref test.out3 ; then echo "Auto Test3 OK"; fi
|
||||||
|
|
||||||
# binary output test
|
# binary output test
|
||||||
test4: test.ref
|
test4: tcctest.c test.ref
|
||||||
@echo ------------ $@ ------------
|
@echo ------------ $@ ------------
|
||||||
# object + link output
|
# object + link output
|
||||||
$(TCC) -c -o tcctest3.o $(SRCDIR)/tcctest.c
|
$(TCC) -c -o tcctest3.o $<
|
||||||
$(TCC) -o tcctest3 tcctest3.o
|
$(TCC) -o tcctest3 tcctest3.o
|
||||||
./tcctest3 > test3.out
|
./tcctest3 > test3.out
|
||||||
@if diff -u test.ref test3.out ; then echo "Object Auto Test OK"; fi
|
@if diff -u test.ref test3.out ; then echo "Object Auto Test OK"; fi
|
||||||
# dynamic output
|
# dynamic output
|
||||||
$(TCC) -o tcctest1 $(SRCDIR)/tcctest.c
|
$(TCC) -o tcctest1 $<
|
||||||
./tcctest1 > test1.out
|
./tcctest1 > test1.out
|
||||||
@if diff -u test.ref test1.out ; then echo "Dynamic Auto Test OK"; fi
|
@if diff -u test.ref test1.out ; then echo "Dynamic Auto Test OK"; fi
|
||||||
# dynamic output + bound check
|
# dynamic output + bound check
|
||||||
$(TCC) -b -o tcctest4 $(SRCDIR)/tcctest.c
|
$(TCC) -b -o tcctest4 $<
|
||||||
./tcctest4 > test4.out
|
./tcctest4 > test4.out
|
||||||
@if diff -u test.ref test4.out ; then echo "BCheck Auto Test OK"; fi
|
@if diff -u test.ref test4.out ; then echo "BCheck Auto Test OK"; fi
|
||||||
# static output
|
# static output
|
||||||
$(TCC) -static -o tcctest2 $(SRCDIR)/tcctest.c
|
$(TCC) -static -o tcctest2 $<
|
||||||
./tcctest2 > test2.out
|
./tcctest2 > test2.out
|
||||||
@if diff -u test.ref test2.out ; then echo "Static Auto Test OK"; fi
|
@if diff -u test.ref test2.out ; then echo "Static Auto Test OK"; fi
|
||||||
|
|
||||||
|
@ -161,9 +164,9 @@ speedtest: ex2 ex3
|
||||||
time ./ex3 35
|
time ./ex3 35
|
||||||
time $(TCC) -run $(top_srcdir)/examples/ex3.c 35
|
time $(TCC) -run $(top_srcdir)/examples/ex3.c 35
|
||||||
|
|
||||||
weaktest: test.ref
|
weaktest: tcctest.c test.ref
|
||||||
$(TCC) -c tcctest.c -o weaktest.tcc.o $(CPPFLAGS) $(CFLAGS)
|
$(TCC) -c $< -o weaktest.tcc.o $(CPPFLAGS) $(CFLAGS)
|
||||||
$(CC) -c tcctest.c -o weaktest.gcc.o -I. $(CPPFLAGS) -w $(CFLAGS)
|
$(CC) -c $< -o weaktest.gcc.o -I. $(CPPFLAGS) -w $(CFLAGS)
|
||||||
objdump -t weaktest.tcc.o | grep ' w ' | sed -e 's/.* \([a-zA-Z0-9_]*\)$$/\1/' | LC_ALL=C sort > weaktest.tcc.o.txt
|
objdump -t weaktest.tcc.o | grep ' w ' | sed -e 's/.* \([a-zA-Z0-9_]*\)$$/\1/' | LC_ALL=C sort > weaktest.tcc.o.txt
|
||||||
objdump -t weaktest.gcc.o | grep ' w ' | sed -e 's/.* \([a-zA-Z0-9_]*\)$$/\1/' | LC_ALL=C sort > weaktest.gcc.o.txt
|
objdump -t weaktest.gcc.o | grep ' w ' | sed -e 's/.* \([a-zA-Z0-9_]*\)$$/\1/' | LC_ALL=C sort > weaktest.gcc.o.txt
|
||||||
diff weaktest.gcc.o.txt weaktest.tcc.o.txt && echo "Weak Auto Test OK"
|
diff weaktest.gcc.o.txt weaktest.tcc.o.txt && echo "Weak Auto Test OK"
|
||||||
|
@ -220,7 +223,5 @@ cache: tcc_g
|
||||||
clean:
|
clean:
|
||||||
$(MAKE) -C tests2 $@
|
$(MAKE) -C tests2 $@
|
||||||
rm -vf *~ *.o *.a *.bin *.i *.ref *.out *.out? *.out?b *.gcc *.exe \
|
rm -vf *~ *.o *.a *.bin *.i *.ref *.out *.out? *.out?b *.gcc *.exe \
|
||||||
hello libtcc_test tcctest[1234] ex? tcc_g tcclib.h
|
hello libtcc_test tcctest[1234] ex? tcc_g tcclib.h \
|
||||||
|
../lib/libtcc1.a
|
||||||
Makefile: $(SRCDIR)/Makefile
|
|
||||||
cp $< $@
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ struct fred
|
||||||
int natasha;
|
int natasha;
|
||||||
};
|
};
|
||||||
|
|
||||||
void main()
|
int main()
|
||||||
{
|
{
|
||||||
struct fred bloggs;
|
struct fred bloggs;
|
||||||
|
|
||||||
|
|
|
@ -96,6 +96,3 @@ all test: $(TESTS)
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -vf fred.txt *.output
|
rm -vf fred.txt *.output
|
||||||
|
|
||||||
Makefile: $(top_srcdir)/tests/tests2/Makefile
|
|
||||||
cp $< $@
|
|
||||||
|
|
|
@ -63,5 +63,5 @@ del *.o
|
||||||
echo>..\config.texi @set VERSION %VERSION%
|
echo>..\config.texi @set VERSION %VERSION%
|
||||||
if not exist doc md doc
|
if not exist doc md doc
|
||||||
makeinfo --html --no-split -o doc\tcc-doc.html ../tcc-doc.texi
|
makeinfo --html --no-split -o doc\tcc-doc.html ../tcc-doc.texi
|
||||||
if exist tcc-win32.txt move tcc-win32.txt doc\
|
copy tcc-win32.txt doc
|
||||||
copy ..\tests\libtcc_test.c examples\
|
copy ..\tests\libtcc_test.c examples
|
||||||
|
|
Loading…
Reference in a new issue