2009-04-18 16:31:35 +04:00
|
|
|
#
|
|
|
|
# Tiny C Compiler Makefile - tests
|
|
|
|
#
|
|
|
|
|
2015-07-29 23:53:57 +03:00
|
|
|
TOP = ..
|
2012-06-27 21:04:27 +04:00
|
|
|
include $(TOP)/Makefile
|
2016-10-01 22:06:53 +03:00
|
|
|
VPATH = $(TOPSRC)/tests $(TOPSRC) $(TOP)
|
2017-04-25 22:01:54 +03:00
|
|
|
CFLAGS := $(filter-out -W% -g% -O%,$(CFLAGS)) -I$(TOPSRC) $(LDFLAGS)
|
2014-09-07 19:05:58 +04:00
|
|
|
|
2009-04-18 16:31:35 +04:00
|
|
|
# what tests to run
|
2013-02-05 17:27:38 +04:00
|
|
|
TESTS = \
|
2013-02-10 03:38:40 +04:00
|
|
|
hello-exe \
|
|
|
|
hello-run \
|
2013-02-05 17:27:38 +04:00
|
|
|
libtest \
|
2019-12-11 02:37:18 +03:00
|
|
|
libtest_mt \
|
2013-02-05 17:27:38 +04:00
|
|
|
test3 \
|
2016-12-19 00:05:42 +03:00
|
|
|
memtest \
|
2016-12-15 19:04:07 +03:00
|
|
|
dlltest \
|
2013-04-18 20:27:34 +04:00
|
|
|
abitest \
|
2017-11-22 19:57:43 +03:00
|
|
|
asm-c-connect-test \
|
2013-04-27 23:39:34 +04:00
|
|
|
vla_test-run \
|
2017-02-25 14:49:47 +03:00
|
|
|
cross-test \
|
2016-10-01 22:06:33 +03:00
|
|
|
tests2-dir \
|
|
|
|
pp-dir
|
2014-01-21 16:25:14 +04:00
|
|
|
|
bcheck cleanup
- revert Makefiles to state before last bcheck additions
Instead, just load bcheck.o explicitly if that is
what is wanted.
- move tcc_add_bcheck() to the <target>-link.c files and
remove revently added arguments. This function is to
support tccelf.c with linking, not for tccgen.c to
support compilation.
- remove -ba option: It said:
"-ba Enable better address checking with bounds checker"
Okay, if it is better then to have it is not an option.
- remove va_copy. It is C99 and we try to stay C89 in tinycc
when possible. For example, MS compilers do not have va_copy.
- win64: revert any 'fixes' to alloca
It was correct as it was before, except for bound_checking
where it was not implemented. This should now work too.
- remove parasitic filename:linenum features
Such feature is already present with rt_printline in
tccrun.c. If it doesn't work it can be fixed.
- revert changes to gen_bounded_ptr_add()
gen_bounded_ptr_add() was working as it should before
(mostly). For the sake of simplicity I switched it to
CDECL. Anyway, FASTCALL means SLOWCALL with tinycc.
In exchange you get one addition which is required for
bounds_cnecking function arguments. The important thing
is to check them *BEFORE* they are loaded into registers.
New function gbound_args() does that.
In any case, code instrumentation with the bounds-check
functions as such now seems to work flawlessly again,
which means when they are inserted as NOPs, any code that
tcc can compile, seems to behave just the same as without
them.
What these functions then do when fully enabled, is a
differnt story. I did not touch this.
2019-12-12 17:45:45 +03:00
|
|
|
BTESTS = btest test2b
|
2014-01-21 16:25:14 +04:00
|
|
|
|
2019-12-12 22:49:35 +03:00
|
|
|
# test4_static -- Not all relocation types are implemented yet.
|
2016-10-02 02:38:22 +03:00
|
|
|
# asmtest / asmtest2 -- minor differences with gcc
|
2009-04-18 16:31:35 +04:00
|
|
|
|
2019-12-12 22:49:35 +03:00
|
|
|
# bounds-checking is supported on i386 and x86_64 on linux and windows
|
2019-12-11 14:07:48 +03:00
|
|
|
ifeq ($(ARCH),i386)
|
|
|
|
TESTS += $(BTESTS)
|
|
|
|
endif
|
|
|
|
ifeq ($(ARCH),x86_64)
|
|
|
|
TESTS += $(BTESTS)
|
2012-11-21 09:47:23 +04:00
|
|
|
endif
|
2013-02-05 17:27:38 +04:00
|
|
|
ifdef CONFIG_WIN32
|
2019-12-11 14:07:48 +03:00
|
|
|
TESTS += $(BTESTS)
|
2012-06-27 21:04:27 +04:00
|
|
|
endif
|
2017-04-25 22:01:54 +03:00
|
|
|
ifdef CONFIG_OSX # -run only
|
|
|
|
TESTS := hello-run libtest tests2-dir pp-dir
|
2012-06-27 21:04:27 +04:00
|
|
|
endif
|
2017-02-20 20:58:08 +03:00
|
|
|
ifeq (,$(filter arm64 i386 x86_64,$(ARCH)))
|
2013-04-27 23:39:34 +04:00
|
|
|
TESTS := $(filter-out vla_test-run,$(TESTS))
|
|
|
|
endif
|
2015-03-04 09:52:47 +03:00
|
|
|
ifeq ($(CONFIG_arm_eabi),yes)
|
|
|
|
TESTS := $(filter-out test3,$(TESTS))
|
|
|
|
endif
|
2017-02-20 20:58:08 +03:00
|
|
|
ifeq (,$(filter i386 x86_64,$(ARCH)))
|
2017-11-22 19:57:43 +03:00
|
|
|
TESTS := $(filter-out dlltest asm-c-connect-test,$(TESTS))
|
2016-12-15 19:04:07 +03:00
|
|
|
endif
|
2017-05-13 09:59:06 +03:00
|
|
|
ifndef CONFIG_cross
|
2017-02-25 14:49:47 +03:00
|
|
|
TESTS := $(filter-out cross-%,$(TESTS))
|
|
|
|
endif
|
2009-04-18 16:31:35 +04:00
|
|
|
|
2017-12-12 19:57:20 +03:00
|
|
|
ifeq ($(OS),Windows_NT) # for libtcc_test to find libtcc.dll
|
|
|
|
PATH := $(CURDIR)/$(TOP)$(if $(findstring :\,$(PATH)),;,:)$(PATH)
|
2011-05-14 18:21:45 +04:00
|
|
|
endif
|
|
|
|
|
2019-12-12 03:52:50 +03:00
|
|
|
ifeq ($(ARCH),arm)
|
|
|
|
# tcctest refers to the alignment of functions, and with thumb mode
|
|
|
|
# the low bit of code addresses selects the mode, so the "alignment"
|
|
|
|
# of functions via bit masking comes out as 1. Just disable thumb.
|
|
|
|
test.ref: CFLAGS+=-marm
|
|
|
|
endif
|
|
|
|
|
2017-07-23 22:24:11 +03:00
|
|
|
RUN_TCC = $(NATIVE_DEFINES) -run $(TOPSRC)/tcc.c $(TCCFLAGS)
|
2016-10-01 22:06:33 +03:00
|
|
|
DISAS = objdump -d
|
2017-04-25 22:01:54 +03:00
|
|
|
DUMPTCC = (set -x; $(TOP)/tcc -vv; ldd $(TOP)/tcc; exit 1)
|
2016-10-01 22:06:33 +03:00
|
|
|
|
2019-03-14 16:59:27 +03:00
|
|
|
all test :
|
|
|
|
$(MAKE) clean-s
|
|
|
|
$(MAKE) $(TESTS)
|
2013-02-05 17:27:38 +04:00
|
|
|
|
2013-02-10 03:38:40 +04:00
|
|
|
hello-exe: ../examples/ex1.c
|
|
|
|
@echo ------------ $@ ------------
|
2017-04-25 22:01:54 +03:00
|
|
|
$(TCC) $< -o hello$(EXESUF) && ./hello$(EXESUF) || $(DUMPTCC)
|
2013-02-10 03:38:40 +04:00
|
|
|
|
|
|
|
hello-run: ../examples/ex1.c
|
2013-02-05 17:27:38 +04:00
|
|
|
@echo ------------ $@ ------------
|
2017-04-25 22:01:54 +03:00
|
|
|
$(TCC) -run $< || $(DUMPTCC)
|
2013-02-05 17:27:38 +04:00
|
|
|
|
2019-12-11 02:37:18 +03:00
|
|
|
libtes%: libtcc_tes%$(EXESUF)
|
2009-04-18 16:31:35 +04:00
|
|
|
@echo ------------ $@ ------------
|
2019-12-11 19:57:43 +03:00
|
|
|
./libtcc_tes$*$(EXESUF) $(TCCFLAGS) $(NATIVE_DEFINES)
|
2009-04-18 16:31:35 +04:00
|
|
|
|
2019-12-11 02:37:18 +03:00
|
|
|
libtcc_tes%$(EXESUF): libtcc_tes%.c $(LIBTCC)
|
2016-10-01 22:06:33 +03:00
|
|
|
$(CC) -o $@ $^ $(CFLAGS) $(LIBS)
|
2009-04-18 16:31:35 +04:00
|
|
|
|
tccpp: fix issues, add tests
* fix some macro expansion issues
* add some pp tests in tests/pp
* improved tcc -E output for better diff'ability
* remove -dD feature (quirky code, exotic feature,
didn't work well)
Based partially on ideas / researches from PipCet
Some issues remain with VA_ARGS macros (if used in a
rather tricky way).
Also, to keep it simple, the pp doesn't automtically
add any extra spaces to separate tokens which otherwise
would form wrong tokens if re-read from tcc -E output
(such as '+' '=') GCC does that, other compilers don't.
* cleanups
- #line 01 "file" / # 01 "file" processing
- #pragma comment(lib,"foo")
- tcc -E: forward some pragmas to output (pack, comment(lib))
- fix macro parameter list parsing mess from
a3fc54345949535524d01319e1ca6378b7c2c201
a715d7143d9d17da17e67fec6af1c01409a71a31
(some coffee might help, next time ;)
- introduce TOK_PPSTR - to have character constants as
written in the file (similar to TOK_PPNUM)
- allow '\' appear in macros
- new functions begin/end_macro to:
- fix switching macro levels during expansion
- allow unget_tok to unget more than one tok
- slight speedup by using bitflags in isidnum_table
Also:
- x86_64.c : fix decl after statements
- i386-gen,c : fix a vstack leak with VLA on windows
- configure/Makefile : build on windows (MSYS) was broken
- tcc_warning: fflush stderr to keep output order (win32)
2015-05-09 15:29:39 +03:00
|
|
|
%-dir:
|
2013-02-05 17:27:38 +04:00
|
|
|
@echo ------------ $@ ------------
|
tccpp: fix issues, add tests
* fix some macro expansion issues
* add some pp tests in tests/pp
* improved tcc -E output for better diff'ability
* remove -dD feature (quirky code, exotic feature,
didn't work well)
Based partially on ideas / researches from PipCet
Some issues remain with VA_ARGS macros (if used in a
rather tricky way).
Also, to keep it simple, the pp doesn't automtically
add any extra spaces to separate tokens which otherwise
would form wrong tokens if re-read from tcc -E output
(such as '+' '=') GCC does that, other compilers don't.
* cleanups
- #line 01 "file" / # 01 "file" processing
- #pragma comment(lib,"foo")
- tcc -E: forward some pragmas to output (pack, comment(lib))
- fix macro parameter list parsing mess from
a3fc54345949535524d01319e1ca6378b7c2c201
a715d7143d9d17da17e67fec6af1c01409a71a31
(some coffee might help, next time ;)
- introduce TOK_PPSTR - to have character constants as
written in the file (similar to TOK_PPNUM)
- allow '\' appear in macros
- new functions begin/end_macro to:
- fix switching macro levels during expansion
- allow unget_tok to unget more than one tok
- slight speedup by using bitflags in isidnum_table
Also:
- x86_64.c : fix decl after statements
- i386-gen,c : fix a vstack leak with VLA on windows
- configure/Makefile : build on windows (MSYS) was broken
- tcc_warning: fflush stderr to keep output order (win32)
2015-05-09 15:29:39 +03:00
|
|
|
$(MAKE) -k -C $*
|
2014-01-06 22:56:26 +04:00
|
|
|
|
2014-03-09 18:54:48 +04:00
|
|
|
# test.ref - generate using cc
|
2009-04-18 16:31:35 +04:00
|
|
|
test.ref: tcctest.c
|
2016-10-01 22:06:33 +03:00
|
|
|
$(CC) -o tcctest.gcc $< $(NATIVE_DEFINES) $(CFLAGS) -w -O0 -std=gnu99 -fno-omit-frame-pointer
|
|
|
|
./tcctest.gcc > $@
|
2009-04-18 16:31:35 +04:00
|
|
|
|
|
|
|
# auto test
|
2014-01-21 16:25:14 +04:00
|
|
|
test1 test1b: tcctest.c test.ref
|
2009-04-18 16:31:35 +04:00
|
|
|
@echo ------------ $@ ------------
|
2014-01-06 22:56:26 +04:00
|
|
|
$(TCC) -run $< > test.out1
|
2014-01-21 16:25:14 +04:00
|
|
|
@diff -u test.ref test.out1 && echo "Auto Test OK"
|
2009-04-18 16:31:35 +04:00
|
|
|
|
|
|
|
# iterated test2 (compile tcc then compile tcctest.c !)
|
2014-01-21 16:25:14 +04:00
|
|
|
test2 test2b: tcctest.c test.ref
|
2009-04-18 16:31:35 +04:00
|
|
|
@echo ------------ $@ ------------
|
2014-01-06 22:56:26 +04:00
|
|
|
$(TCC) $(RUN_TCC) $(RUN_TCC) -run $< > test.out2
|
2014-01-21 16:25:14 +04:00
|
|
|
@diff -u test.ref test.out2 && echo "Auto Test2 OK"
|
2009-04-18 16:31:35 +04:00
|
|
|
|
|
|
|
# iterated test3 (compile tcc then compile tcc then compile tcctest.c !)
|
2014-01-21 16:25:14 +04:00
|
|
|
test3 test3b: tcctest.c test.ref
|
2009-04-18 16:31:35 +04:00
|
|
|
@echo ------------ $@ ------------
|
2014-01-06 22:56:26 +04:00
|
|
|
$(TCC) $(RUN_TCC) $(RUN_TCC) $(RUN_TCC) -run $< > test.out3
|
2014-01-21 16:25:14 +04:00
|
|
|
@diff -u test.ref test.out3 && echo "Auto Test3 OK"
|
|
|
|
|
bcheck cleanup
- revert Makefiles to state before last bcheck additions
Instead, just load bcheck.o explicitly if that is
what is wanted.
- move tcc_add_bcheck() to the <target>-link.c files and
remove revently added arguments. This function is to
support tccelf.c with linking, not for tccgen.c to
support compilation.
- remove -ba option: It said:
"-ba Enable better address checking with bounds checker"
Okay, if it is better then to have it is not an option.
- remove va_copy. It is C99 and we try to stay C89 in tinycc
when possible. For example, MS compilers do not have va_copy.
- win64: revert any 'fixes' to alloca
It was correct as it was before, except for bound_checking
where it was not implemented. This should now work too.
- remove parasitic filename:linenum features
Such feature is already present with rt_printline in
tccrun.c. If it doesn't work it can be fixed.
- revert changes to gen_bounded_ptr_add()
gen_bounded_ptr_add() was working as it should before
(mostly). For the sake of simplicity I switched it to
CDECL. Anyway, FASTCALL means SLOWCALL with tinycc.
In exchange you get one addition which is required for
bounds_cnecking function arguments. The important thing
is to check them *BEFORE* they are loaded into registers.
New function gbound_args() does that.
In any case, code instrumentation with the bounds-check
functions as such now seems to work flawlessly again,
which means when they are inserted as NOPs, any code that
tcc can compile, seems to behave just the same as without
them.
What these functions then do when fully enabled, is a
differnt story. I did not touch this.
2019-12-12 17:45:45 +03:00
|
|
|
test%b : TCCFLAGS += -b
|
2009-04-18 16:31:35 +04:00
|
|
|
|
|
|
|
# binary output test
|
2014-01-06 22:56:26 +04:00
|
|
|
test4: tcctest.c test.ref
|
2009-04-18 16:31:35 +04:00
|
|
|
@echo ------------ $@ ------------
|
|
|
|
# object + link output
|
2014-01-06 22:56:26 +04:00
|
|
|
$(TCC) -c -o tcctest3.o $<
|
2009-04-18 16:31:35 +04:00
|
|
|
$(TCC) -o tcctest3 tcctest3.o
|
|
|
|
./tcctest3 > test3.out
|
|
|
|
@if diff -u test.ref test3.out ; then echo "Object Auto Test OK"; fi
|
2013-02-05 17:27:38 +04:00
|
|
|
# dynamic output
|
2014-01-06 22:56:26 +04:00
|
|
|
$(TCC) -o tcctest1 $<
|
2013-02-05 17:27:38 +04:00
|
|
|
./tcctest1 > test1.out
|
|
|
|
@if diff -u test.ref test1.out ; then echo "Dynamic Auto Test OK"; fi
|
2009-04-18 16:31:35 +04:00
|
|
|
# dynamic output + bound check
|
bcheck cleanup
- revert Makefiles to state before last bcheck additions
Instead, just load bcheck.o explicitly if that is
what is wanted.
- move tcc_add_bcheck() to the <target>-link.c files and
remove revently added arguments. This function is to
support tccelf.c with linking, not for tccgen.c to
support compilation.
- remove -ba option: It said:
"-ba Enable better address checking with bounds checker"
Okay, if it is better then to have it is not an option.
- remove va_copy. It is C99 and we try to stay C89 in tinycc
when possible. For example, MS compilers do not have va_copy.
- win64: revert any 'fixes' to alloca
It was correct as it was before, except for bound_checking
where it was not implemented. This should now work too.
- remove parasitic filename:linenum features
Such feature is already present with rt_printline in
tccrun.c. If it doesn't work it can be fixed.
- revert changes to gen_bounded_ptr_add()
gen_bounded_ptr_add() was working as it should before
(mostly). For the sake of simplicity I switched it to
CDECL. Anyway, FASTCALL means SLOWCALL with tinycc.
In exchange you get one addition which is required for
bounds_cnecking function arguments. The important thing
is to check them *BEFORE* they are loaded into registers.
New function gbound_args() does that.
In any case, code instrumentation with the bounds-check
functions as such now seems to work flawlessly again,
which means when they are inserted as NOPs, any code that
tcc can compile, seems to behave just the same as without
them.
What these functions then do when fully enabled, is a
differnt story. I did not touch this.
2019-12-12 17:45:45 +03:00
|
|
|
$(TCC) -b -o tcctest4 $<
|
2009-04-18 16:31:35 +04:00
|
|
|
./tcctest4 > test4.out
|
|
|
|
@if diff -u test.ref test4.out ; then echo "BCheck Auto Test OK"; fi
|
2019-12-12 22:49:35 +03:00
|
|
|
|
|
|
|
test4_static: tcctest.c test.ref
|
|
|
|
# static output.
|
2014-01-06 22:56:26 +04:00
|
|
|
$(TCC) -static -o tcctest2 $<
|
2013-02-05 17:27:38 +04:00
|
|
|
./tcctest2 > test2.out
|
|
|
|
@if diff -u test.ref test2.out ; then echo "Static Auto Test OK"; fi
|
2009-04-18 16:31:35 +04:00
|
|
|
|
2016-12-15 19:04:07 +03:00
|
|
|
# use tcc to create libtcc.so/.dll and the tcc(.exe) frontend and run them
|
|
|
|
dlltest:
|
|
|
|
@echo ------------ $@ ------------
|
2017-07-23 22:24:11 +03:00
|
|
|
$(TCC) $(NATIVE_DEFINES) -DLIBTCC_AS_DLL $(TOPSRC)/libtcc.c $(LIBS) -shared -o libtcc2$(DLLSUF)
|
|
|
|
$(TCC) $(NATIVE_DEFINES) -DONE_SOURCE=0 $(TOPSRC)/tcc.c libtcc2$(DLLSUF) $(LIBS) -Wl,-rpath=. -o tcc2$(EXESUF)
|
2016-12-20 20:05:33 +03:00
|
|
|
./tcc2$(EXESUF) $(TCCFLAGS) $(RUN_TCC) -run $(TOPSRC)/examples/ex1.c
|
2016-12-15 19:04:07 +03:00
|
|
|
ifndef CONFIG_WIN32
|
|
|
|
@echo ------------ $@ with PIC ------------
|
2017-07-23 22:24:11 +03:00
|
|
|
$(CC) $(CFLAGS) -fPIC $(NATIVE_DEFINES) -DLIBTCC_AS_DLL -c $(TOPSRC)/libtcc.c
|
2016-12-15 19:04:07 +03:00
|
|
|
$(TCC) libtcc.o $(LIBS) -shared -o libtcc2$(DLLSUF)
|
2017-07-23 22:24:11 +03:00
|
|
|
$(TCC) $(NATIVE_DEFINES) -DONE_SOURCE=0 $(TOPSRC)/tcc.c libtcc2$(DLLSUF) $(LIBS) -Wl,-rpath=. -o tcc2$(EXESUF)
|
2016-12-20 20:05:33 +03:00
|
|
|
./tcc2$(EXESUF) $(TCCFLAGS) $(RUN_TCC) -run $(TOPSRC)/examples/ex1.c
|
2016-12-15 19:04:07 +03:00
|
|
|
endif
|
|
|
|
@rm tcc2$(EXESUF) libtcc2$(DLLSUF)
|
|
|
|
|
2016-12-19 00:05:42 +03:00
|
|
|
memtest:
|
|
|
|
@echo ------------ $@ ------------
|
2017-07-23 22:24:11 +03:00
|
|
|
$(CC) $(CFLAGS) $(NATIVE_DEFINES) -DMEM_DEBUG=2 $(TOPSRC)/tcc.c $(LIBS) -o memtest-tcc$(EXESUF)
|
|
|
|
./memtest-tcc$(EXESUF) $(TCCFLAGS) $(NATIVE_DEFINES) $(TOPSRC)/tcc.c $(LIBS)
|
|
|
|
./memtest-tcc$(EXESUF) $(TCCFLAGS) $(NATIVE_DEFINES) -run $(TOPSRC)/tcc.c $(TCCFLAGS) $(TOPSRC)/tests/tcctest.c
|
2016-12-19 00:05:42 +03:00
|
|
|
|
2016-12-15 19:04:07 +03:00
|
|
|
|
2009-04-18 16:31:35 +04:00
|
|
|
# memory and bound check auto test
|
bcheck cleanup
- revert Makefiles to state before last bcheck additions
Instead, just load bcheck.o explicitly if that is
what is wanted.
- move tcc_add_bcheck() to the <target>-link.c files and
remove revently added arguments. This function is to
support tccelf.c with linking, not for tccgen.c to
support compilation.
- remove -ba option: It said:
"-ba Enable better address checking with bounds checker"
Okay, if it is better then to have it is not an option.
- remove va_copy. It is C99 and we try to stay C89 in tinycc
when possible. For example, MS compilers do not have va_copy.
- win64: revert any 'fixes' to alloca
It was correct as it was before, except for bound_checking
where it was not implemented. This should now work too.
- remove parasitic filename:linenum features
Such feature is already present with rt_printline in
tccrun.c. If it doesn't work it can be fixed.
- revert changes to gen_bounded_ptr_add()
gen_bounded_ptr_add() was working as it should before
(mostly). For the sake of simplicity I switched it to
CDECL. Anyway, FASTCALL means SLOWCALL with tinycc.
In exchange you get one addition which is required for
bounds_cnecking function arguments. The important thing
is to check them *BEFORE* they are loaded into registers.
New function gbound_args() does that.
In any case, code instrumentation with the bounds-check
functions as such now seems to work flawlessly again,
which means when they are inserted as NOPs, any code that
tcc can compile, seems to behave just the same as without
them.
What these functions then do when fully enabled, is a
differnt story. I did not touch this.
2019-12-12 17:45:45 +03:00
|
|
|
BOUNDS_OK = 1 4 8 10 14 16
|
2019-12-10 10:07:25 +03:00
|
|
|
BOUNDS_FAIL= 2 5 6 7 9 11 12 13 15 17
|
2009-04-18 16:31:35 +04:00
|
|
|
|
2013-02-05 17:27:38 +04:00
|
|
|
btest: boundtest.c
|
2009-04-18 16:31:35 +04:00
|
|
|
@echo ------------ $@ ------------
|
bcheck cleanup
- revert Makefiles to state before last bcheck additions
Instead, just load bcheck.o explicitly if that is
what is wanted.
- move tcc_add_bcheck() to the <target>-link.c files and
remove revently added arguments. This function is to
support tccelf.c with linking, not for tccgen.c to
support compilation.
- remove -ba option: It said:
"-ba Enable better address checking with bounds checker"
Okay, if it is better then to have it is not an option.
- remove va_copy. It is C99 and we try to stay C89 in tinycc
when possible. For example, MS compilers do not have va_copy.
- win64: revert any 'fixes' to alloca
It was correct as it was before, except for bound_checking
where it was not implemented. This should now work too.
- remove parasitic filename:linenum features
Such feature is already present with rt_printline in
tccrun.c. If it doesn't work it can be fixed.
- revert changes to gen_bounded_ptr_add()
gen_bounded_ptr_add() was working as it should before
(mostly). For the sake of simplicity I switched it to
CDECL. Anyway, FASTCALL means SLOWCALL with tinycc.
In exchange you get one addition which is required for
bounds_cnecking function arguments. The important thing
is to check them *BEFORE* they are loaded into registers.
New function gbound_args() does that.
In any case, code instrumentation with the bounds-check
functions as such now seems to work flawlessly again,
which means when they are inserted as NOPs, any code that
tcc can compile, seems to behave just the same as without
them.
What these functions then do when fully enabled, is a
differnt story. I did not touch this.
2019-12-12 17:45:45 +03:00
|
|
|
@for i in $(BOUNDS_OK); do \
|
2009-07-06 23:10:14 +04:00
|
|
|
echo ; echo --- boundtest $$i ---; \
|
bcheck cleanup
- revert Makefiles to state before last bcheck additions
Instead, just load bcheck.o explicitly if that is
what is wanted.
- move tcc_add_bcheck() to the <target>-link.c files and
remove revently added arguments. This function is to
support tccelf.c with linking, not for tccgen.c to
support compilation.
- remove -ba option: It said:
"-ba Enable better address checking with bounds checker"
Okay, if it is better then to have it is not an option.
- remove va_copy. It is C99 and we try to stay C89 in tinycc
when possible. For example, MS compilers do not have va_copy.
- win64: revert any 'fixes' to alloca
It was correct as it was before, except for bound_checking
where it was not implemented. This should now work too.
- remove parasitic filename:linenum features
Such feature is already present with rt_printline in
tccrun.c. If it doesn't work it can be fixed.
- revert changes to gen_bounded_ptr_add()
gen_bounded_ptr_add() was working as it should before
(mostly). For the sake of simplicity I switched it to
CDECL. Anyway, FASTCALL means SLOWCALL with tinycc.
In exchange you get one addition which is required for
bounds_cnecking function arguments. The important thing
is to check them *BEFORE* they are loaded into registers.
New function gbound_args() does that.
In any case, code instrumentation with the bounds-check
functions as such now seems to work flawlessly again,
which means when they are inserted as NOPs, any code that
tcc can compile, seems to behave just the same as without
them.
What these functions then do when fully enabled, is a
differnt story. I did not touch this.
2019-12-12 17:45:45 +03:00
|
|
|
if $(TCC) -b -run $< $$i ; then \
|
2014-04-07 15:31:00 +04:00
|
|
|
echo succeeded as expected; \
|
2009-04-18 16:31:35 +04:00
|
|
|
else\
|
|
|
|
echo Failed positive test $$i ; exit 1 ; \
|
|
|
|
fi ;\
|
|
|
|
done ;\
|
|
|
|
for i in $(BOUNDS_FAIL); do \
|
2009-07-06 23:10:14 +04:00
|
|
|
echo ; echo --- boundtest $$i ---; \
|
bcheck cleanup
- revert Makefiles to state before last bcheck additions
Instead, just load bcheck.o explicitly if that is
what is wanted.
- move tcc_add_bcheck() to the <target>-link.c files and
remove revently added arguments. This function is to
support tccelf.c with linking, not for tccgen.c to
support compilation.
- remove -ba option: It said:
"-ba Enable better address checking with bounds checker"
Okay, if it is better then to have it is not an option.
- remove va_copy. It is C99 and we try to stay C89 in tinycc
when possible. For example, MS compilers do not have va_copy.
- win64: revert any 'fixes' to alloca
It was correct as it was before, except for bound_checking
where it was not implemented. This should now work too.
- remove parasitic filename:linenum features
Such feature is already present with rt_printline in
tccrun.c. If it doesn't work it can be fixed.
- revert changes to gen_bounded_ptr_add()
gen_bounded_ptr_add() was working as it should before
(mostly). For the sake of simplicity I switched it to
CDECL. Anyway, FASTCALL means SLOWCALL with tinycc.
In exchange you get one addition which is required for
bounds_cnecking function arguments. The important thing
is to check them *BEFORE* they are loaded into registers.
New function gbound_args() does that.
In any case, code instrumentation with the bounds-check
functions as such now seems to work flawlessly again,
which means when they are inserted as NOPs, any code that
tcc can compile, seems to behave just the same as without
them.
What these functions then do when fully enabled, is a
differnt story. I did not touch this.
2019-12-12 17:45:45 +03:00
|
|
|
if $(TCC) -b -run $< $$i ; then \
|
2009-04-18 16:31:35 +04:00
|
|
|
echo Failed negative test $$i ; exit 1 ;\
|
|
|
|
else\
|
2009-07-06 23:10:14 +04:00
|
|
|
echo failed as expected; \
|
2009-04-18 16:31:35 +04:00
|
|
|
fi ;\
|
|
|
|
done ;\
|
2009-07-06 23:10:14 +04:00
|
|
|
echo; echo Bound test OK
|
2009-04-18 16:31:35 +04:00
|
|
|
|
|
|
|
# speed test
|
2009-07-06 23:11:19 +04:00
|
|
|
speedtest: ex2 ex3
|
2009-04-18 16:31:35 +04:00
|
|
|
@echo ------------ $@ ------------
|
|
|
|
time ./ex2 1238 2 3 4 10 13 4
|
2016-10-01 22:06:53 +03:00
|
|
|
time $(TCC) -run $(TOPSRC)/examples/ex2.c 1238 2 3 4 10 13 4
|
2009-04-18 16:31:35 +04:00
|
|
|
time ./ex3 35
|
2016-10-01 22:06:53 +03:00
|
|
|
time $(TCC) -run $(TOPSRC)/examples/ex3.c 35
|
2009-04-18 16:31:35 +04:00
|
|
|
|
2014-01-06 22:56:26 +04:00
|
|
|
weaktest: tcctest.c test.ref
|
2016-10-01 22:06:33 +03:00
|
|
|
$(TCC) -c $< -o weaktest.tcc.o
|
2017-02-13 21:03:29 +03:00
|
|
|
$(CC) -c $< -o weaktest.gcc.o $(NATIVE_DEFINES) $(CFLAGS) -w -O0 -std=gnu99 -fno-omit-frame-pointer
|
2011-02-01 20:41:03 +03:00
|
|
|
objdump -t weaktest.tcc.o | grep ' w ' | sed -e 's/.* \([a-zA-Z0-9_]*\)$$/\1/' | LC_ALL=C sort > weaktest.tcc.o.txt
|
2016-10-01 22:06:33 +03:00
|
|
|
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"
|
2011-02-01 20:41:03 +03:00
|
|
|
|
2016-10-01 22:06:53 +03:00
|
|
|
ex%: $(TOPSRC)/examples/ex%.c
|
2016-10-01 22:06:33 +03:00
|
|
|
$(CC) -o $@ $< $(CFLAGS)
|
2009-04-18 16:31:35 +04:00
|
|
|
|
|
|
|
# tiny assembler testing
|
|
|
|
asmtest.ref: asmtest.S
|
2016-05-11 19:58:14 +03:00
|
|
|
$(CC) -Wa,-W -o asmtest.ref.o -c asmtest.S
|
2009-07-06 23:11:19 +04:00
|
|
|
objdump -D asmtest.ref.o > asmtest.ref
|
2009-04-18 16:31:35 +04:00
|
|
|
|
2016-10-02 02:38:22 +03:00
|
|
|
asmtest asmtest2: asmtest.ref
|
2009-04-18 16:31:35 +04:00
|
|
|
@echo ------------ $@ ------------
|
2016-10-02 02:38:22 +03:00
|
|
|
$(TCC) $(MAYBE_RUN_TCC) -c asmtest.S
|
2009-07-06 23:11:19 +04:00
|
|
|
objdump -D asmtest.o > asmtest.out
|
2009-04-18 16:31:35 +04:00
|
|
|
@if diff -u --ignore-matching-lines="file format" asmtest.ref asmtest.out ; then echo "ASM Auto Test OK"; fi
|
|
|
|
|
2016-10-02 02:38:22 +03:00
|
|
|
# test assembler with tcc compiled by itself
|
|
|
|
asmtest2: MAYBE_RUN_TCC = $(RUN_TCC)
|
|
|
|
|
2013-04-18 00:51:51 +04:00
|
|
|
# Check that code generated by libtcc is binary compatible with
|
|
|
|
# that generated by CC
|
2016-10-01 22:06:33 +03:00
|
|
|
abitest-cc$(EXESUF): abitest.c $(LIBTCC)
|
|
|
|
$(CC) -o $@ $^ $(CFLAGS) $(LIBS) -w
|
2013-04-18 20:27:34 +04:00
|
|
|
|
2014-01-21 16:25:14 +04:00
|
|
|
abitest-tcc$(EXESUF): abitest.c libtcc.c
|
2017-07-23 22:24:11 +03:00
|
|
|
$(TCC) -o $@ $^ $(NATIVE_DEFINES) $(LIBS)
|
2013-04-18 00:51:51 +04:00
|
|
|
|
2015-03-04 09:52:47 +03:00
|
|
|
ABITESTS := abitest-cc$(EXESUF)
|
|
|
|
ifneq ($(CONFIG_arm_eabi),yes) # not ARM soft-float
|
2016-10-01 22:06:33 +03:00
|
|
|
ABITESTS += abitest-tcc$(EXESUF)
|
2015-03-04 09:52:47 +03:00
|
|
|
endif
|
|
|
|
|
|
|
|
abitest: $(ABITESTS)
|
2013-04-18 00:51:51 +04:00
|
|
|
@echo ------------ $@ ------------
|
tccpp: fix issues, add tests
* fix some macro expansion issues
* add some pp tests in tests/pp
* improved tcc -E output for better diff'ability
* remove -dD feature (quirky code, exotic feature,
didn't work well)
Based partially on ideas / researches from PipCet
Some issues remain with VA_ARGS macros (if used in a
rather tricky way).
Also, to keep it simple, the pp doesn't automtically
add any extra spaces to separate tokens which otherwise
would form wrong tokens if re-read from tcc -E output
(such as '+' '=') GCC does that, other compilers don't.
* cleanups
- #line 01 "file" / # 01 "file" processing
- #pragma comment(lib,"foo")
- tcc -E: forward some pragmas to output (pack, comment(lib))
- fix macro parameter list parsing mess from
a3fc54345949535524d01319e1ca6378b7c2c201
a715d7143d9d17da17e67fec6af1c01409a71a31
(some coffee might help, next time ;)
- introduce TOK_PPSTR - to have character constants as
written in the file (similar to TOK_PPNUM)
- allow '\' appear in macros
- new functions begin/end_macro to:
- fix switching macro levels during expansion
- allow unget_tok to unget more than one tok
- slight speedup by using bitflags in isidnum_table
Also:
- x86_64.c : fix decl after statements
- i386-gen,c : fix a vstack leak with VLA on windows
- configure/Makefile : build on windows (MSYS) was broken
- tcc_warning: fflush stderr to keep output order (win32)
2015-05-09 15:29:39 +03:00
|
|
|
./abitest-cc$(EXESUF) $(TCCFLAGS)
|
2016-10-01 22:06:33 +03:00
|
|
|
ifneq ($(CONFIG_arm_eabi),yes) # not ARM soft-float
|
|
|
|
./abitest-tcc$(EXESUF) $(TCCFLAGS)
|
|
|
|
endif
|
2013-04-18 00:51:51 +04:00
|
|
|
|
2013-04-27 23:39:34 +04:00
|
|
|
vla_test$(EXESUF): vla_test.c
|
2016-10-01 22:06:33 +03:00
|
|
|
$(TCC) -o $@ $^
|
|
|
|
|
2013-04-27 23:39:34 +04:00
|
|
|
vla_test-run: vla_test$(EXESUF)
|
|
|
|
@echo ------------ $@ ------------
|
|
|
|
./vla_test$(EXESUF)
|
|
|
|
|
2017-11-22 19:57:43 +03:00
|
|
|
asm-c-connect$(EXESUF): asm-c-connect-1.c asm-c-connect-2.c
|
|
|
|
$(TCC) -o $@ $^
|
|
|
|
|
2017-12-04 05:51:14 +03:00
|
|
|
asm-c-connect-%.o: asm-c-connect-%.c
|
|
|
|
$(TCC) -c -o $@ $<
|
|
|
|
|
|
|
|
asm-c-connect-sep$(EXESUF): asm-c-connect-1.o asm-c-connect-2.o
|
|
|
|
$(TCC) -o $@ $^
|
|
|
|
|
|
|
|
asm-c-connect-test: asm-c-connect$(EXESUF) asm-c-connect-sep$(EXESUF)
|
2017-11-22 19:57:43 +03:00
|
|
|
@echo ------------ $@ ------------
|
2017-12-12 19:57:20 +03:00
|
|
|
./asm-c-connect$(EXESUF) > asm-c-connect.out1 && cat asm-c-connect.out1
|
|
|
|
./asm-c-connect-sep$(EXESUF) > asm-c-connect.out2 && cat asm-c-connect.out2
|
|
|
|
@diff -u asm-c-connect.out1 asm-c-connect.out2 && echo "ok"
|
2017-11-22 19:57:43 +03:00
|
|
|
|
2017-02-25 14:49:47 +03:00
|
|
|
cross-test :
|
|
|
|
@echo ------------ $@ ------------
|
|
|
|
$(TOP)/i386-tcc$(EXESUF) $(TCCFLAGS-unx) -c $(TOPSRC)/examples/ex3.c && echo "ok"
|
various stuff
win32/Makefile ("for cygwin") removed
- On cygwin, the normal ./configure && make can be used with either
cygwin's "GCC for Win32 Toolchain"
./configure --cross-prefix=i686-w64-mingw32-
or with an existing tcc:
./configure --cc=<old-tccdir>/tcc.exe
tcctest.c:
- exclude test_high_clobbers() on _WIN64 (does not work)
tests2/95_bitfield.c:
- use 'signed char' for ARM (where default 'char' is unsigned)
tests:
- remove -I "expr" diff option to allow tests with
busybox-diff.
libtcc.c, tcc.c:
- removed -iwithprefix option. It is supposed to be
combined with -iprefix which we don't have either.
tccgen.c:
- fix assignments and return of 'void', as in
void f() {
void *p, *q;
*p = *q:
return *p;
}
This appears to be allowed but should do nothing.
tcc.h, libtcc.c, tccpp.c:
- Revert "Introduce VIP sysinclude paths which are always searched first"
This reverts commit 1d5e386b0a78393ac6b670c209a185849ec798a1.
The patch was giving tcc's system includes priority over -I which
is not how it should be.
tccelf.c:
- add DT_TEXTREL tag only if text relocations are actually
used (which is likely not the case on x86_64)
- prepare_dynamic_rel(): avoid relocation of unresolved
(weak) symbols
tccrun.c:
- for HAVE_SELINUX, use two mappings to the same (real) file.
(it was so once except the RX mapping wasn't used at all).
tccpe.c:
- fix relocation constant used for x86_64 (by Andrei E. Warentin)
- #ifndef _WIN32 do "chmod 755 ..." to get runnable exes on cygwin.
tccasm.c:
- keep forward asm labels static, otherwise they will endup
in dynsym eventually.
configure, Makefile:
- mingw32: respect ./configure options --bindir --docdir --libdir
- allow overriding tcc when building libtcc1.a and libtcc.def with
make XTCC=<tcc program to use>
- use $(wildcard ...) for install to allow installing just
a cross compiler for example
make cross-arm
make install
- use name <target>-libtcc1.a
build-tcc.bat:
- add options: -clean, -b bindir
2017-10-11 19:13:43 +03:00
|
|
|
$(TOP)/i386-win32-tcc$(EXESUF) $(TCCFLAGS-win) $(TOPSRC)/examples/ex3.c && echo "ok"
|
2017-02-25 14:49:47 +03:00
|
|
|
$(TOP)/x86_64-tcc$(EXESUF) $(TCCFLAGS-unx) -c $(TOPSRC)/examples/ex3.c && echo "ok"
|
various stuff
win32/Makefile ("for cygwin") removed
- On cygwin, the normal ./configure && make can be used with either
cygwin's "GCC for Win32 Toolchain"
./configure --cross-prefix=i686-w64-mingw32-
or with an existing tcc:
./configure --cc=<old-tccdir>/tcc.exe
tcctest.c:
- exclude test_high_clobbers() on _WIN64 (does not work)
tests2/95_bitfield.c:
- use 'signed char' for ARM (where default 'char' is unsigned)
tests:
- remove -I "expr" diff option to allow tests with
busybox-diff.
libtcc.c, tcc.c:
- removed -iwithprefix option. It is supposed to be
combined with -iprefix which we don't have either.
tccgen.c:
- fix assignments and return of 'void', as in
void f() {
void *p, *q;
*p = *q:
return *p;
}
This appears to be allowed but should do nothing.
tcc.h, libtcc.c, tccpp.c:
- Revert "Introduce VIP sysinclude paths which are always searched first"
This reverts commit 1d5e386b0a78393ac6b670c209a185849ec798a1.
The patch was giving tcc's system includes priority over -I which
is not how it should be.
tccelf.c:
- add DT_TEXTREL tag only if text relocations are actually
used (which is likely not the case on x86_64)
- prepare_dynamic_rel(): avoid relocation of unresolved
(weak) symbols
tccrun.c:
- for HAVE_SELINUX, use two mappings to the same (real) file.
(it was so once except the RX mapping wasn't used at all).
tccpe.c:
- fix relocation constant used for x86_64 (by Andrei E. Warentin)
- #ifndef _WIN32 do "chmod 755 ..." to get runnable exes on cygwin.
tccasm.c:
- keep forward asm labels static, otherwise they will endup
in dynsym eventually.
configure, Makefile:
- mingw32: respect ./configure options --bindir --docdir --libdir
- allow overriding tcc when building libtcc1.a and libtcc.def with
make XTCC=<tcc program to use>
- use $(wildcard ...) for install to allow installing just
a cross compiler for example
make cross-arm
make install
- use name <target>-libtcc1.a
build-tcc.bat:
- add options: -clean, -b bindir
2017-10-11 19:13:43 +03:00
|
|
|
$(TOP)/x86_64-win32-tcc$(EXESUF) $(TCCFLAGS-win) $(TOPSRC)/examples/ex3.c && echo "ok"
|
2017-02-25 14:49:47 +03:00
|
|
|
$(TOP)/arm-tcc$(EXESUF) $(TCCFLAGS-unx) -c $(TOPSRC)/examples/ex3.c && echo "ok"
|
various stuff
win32/Makefile ("for cygwin") removed
- On cygwin, the normal ./configure && make can be used with either
cygwin's "GCC for Win32 Toolchain"
./configure --cross-prefix=i686-w64-mingw32-
or with an existing tcc:
./configure --cc=<old-tccdir>/tcc.exe
tcctest.c:
- exclude test_high_clobbers() on _WIN64 (does not work)
tests2/95_bitfield.c:
- use 'signed char' for ARM (where default 'char' is unsigned)
tests:
- remove -I "expr" diff option to allow tests with
busybox-diff.
libtcc.c, tcc.c:
- removed -iwithprefix option. It is supposed to be
combined with -iprefix which we don't have either.
tccgen.c:
- fix assignments and return of 'void', as in
void f() {
void *p, *q;
*p = *q:
return *p;
}
This appears to be allowed but should do nothing.
tcc.h, libtcc.c, tccpp.c:
- Revert "Introduce VIP sysinclude paths which are always searched first"
This reverts commit 1d5e386b0a78393ac6b670c209a185849ec798a1.
The patch was giving tcc's system includes priority over -I which
is not how it should be.
tccelf.c:
- add DT_TEXTREL tag only if text relocations are actually
used (which is likely not the case on x86_64)
- prepare_dynamic_rel(): avoid relocation of unresolved
(weak) symbols
tccrun.c:
- for HAVE_SELINUX, use two mappings to the same (real) file.
(it was so once except the RX mapping wasn't used at all).
tccpe.c:
- fix relocation constant used for x86_64 (by Andrei E. Warentin)
- #ifndef _WIN32 do "chmod 755 ..." to get runnable exes on cygwin.
tccasm.c:
- keep forward asm labels static, otherwise they will endup
in dynsym eventually.
configure, Makefile:
- mingw32: respect ./configure options --bindir --docdir --libdir
- allow overriding tcc when building libtcc1.a and libtcc.def with
make XTCC=<tcc program to use>
- use $(wildcard ...) for install to allow installing just
a cross compiler for example
make cross-arm
make install
- use name <target>-libtcc1.a
build-tcc.bat:
- add options: -clean, -b bindir
2017-10-11 19:13:43 +03:00
|
|
|
$(TOP)/arm-wince-tcc$(EXESUF) $(TCCFLAGS-win) -c $(TOPSRC)/examples/ex3.c && echo "ok"
|
|
|
|
$(TOP)/arm64-tcc$(EXESUF) $(TCCFLAGS-unx) -c $(TOPSRC)/examples/ex3.c && echo "ok"
|
2019-12-16 20:51:28 +03:00
|
|
|
$(TOP)/riscv64-tcc$(EXESUF) $(TCCFLAGS-unx) -c $(TOPSRC)/examples/ex3.c && echo "ok"
|
2017-02-25 14:49:47 +03:00
|
|
|
$(TOP)/c67-tcc$(EXESUF) $(TCCFLAGS-unx) -c $(TOPSRC)/examples/ex3.c && echo "ok"
|
|
|
|
$(TOP)/i386-win32-tcc$(EXESUF) $(TCCFLAGS-win) $(TOPSRC)/win32/examples/hello_win.c && echo "ok"
|
|
|
|
$(TOP)/x86_64-win32-tcc$(EXESUF) $(TCCFLAGS-win) $(TOPSRC)/win32/examples/hello_win.c && echo "ok"
|
|
|
|
$(TOP)/arm-wince-tcc$(EXESUF) $(TCCFLAGS-win) -c $(TOPSRC)/win32/examples/hello_win.c && echo "ok"
|
|
|
|
|
2009-04-18 16:31:35 +04:00
|
|
|
# targets for development
|
|
|
|
%.bin: %.c tcc
|
|
|
|
$(TCC) -g -o $@ $<
|
|
|
|
$(DISAS) $@
|
|
|
|
|
|
|
|
instr: instr.o
|
|
|
|
objdump -d instr.o
|
|
|
|
|
|
|
|
instr.o: instr.S
|
|
|
|
$(CC) -o $@ -c $< -O2 -Wall -g
|
|
|
|
|
|
|
|
cache: tcc_g
|
|
|
|
cachegrind ./tcc_g -o /tmp/linpack -lm bench/linpack.c
|
|
|
|
vg_annotate tcc.c > /tmp/linpack.cache.log
|
|
|
|
|
|
|
|
# clean
|
|
|
|
clean:
|
2017-04-25 22:01:54 +03:00
|
|
|
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]
|
2018-03-09 23:10:06 +03:00
|
|
|
rm -f asm-c-connect$(EXESUF) asm-c-connect-sep$(EXESUF)
|
2019-12-11 02:37:18 +03:00
|
|
|
rm -f ex? tcc_g weaktest.*.txt *.def libtcc_test_mt
|
2017-04-25 22:01:54 +03:00
|
|
|
@$(MAKE) -C tests2 $@
|
|
|
|
@$(MAKE) -C pp $@
|
2016-10-01 22:06:33 +03:00
|
|
|
|
|
|
|
# silent clean, used before running tests
|
|
|
|
clean-s:
|
|
|
|
@$(MAKE) -s --no-print-directory clean
|