From 32a4962593d6a2006cdd725480124717e7f5377d Mon Sep 17 00:00:00 2001 From: grischka Date: Tue, 21 Jan 2014 13:25:14 +0100 Subject: [PATCH] tcctest: add back testXb (self compile with -b) - Thanks to Kirill "tcc -b itself" should work now (was removed in d5f4df09ff4a84dda5b03525285f03be7723376b) Also: - tests/Makefile: - fix spurious --I from 767410b8750b45d63805b45ca1a2cf34d7cb4923 - lookup boundtest.c via VPATH (for out-of-tree build) - test[123]b?: fail on diff error - Windows: test3 now works (from e31579b0769e1f9c0947d12e83316d1149307b1a) - abitest: a libtcc.a made by gcc is not usable for tcc on WIndows - using source instead (libtcc.c) - tccpe: - avoid gcc warning (x86_64) --- Makefile | 4 ++-- tccpe.c | 2 +- tests/Makefile | 40 ++++++++++++++++++++++------------------ 3 files changed, 25 insertions(+), 21 deletions(-) diff --git a/Makefile b/Makefile index 78e67f7..39f10ba 100644 --- a/Makefile +++ b/Makefile @@ -346,8 +346,8 @@ tcc-doc.info: tcc-doc.texi # in tests subdir export LIBTCC1 -%est: - $(MAKE) -C tests $@ "PROGS_CROSS=$(PROGS_CROSS)" +test test% %test : + $(MAKE) -C tests $@ 'PROGS_CROSS=$(PROGS_CROSS)' clean: rm -vf $(PROGS) tcc_p$(EXESUF) tcc.pod *~ *.o *.a *.so* *.out *.exe libtcc_test$(EXESUF) diff --git a/tccpe.c b/tccpe.c index ed7cb82..f4a58f7 100644 --- a/tccpe.c +++ b/tccpe.c @@ -1803,7 +1803,7 @@ static void pe_add_runtime(TCCState *s1, struct pe_info *pe) s1->runtime_main = start_symbol; #endif } else { - pe->start_addr = (DWORD)tcc_get_symbol_err(s1, start_symbol); + pe->start_addr = (DWORD)(uintptr_t)tcc_get_symbol_err(s1, start_symbol); } pe->type = pe_type; diff --git a/tests/Makefile b/tests/Makefile index 62e4f88..4d99a46 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -5,7 +5,7 @@ TOP = .. include $(TOP)/Makefile SRCDIR = $(top_srcdir)/tests -VPATH = $(SRCDIR) +VPATH = $(SRCDIR) $(top_srcdir) # what tests to run TESTS = \ @@ -13,27 +13,30 @@ TESTS = \ hello-run \ libtest \ test3 \ + $(BTESTS) \ abitest \ vla_test-run \ moretests + +BTESTS = test1b test3b btest + ifdef CONFIG_CROSS -TESTS += hello-cross + TESTS += hello-cross endif # test4 -- problem with -static # asmtest -- minor differences with gcc # btest -- works on i386 (including win32) -# test3 -- win32 does not know how to printf long doubles # bounds-checking is supported only on i386 ifneq ($(ARCH),i386) - TESTS := $(filter-out btest,$(TESTS)) + TESTS := $(filter-out $(BTESTS),$(TESTS)) endif ifdef CONFIG_WIN32 - TESTS := w32-prep $(filter-out test3,$(TESTS)) + TESTS := w32-prep $(filter-out $(BTESTS),$(TESTS)) endif ifeq ($(TARGETOS),Darwin) - TESTS := $(filter-out hello-exe test3 btest,$(TESTS)) + TESTS := $(filter-out hello-exe test3 $(BTESTS),$(TESTS)) endif ifeq ($(ARCH),i386) else ifneq ($(ARCH),x86-64) @@ -53,7 +56,7 @@ endif # run local version of tcc with local libraries and includes TCCFLAGS = -B$(TOP) -I$(TOP) -I$(top_srcdir) -I$(top_srcdir)/include ifdef CONFIG_WIN32 - TCCFLAGS = -B$(top_srcdir)/win32 --I$(top_srcdir) -I$(top_srcdir)/include -I$(TOP) -L$(TOP) + TCCFLAGS = -B$(top_srcdir)/win32 -I$(top_srcdir) -I$(top_srcdir)/include -I$(TOP) -L$(TOP) endif XTCCFLAGS = -B$(TOP) -B$(top_srcdir)/win32 -I$(TOP) -I$(top_srcdir) -I$(top_srcdir)/include @@ -101,28 +104,29 @@ w32-prep: cp ../libtcc1.a ../lib # test.ref - generate using gcc -# copy only tcclib.h so GCC's stddef and stdarg will be used test.ref: tcctest.c gcc -o tcctest.gcc $< -I$(top_srcdir) $(CPPFLAGS) -w $(CFLAGS) $(NATIVE_DEFINES) -std=gnu99 -O0 -fno-omit-frame-pointer $(LDFLAGS) ./tcctest.gcc > $@ # auto test -test1: tcctest.c test.ref +test1 test1b: tcctest.c test.ref @echo ------------ $@ ------------ $(TCC) -run $< > test.out1 - @if diff -u test.ref test.out1 ; then echo "Auto Test OK"; fi + @diff -u test.ref test.out1 && echo "Auto Test OK" # iterated test2 (compile tcc then compile tcctest.c !) -test2: tcctest.c test.ref +test2 test2b: tcctest.c test.ref @echo ------------ $@ ------------ $(TCC) $(RUN_TCC) $(RUN_TCC) -run $< > test.out2 - @if diff -u test.ref test.out2 ; then echo "Auto Test2 OK"; fi + @diff -u test.ref test.out2 && echo "Auto Test2 OK" # iterated test3 (compile tcc then compile tcc then compile tcctest.c !) -test3: tcctest.c test.ref +test3 test3b: tcctest.c test.ref @echo ------------ $@ ------------ $(TCC) $(RUN_TCC) $(RUN_TCC) $(RUN_TCC) -run $< > test.out3 - @if diff -u test.ref test.out3 ; then echo "Auto Test3 OK"; fi + @diff -u test.ref test.out3 && echo "Auto Test3 OK" + +test%b : TCCFLAGS += -b # binary output test test4: tcctest.c test.ref @@ -153,7 +157,7 @@ btest: boundtest.c @echo ------------ $@ ------------ @for i in $(BOUNDS_OK); do \ echo ; echo --- boundtest $$i ---; \ - if $(TCC) -b -run boundtest.c $$i ; then \ + if $(TCC) -b -run $< $$i ; then \ echo succeded as expected; \ else\ echo Failed positive test $$i ; exit 1 ; \ @@ -161,7 +165,7 @@ btest: boundtest.c done ;\ for i in $(BOUNDS_FAIL); do \ echo ; echo --- boundtest $$i ---; \ - if $(TCC) -b -run boundtest.c $$i ; then \ + if $(TCC) -b -run $< $$i ; then \ echo Failed negative test $$i ; exit 1 ;\ else\ echo failed as expected; \ @@ -203,8 +207,8 @@ asmtest: asmtest.ref abitest-cc$(EXESUF): abitest.c $(top_builddir)/$(LIBTCC) $(CC) -o $@ $^ $(CPPFLAGS) $(CFLAGS) $(NATIVE_DEFINES) $(LIBS) $(LINK_LIBTCC) $(LDFLAGS) -I$(top_srcdir) -abitest-tcc$(EXESUF): abitest.c $(top_builddir)/$(LIBTCC) - $(TCC) -o $@ $^ $(CPPFLAGS) $(CFLAGS) $(NATIVE_DEFINES) $(LIBS) $(LINK_LIBTCC) $(LDFLAGS) -I$(top_srcdir) +abitest-tcc$(EXESUF): abitest.c libtcc.c + $(TCC) -o $@ $^ $(CPPFLAGS) $(CFLAGS) $(NATIVE_DEFINES) -DONE_SOURCE $(LIBS) $(LDFLAGS) -I$(top_srcdir) abitest: abitest-cc$(EXESUF) abitest-tcc$(EXESUF) @echo ------------ $@ ------------