mirror of
https://github.com/frida/tinycc
synced 2024-11-28 02:29:38 +03:00
update
This commit is contained in:
parent
2694c10547
commit
b0b2d5d2e9
30
Makefile
30
Makefile
@ -5,13 +5,13 @@ prefix=/usr/local
|
||||
|
||||
CFLAGS=-O2 -g -Wall -Wno-parentheses -Wno-missing-braces -I.
|
||||
LIBS=-ldl
|
||||
#CFLAGS=-O2 -g -Wall -Wno-parentheses -I. -pg -static -DPROFILE
|
||||
#LIBS=
|
||||
CFLAGS_P=$(CFLAGS) -pg -static -DCONFIG_TCC_STATIC
|
||||
LIBS_P=
|
||||
|
||||
CFLAGS+=-m386 -malign-functions=0
|
||||
DISAS=objdump -D -b binary -m i386
|
||||
INSTALL=install
|
||||
VERSION=0.9.1
|
||||
VERSION=0.9.2
|
||||
|
||||
all: tcc
|
||||
|
||||
@ -21,7 +21,7 @@ test: test.ref test.out
|
||||
@if diff -u test.ref test.out ; then echo "Auto Test OK"; fi
|
||||
|
||||
prog.ref: prog.c
|
||||
gcc $(CFLAGS) -o $@ $<
|
||||
gcc3 $(CFLAGS) -o $@ $<
|
||||
|
||||
test.ref: prog.ref
|
||||
./prog.ref > $@
|
||||
@ -33,12 +33,12 @@ run: tcc prog.c
|
||||
./tcc -I. prog.c
|
||||
|
||||
# iterated test2 (compile tcc then compile prog.c !)
|
||||
test2: tcc tcc.c prog.c
|
||||
test2: tcc tcc.c prog.c test.ref
|
||||
./tcc -I. tcc.c -I. prog.c > test.out2
|
||||
@if diff -u test.ref test.out2 ; then echo "Auto Test2 OK"; fi
|
||||
|
||||
# iterated test3 (compile tcc then compile tcc then compile prog.c !)
|
||||
test3: tcc tcc.c prog.c
|
||||
test3: tcc tcc.c prog.c test.ref
|
||||
./tcc -I. tcc.c -I. tcc.c -I. prog.c > test.out3
|
||||
@if diff -u test.ref test.out3 ; then echo "Auto Test3 OK"; fi
|
||||
|
||||
@ -57,7 +57,7 @@ ex3: ex3.c
|
||||
|
||||
# Tiny C Compiler
|
||||
|
||||
tcc_g: tcc.c Makefile
|
||||
tcc_g: tcc.c i386-gen.c Makefile
|
||||
gcc $(CFLAGS) -o $@ $< $(LIBS)
|
||||
|
||||
tcc: tcc_g
|
||||
@ -66,11 +66,15 @@ tcc: tcc_g
|
||||
install: tcc
|
||||
$(INSTALL) -m755 tcc $(prefix)/bin
|
||||
mkdir -p $(prefix)/lib/tcc
|
||||
$(INSTALL) -m644 stdarg.h stddef.h tcclib.h $(prefix)/lib/tcc
|
||||
$(INSTALL) -m644 stdarg.h stddef.h float.h tcclib.h $(prefix)/lib/tcc
|
||||
|
||||
clean:
|
||||
rm -f *~ *.o tcc tcc1 tcct tcc_g prog.ref *.bin *.i ex2 \
|
||||
core gmon.out test.out test.ref a.out
|
||||
core gmon.out test.out test.ref a.out tcc_p
|
||||
|
||||
# profiling version
|
||||
tcc_p: tcc.c Makefile
|
||||
gcc $(CFLAGS_P) -o $@ $< $(LIBS_P)
|
||||
|
||||
# target for development
|
||||
|
||||
@ -78,6 +82,9 @@ clean:
|
||||
./tcc -o $@ -I. $<
|
||||
$(DISAS) $@
|
||||
|
||||
instr: instr.o
|
||||
objdump -d instr.o
|
||||
|
||||
instr.o: instr.S
|
||||
gcc -O2 -Wall -g -c -o $@ $<
|
||||
|
||||
@ -88,6 +95,9 @@ tar:
|
||||
cp -r ../tcc /tmp/$(FILE)
|
||||
( cd /tmp ; tar zcvf ~/$(FILE).tar.gz \
|
||||
$(FILE)/Makefile $(FILE)/README $(FILE)/TODO $(FILE)/COPYING \
|
||||
$(FILE)/tcc.c $(FILE)/stddef.h $(FILE)/stdarg.h $(FILE)/tcclib.h \
|
||||
$(FILE)/Changelog $(FILE)/tcc-doc.html \
|
||||
$(FILE)/tcc.c $(FILE)/i386-gen.c \
|
||||
$(FILE)/stddef.h $(FILE)/stdarg.h $(FILE)/stdbool.h $(FILE)/float.h \
|
||||
$(FILE)/tcclib.h \
|
||||
$(FILE)/ex*.c $(FILE)/prog.c )
|
||||
rm -rf /tmp/$(FILE)
|
||||
|
49
README
49
README
@ -5,7 +5,7 @@ Features:
|
||||
--------
|
||||
|
||||
- SMALL! You can compile and execute C code everywhere, for example on
|
||||
rescue disks (29KB for x86 TCC executable).
|
||||
rescue disks.
|
||||
|
||||
- FAST! tcc generates optimized x86 code. No byte code
|
||||
overhead. Compiles, assemble and link about 7 times faster than 'gcc
|
||||
@ -27,7 +27,7 @@ Documentation:
|
||||
|
||||
1) Installation
|
||||
|
||||
***TCC currently only work on Linux x86***.
|
||||
***TCC currently only works on Linux x86***.
|
||||
|
||||
Type 'make install' to compile and install tcc in /usr/local/bin and
|
||||
/usr/local/lib/tcc.
|
||||
@ -60,8 +60,8 @@ default ones are: /usr/include, /usr/lib/tcc, /usr/local/lib/tcc.
|
||||
libxxx.so. Standard library paths are checked, including those
|
||||
specificed with LD_LIBRARY_PATH.
|
||||
|
||||
Only one source code can be compiled. If you have multiple source
|
||||
files, add one which includes all your sources.
|
||||
'-i file' : compile C source 'file' before main C source. With this
|
||||
command, multiple C files can be compiled and linked together.
|
||||
|
||||
4) Examples
|
||||
|
||||
@ -84,44 +84,9 @@ generator.
|
||||
prog.c: auto test for TCC which tests many subtle possible bugs. Used
|
||||
when doing 'make test'.
|
||||
|
||||
Exact differences with ANSI C:
|
||||
-----------------------------
|
||||
5) Full Documentation
|
||||
|
||||
- Preprocessor: the preprocessor tokens are the same as C. It means
|
||||
that in some rare cases, preprocessed numbers are not handled
|
||||
exactly as in ANSI C. This approach has the advantage of being
|
||||
simpler and FAST!
|
||||
|
||||
- Types: floating point numbers are not supported yet.
|
||||
|
||||
- Bit fields are not supported.
|
||||
|
||||
- Linking: extern variables must appear in a referenced dll and cannot
|
||||
appear in current source.
|
||||
|
||||
Supported ANSI C extensions:
|
||||
---------------------------
|
||||
|
||||
- 'inline' keyword is ignored (ISOC99).
|
||||
|
||||
- 'restrict' keyword is ignored (ISOC99).
|
||||
|
||||
- '__func__' is a string variable containing the current function name (ISOC99).
|
||||
|
||||
- Variadic macros: __VA_ARGS__ can be used for function-like macros (ISOC99):
|
||||
#define dprintf(level, __VA_ARGS__) printf(__VA_ARGS__).
|
||||
|
||||
- Declarations can appear anywhere in a block (ISOC99).
|
||||
|
||||
- Array and struct/union elements can be initialized in any order by
|
||||
using designators (.e.g. { [0].x = 1 }) (ISOC99).
|
||||
|
||||
- Compound initializers are supported (e.g. int *p = (int []){ 1, 2,
|
||||
3}) (ISOC99).
|
||||
|
||||
- '#!' at the start of a line is ignored to allow scripting.
|
||||
|
||||
- Binary digits can be entered ('0b101' instead of '5').
|
||||
Please read tcc-doc.html to have all the features of TCC.
|
||||
|
||||
Technical Description:
|
||||
---------------------
|
||||
@ -162,7 +127,7 @@ License:
|
||||
TCC is distributed under the GNU General Public License (see COPYING
|
||||
file).
|
||||
|
||||
I accept only patches where you give your copyright explictely to me
|
||||
I accept only patches where you give your copyright explicitely to me
|
||||
to simplify licensing issues.
|
||||
|
||||
Fabrice Bellard - Nov 17, 2001.
|
||||
|
14
TODO
14
TODO
@ -1,21 +1,21 @@
|
||||
TODO list:
|
||||
|
||||
Critical:
|
||||
|
||||
- add float/double support (should be as small as possible while being
|
||||
usable for RISC code generator too).
|
||||
- finish float/double support. add function type convertion.
|
||||
- section generation and GNUC __attributte__ handling.
|
||||
- D option with '=' handling
|
||||
- 0 is pointer - fix type compare
|
||||
- add message if external function or variable not found.
|
||||
- To check: 'sizeof' may not work if too complex expression is given.
|
||||
- fix 'char' and 'short' casts (in function parameters and in assignment).
|
||||
- function pointers to forward reference (patch code generator).
|
||||
- fix 'char' and 'short' casts (only in function parameters and in
|
||||
assignment).
|
||||
|
||||
Not critical:
|
||||
|
||||
- interactive mode
|
||||
- fix multiple compound literals inits in blocks (ISOC99 normative
|
||||
example - only relevant when using gotos! -> must add boolean
|
||||
variable to tell if compound literal was already initialized).
|
||||
- fix L"\x1234" wide string case (need to store them as ints ?) */
|
||||
- fix L"\x1234" wide string case (need to store them as utf8 ?)
|
||||
- fix preprocessor symbol redefinition
|
||||
- better constant opt (&&, ||, ?:)
|
||||
- add ELF executable and shared library output option (would be needed
|
||||
|
10
stdbool.h
Normal file
10
stdbool.h
Normal file
@ -0,0 +1,10 @@
|
||||
#ifndef _STDBOOL_H
|
||||
#define _STDBOOL_H
|
||||
|
||||
/* ISOC99 boolean */
|
||||
|
||||
#define bool _Bool
|
||||
#define true 1
|
||||
#define false 0
|
||||
|
||||
#endif /* _STDBOOL_H */
|
3
stddef.h
3
stddef.h
@ -1,9 +1,10 @@
|
||||
#ifndef _STDDEF_H
|
||||
#define _STDDEF_H
|
||||
|
||||
/* TCC include file */
|
||||
#define NULL ((void *)0)
|
||||
typedef unsigned int size_t;
|
||||
typedef int wchar_t;
|
||||
typedef int ptrdiff_t;
|
||||
#define offsetof(type, field) ((size_t) &((type *)0)->field)
|
||||
|
||||
#endif
|
||||
|
@ -29,8 +29,8 @@ it was an executable.
|
||||
|
||||
<h2>Exact differences with ANSI C</h2>
|
||||
|
||||
TCC implements almost all the ANSI C standard, except floating point
|
||||
and long long numbers.
|
||||
TCC implements almost all the ANSI C standard, except floating points
|
||||
numbers.
|
||||
|
||||
<ul>
|
||||
<li> The preprocessor tokens are the same as C. It means that in some
|
||||
|
Loading…
Reference in New Issue
Block a user