Unified · Split
| @@ -5,13 +5,13 @@ prefix=/usr/local · 4 unmodified lines | ||
| 5 | 5 | |
| 6 | 6 | CFLAGS=-O2 -g -Wall -Wno-parentheses -Wno-missing-braces -I. |
| 7 | 7 | LIBS=-ldl |
| 8 | −#CFLAGS=-O2 -g -Wall -Wno-parentheses -I. -pg -static -DPROFILE | |
| 9 | −#LIBS= | |
| 8 | +CFLAGS_P=$(CFLAGS) -pg -static -DCONFIG_TCC_STATIC | |
| 9 | +LIBS_P= | |
| 10 | 10 | |
| 11 | 11 | CFLAGS+=-m386 -malign-functions=0 |
| 12 | 12 | DISAS=objdump -D -b binary -m i386 |
| 13 | 13 | INSTALL=install |
| 14 | −VERSION=0.9.1 | |
| 14 | +VERSION=0.9.2 | |
| 15 | 15 | |
| 16 | 16 | all: tcc |
| 17 | 17 | |
| @@ -21,7 +21,7 @@ test: test.ref test.out · 3 unmodified lines | ||
| 21 | 21 | @if diff -u test.ref test.out ; then echo "Auto Test OK"; fi |
| 22 | 22 | |
| 23 | 23 | prog.ref: prog.c |
| 24 | − gcc $(CFLAGS) -o $@ $< | |
| 24 | + gcc3 $(CFLAGS) -o $@ $< | |
| 25 | 25 | |
| 26 | 26 | test.ref: prog.ref |
| 27 | 27 | ./prog.ref > $@ |
| @@ -33,12 +33,12 @@ run: tcc prog.c · 5 unmodified lines | ||
| 33 | 33 | ./tcc -I. prog.c |
| 34 | 34 | |
| 35 | 35 | # iterated test2 (compile tcc then compile prog.c !) |
| 36 | −test2: tcc tcc.c prog.c | |
| 36 | +test2: tcc tcc.c prog.c test.ref | |
| 37 | 37 | ./tcc -I. tcc.c -I. prog.c > test.out2 |
| 38 | 38 | @if diff -u test.ref test.out2 ; then echo "Auto Test2 OK"; fi |
| 39 | 39 | |
| 40 | 40 | # iterated test3 (compile tcc then compile tcc then compile prog.c !) |
| 41 | −test3: tcc tcc.c prog.c | |
| 41 | +test3: tcc tcc.c prog.c test.ref | |
| 42 | 42 | ./tcc -I. tcc.c -I. tcc.c -I. prog.c > test.out3 |
| 43 | 43 | @if diff -u test.ref test.out3 ; then echo "Auto Test3 OK"; fi |
| 44 | 44 | |
| @@ -57,7 +57,7 @@ ex3: ex3.c · 12 unmodified lines | ||
| 57 | 57 | |
| 58 | 58 | # Tiny C Compiler |
| 59 | 59 | |
| 60 | −tcc_g: tcc.c Makefile | |
| 60 | +tcc_g: tcc.c i386-gen.c Makefile | |
| 61 | 61 | gcc $(CFLAGS) -o $@ $< $(LIBS) |
| 62 | 62 | |
| 63 | 63 | tcc: tcc_g |
| @@ -66,11 +66,15 @@ tcc: tcc_g · 2 unmodified lines | ||
| 66 | 66 | install: tcc |
| 67 | 67 | $(INSTALL) -m755 tcc $(prefix)/bin |
| 68 | 68 | mkdir -p $(prefix)/lib/tcc |
| 69 | − $(INSTALL) -m644 stdarg.h stddef.h tcclib.h $(prefix)/lib/tcc | |
| 69 | + $(INSTALL) -m644 stdarg.h stddef.h float.h tcclib.h $(prefix)/lib/tcc | |
| 70 | 70 | |
| 71 | 71 | clean: |
| 72 | 72 | rm -f *~ *.o tcc tcc1 tcct tcc_g prog.ref *.bin *.i ex2 \ |
| 73 | − core gmon.out test.out test.ref a.out | |
| 73 | + core gmon.out test.out test.ref a.out tcc_p | |
| 74 | + | |
| 75 | +# profiling version | |
| 76 | +tcc_p: tcc.c Makefile | |
| 77 | + gcc $(CFLAGS_P) -o $@ $< $(LIBS_P) | |
| 74 | 78 | |
| 75 | 79 | # target for development |
| 76 | 80 | |
| @@ -78,6 +82,9 @@ clean: · 1 unmodified line | ||
| 78 | 82 | ./tcc -o $@ -I. $< |
| 79 | 83 | $(DISAS) $@ |
| 80 | 84 | |
| 85 | +instr: instr.o | |
| 86 | + objdump -d instr.o | |
| 87 | + | |
| 81 | 88 | instr.o: instr.S |
| 82 | 89 | gcc -O2 -Wall -g -c -o $@ $< |
| 83 | 90 | |
| @@ -88,6 +95,9 @@ tar: · 4 unmodified lines | ||
| 88 | 95 | cp -r ../tcc /tmp/$(FILE) |
| 89 | 96 | ( cd /tmp ; tar zcvf ~/$(FILE).tar.gz \ |
| 90 | 97 | $(FILE)/Makefile $(FILE)/README $(FILE)/TODO $(FILE)/COPYING \ |
| 91 | − $(FILE)/tcc.c $(FILE)/stddef.h $(FILE)/stdarg.h $(FILE)/tcclib.h \ | |
| 98 | + $(FILE)/Changelog $(FILE)/tcc-doc.html \ | |
| 99 | + $(FILE)/tcc.c $(FILE)/i386-gen.c \ | |
| 100 | + $(FILE)/stddef.h $(FILE)/stdarg.h $(FILE)/stdbool.h $(FILE)/float.h \ | |
| 101 | + $(FILE)/tcclib.h \ | |
| 92 | 102 | $(FILE)/ex*.c $(FILE)/prog.c ) |
| 93 | 103 | rm -rf /tmp/$(FILE) |
| @@ -5,7 +5,7 @@ Features: · 4 unmodified lines | ||
| 5 | 5 | -------- |
| 6 | 6 | |
| 7 | 7 | - SMALL! You can compile and execute C code everywhere, for example on |
| 8 | − rescue disks (29KB for x86 TCC executable). | |
| 8 | + rescue disks. | |
| 9 | 9 | |
| 10 | 10 | - FAST! tcc generates optimized x86 code. No byte code |
| 11 | 11 | overhead. Compiles, assemble and link about 7 times faster than 'gcc |
| @@ -27,7 +27,7 @@ Documentation: · 15 unmodified lines | ||
| 27 | 27 | |
| 28 | 28 | 1) Installation |
| 29 | 29 | |
| 30 | −***TCC currently only work on Linux x86***. | |
| 30 | +***TCC currently only works on Linux x86***. | |
| 31 | 31 | |
| 32 | 32 | Type 'make install' to compile and install tcc in /usr/local/bin and |
| 33 | 33 | /usr/local/lib/tcc. |
| @@ -60,8 +60,8 @@ default ones are: /usr/include, /usr/lib/tcc, /usr/local/lib/tcc. · 26 unmodified lines | ||
| 60 | 60 | libxxx.so. Standard library paths are checked, including those |
| 61 | 61 | specificed with LD_LIBRARY_PATH. |
| 62 | 62 | |
| 63 | −Only one source code can be compiled. If you have multiple source | |
| 64 | −files, add one which includes all your sources. | |
| 63 | +'-i file' : compile C source 'file' before main C source. With this | |
| 64 | +command, multiple C files can be compiled and linked together. | |
| 65 | 65 | |
| 66 | 66 | 4) Examples |
| 67 | 67 | |
| @@ -84,44 +84,9 @@ generator. · 16 unmodified lines | ||
| 84 | 84 | prog.c: auto test for TCC which tests many subtle possible bugs. Used |
| 85 | 85 | when doing 'make test'. |
| 86 | 86 | |
| 87 | −Exact differences with ANSI C: | |
| 88 | −----------------------------- | |
| 87 | +5) Full Documentation | |
| 89 | 88 | |
| 90 | −- Preprocessor: the preprocessor tokens are the same as C. It means | |
| 91 | − that in some rare cases, preprocessed numbers are not handled | |
| 92 | − exactly as in ANSI C. This approach has the advantage of being | |
| 93 | − simpler and FAST! | |
| 94 | − | |
| 95 | −- Types: floating point numbers are not supported yet. | |
| 96 | − | |
| 97 | −- Bit fields are not supported. | |
| 98 | − | |
| 99 | −- Linking: extern variables must appear in a referenced dll and cannot | |
| 100 | − appear in current source. | |
| 101 | − | |
| 102 | −Supported ANSI C extensions: | |
| 103 | −--------------------------- | |
| 104 | − | |
| 105 | −- 'inline' keyword is ignored (ISOC99). | |
| 106 | − | |
| 107 | −- 'restrict' keyword is ignored (ISOC99). | |
| 108 | − | |
| 109 | −- '__func__' is a string variable containing the current function name (ISOC99). | |
| 110 | − | |
| 111 | −- Variadic macros: __VA_ARGS__ can be used for function-like macros (ISOC99): | |
| 112 | − #define dprintf(level, __VA_ARGS__) printf(__VA_ARGS__). | |
| 113 | − | |
| 114 | −- Declarations can appear anywhere in a block (ISOC99). | |
| 115 | − | |
| 116 | −- Array and struct/union elements can be initialized in any order by | |
| 117 | − using designators (.e.g. { [0].x = 1 }) (ISOC99). | |
| 118 | − | |
| 119 | −- Compound initializers are supported (e.g. int *p = (int []){ 1, 2, | |
| 120 | − 3}) (ISOC99). | |
| 121 | − | |
| 122 | −- '#!' at the start of a line is ignored to allow scripting. | |
| 123 | − | |
| 124 | −- Binary digits can be entered ('0b101' instead of '5'). | |
| 89 | +Please read tcc-doc.html to have all the features of TCC. | |
| 125 | 90 | |
| 126 | 91 | Technical Description: |
| 127 | 92 | --------------------- |
| @@ -162,7 +127,7 @@ License: · 34 unmodified lines | ||
| 162 | 127 | TCC is distributed under the GNU General Public License (see COPYING |
| 163 | 128 | file). |
| 164 | 129 | |
| 165 | −I accept only patches where you give your copyright explictely to me | |
| 130 | +I accept only patches where you give your copyright explicitely to me | |
| 166 | 131 | to simplify licensing issues. |
| 167 | 132 | |
| 168 | 133 | Fabrice Bellard - Nov 17, 2001. |
| @@ -1,21 +1,21 @@ | ||
| 1 | 1 | TODO list: |
| 2 | 2 | |
| 3 | 3 | Critical: |
| 4 | − | |
| 5 | −- add float/double support (should be as small as possible while being | |
| 6 | − usable for RISC code generator too). | |
| 4 | +- finish float/double support. add function type convertion. | |
| 5 | +- section generation and GNUC __attributte__ handling. | |
| 6 | +- D option with '=' handling | |
| 7 | 7 | - 0 is pointer - fix type compare |
| 8 | −- add message if external function or variable not found. | |
| 9 | 8 | - To check: 'sizeof' may not work if too complex expression is given. |
| 10 | −- fix 'char' and 'short' casts (in function parameters and in assignment). | |
| 11 | −- function pointers to forward reference (patch code generator). | |
| 9 | +- fix 'char' and 'short' casts (only in function parameters and in | |
| 10 | + assignment). | |
| 12 | 11 | |
| 13 | 12 | Not critical: |
| 14 | 13 | |
| 14 | +- interactive mode | |
| 15 | 15 | - fix multiple compound literals inits in blocks (ISOC99 normative |
| 16 | 16 | example - only relevant when using gotos! -> must add boolean |
| 17 | 17 | variable to tell if compound literal was already initialized). |
| 18 | −- fix L"\x1234" wide string case (need to store them as ints ?) */ | |
| 18 | +- fix L"\x1234" wide string case (need to store them as utf8 ?) | |
| 19 | 19 | - fix preprocessor symbol redefinition |
| 20 | 20 | - better constant opt (&&, ||, ?:) |
| 21 | 21 | - add ELF executable and shared library output option (would be needed |
| @@ -0,0 +1,10 @@ | ||
| 1 | +#ifndef _STDBOOL_H | |
| 2 | +#define _STDBOOL_H | |
| 3 | + | |
| 4 | +/* ISOC99 boolean */ | |
| 5 | + | |
| 6 | +#define bool _Bool | |
| 7 | +#define true 1 | |
| 8 | +#define false 0 | |
| 9 | + | |
| 10 | +#endif /* _STDBOOL_H */ | |
| @@ -1,9 +1,10 @@ | ||
| 1 | 1 | #ifndef _STDDEF_H |
| 2 | 2 | #define _STDDEF_H |
| 3 | 3 | |
| 4 | −/* TCC include file */ | |
| 5 | 4 | #define NULL ((void *)0) |
| 6 | 5 | typedef unsigned int size_t; |
| 7 | 6 | typedef int wchar_t; |
| 7 | +typedef int ptrdiff_t; | |
| 8 | +#define offsetof(type, field) ((size_t) &((type *)0)->field) | |
| 8 | 9 | |
| 9 | 10 | #endif |
| @@ -29,8 +29,8 @@ it was an executable. · 28 unmodified lines | ||
| 29 | 29 | |
| 30 | 30 | <h2>Exact differences with ANSI C</h2> |
| 31 | 31 | |
| 32 | −TCC implements almost all the ANSI C standard, except floating point | |
| 33 | −and long long numbers. | |
| 32 | +TCC implements almost all the ANSI C standard, except floating points | |
| 33 | +numbers. | |
| 34 | 34 | |
| 35 | 35 | <ul> |
| 36 | 36 | <li> The preprocessor tokens are the same as C. It means that in some |
| @@ -4,6 +4,7 @@ · 3 unmodified lines | ||
| 4 | 4 | * only for your convenience so that you do not need to put the whole |
| 5 | 5 | * glibc include files on your floppy disk |
| 6 | 6 | */ |
| 7 | + | |
| 7 | 8 | #include <stddef.h> |
| 8 | 9 | #include <stdarg.h> |
| 9 | 10 | |