History

update

bellard committed 25 years ago

Commit 34a14a01 parent b9455a73 files · +69 −43Browse files

Unified · Split

3 files
  1. Makefile +11 −10
  2. README +50 −29
  3. TODO +8 −4
Makefile+11−10
@@ -3,7 +3,7 @@ · 2 unmodified lines
33 #
44 prefix=/usr/local
55
6−CFLAGS=-O2 -g -Wall -Wno-parentheses -I.
6+CFLAGS=-O2 -g -Wall -Wno-parentheses -Wno-missing-braces -I.
77 LIBS=-ldl
88 #CFLAGS=-O2 -g -Wall -Wno-parentheses -I. -pg -static -DPROFILE
99 #LIBS=
@@ -32,11 +32,15 @@ test.out: tcc prog.c · 22 unmodified lines
3232 run: tcc prog.c
3333 ./tcc -I. prog.c
3434
35−run2: tcc tcc.c prog.c
36− ./tcc -I. tcc.c -I. prog.c
35+# iterated test2 (compile tcc then compile prog.c !)
36+test2: tcc tcc.c prog.c
37+ ./tcc -I. tcc.c -I. prog.c > test.out2
38+ @if diff -u test.ref test.out2 ; then echo "Auto Test2 OK"; fi
3739
38−run3: tcc tcc.c prog.c
39− ./tcc -I. tcc.c -I. tcc.c -I. prog.c
40+# iterated test3 (compile tcc then compile tcc then compile prog.c !)
41+test3: tcc tcc.c prog.c
42+ ./tcc -I. tcc.c -I. tcc.c -I. prog.c > test.out3
43+ @if diff -u test.ref test.out3 ; then echo "Auto Test3 OK"; fi
4044
4145 # speed test
4246 speed: tcc ex2 ex3
@@ -70,13 +74,10 @@ clean: · 27 unmodified lines
7074
7175 # target for development
7276
73−%.bin: %.c tcct
74− ./tcct -I. $< $@
77+%.bin: %.c tcc
78+ ./tcc -o $@ -I. $<
7579 $(DISAS) $@
7680
77−tcct: tcc.c
78− gcc -DTEST $(CFLAGS) -o $@ $< -ldl
79−
8081 instr.o: instr.S
8182 gcc -O2 -Wall -g -c -o $@ $<
8283
README+50−29
@@ -5,16 +5,18 @@ Features: · 4 unmodified lines
55 --------
66
77 - SMALL! You can compile and execute C code everywhere, for example on
8− rescue disks (25KB for x86 executable).
8+ rescue disks (27KB for x86 TCC executable).
99
10−- FAST! tcc generates optimized x86 code. No byte code overhead.
10+- FAST! tcc generates optimized x86 code. No byte code
11+ overhead. Compiles, assemble and link about 7 times faster than 'gcc
12+ -O0'.
1113
1214 - UNLIMITED! Any C dynamic library can be used directly. TCC is
13− heading torward full ANSI C compliance. TCC can of course compile
15+ heading torward full ISOC99 compliance. TCC can of course compile
1416 itself.
1517
1618 - Compile and execute C source directly. No linking or assembly
17− necessary. Full C preprocessor included.
19+ necessary. Full C preprocessor included.
1820
1921 - C script supported : just add '#!/usr/local/bin/tcc' at the first
2022 line of your C source, and execute it directly from the command
@@ -27,7 +29,7 @@ Documentation: · 6 unmodified lines
2729
2830 ***TCC currently only work on Linux x86***.
2931
30−Type 'make install' to compile and install tcc in /usr/local and
32+Type 'make install' to compile and install tcc in /usr/local/bin and
3133 /usr/local/lib/tcc.
3234
3335 2) Introduction
@@ -64,7 +66,7 @@ files, add one which includes all your sources. · 30 unmodified lines
6466 4) Examples
6567
6668 ex1.c: simplest example (hello world). Can also be launched directly
67−as a script: ./ex2.c.
69+as a script: './ex1.c'.
6870
6971 ex2.c: more complicated example: find a number with the four
7072 operations given a list of numbers (benchmark).
@@ -72,12 +74,12 @@ operations given a list of numbers (benchmark). · 1 unmodified line
7274 ex3.c: compute fibonacci numbers (benchmark).
7375
7476 ex4.c: more complicated: X11 program. Very complicated test in fact
75−because standard headers are being used ! Currently slow because
76−parsing does not use hash tables.
77+because standard headers are being used !
7778
7879 ex5.c: 'hello world' with standard glibc headers.
7980
80−tcc.c: TCC can compile itself. Used to check the code generator.
81+tcc.c: TCC can of course compile itself. Used to check the code
82+generator.
8183
8284 prog.c: auto test for TCC which tests many subtle possible bugs. Used
8385 when doing 'make test'.
@@ -91,38 +93,57 @@ Exact differences with ANSI C: · 7 unmodified lines
9193 rare cases, preprocessed numbers are not handled exactly as in ANSI
9294 C. This approach has the advantage of being simpler and FAST!
9395
94− - __LINE__, __FILE__, __DATE__, __TIME__ are currently not handled.
95−
96− - #line not handled
97−
9896 2) C language
9997
100−- Parsing: variables cannot be initialized ('int a = 1' or 'int tab[2] =
101− {1, 2}' not supported).
102−
10398 - Cannot pass struct/union as value. Cannot assign struct/union (use
10499 memcpy instead).
105100
106−- Types: floating point numbers are not supported.
101+- Types: floating point numbers are not supported yet.
107102
108103 - (BUG) 'char' and 'short' casts do not truncate correctly.
109104
110105 - 'sizeof' may not work if too complex expression is given.
111106
112−Supported C extensions:
113−----------------------
107+- bit fields are not supported.
108+
109+- L'c' or L"string" for wide chars are parsed but not handled as wchar_t.
110+
111+- Cannot initialize auto (=local) arrays with implicit size
112+ (workaround: specificy exact size in array declaration). Cannot
113+ initialize auto arrays with strings.
114+
115+3) Linking
116+
117+- extern variables must appear in a referenced dll and cannot appear
118+ in current source.
119+
120+Supported ANSI C extensions:
121+---------------------------
122+
123+- 'inline' keyword is ignored (ISOC99).
124+
125+- 'restrict' keyword is ignored (ISOC99).
126+
127+- '__func__' is a string variable containing the current function name (ISOC99).
128+
129+- variadic macros: __VA_ARGS__ can be used for function-like macros (ISOC99):
130+ #define dprintf(level, __VA_ARGS__) printf(__VA_ARGS__).
131+
132+- declarations can appear anywhere in a block (ISOC99).
114133
115−- 'inline' keyword is ignored.
134+- array and struct/union elements can be initialized in any order by
135+ using designators (.e. { [0].x = 1 }) (ISOC99).
116136
137+- binary digits can be entered ('0b101' instead of '5').
117138
118139 Technical Description:
119140 ---------------------
120141
121142 This is not my first C compiler (see my 'fbcc' compiler) but it
122143 contains the first C preprocessor I wrote. The project started as a
123−joke to make the smallest C compiler. Then I expanded it torward ANSI
124−compliance. This C compiler is particular because each feature was
125−added while trying to be as simple and compact as possible. For
144+joke to make the smallest C compiler. Then I expanded it torward
145+ISOC99 compliance. This C compiler is particular because each feature
146+was added while trying to be as simple and compact as possible. For
126147 example, no intermediate structure is used to store code or
127148 expressions.
128149
@@ -137,10 +158,10 @@ registers are used. When more registers are needed, one register is · 8 unmodified lines
137158 flushed in a new local variable.
138159
139160 Constant propagation is done for all operations. Multiplications and
140−divisions are optimized to shifts when appropriate. Logical operators
141−are optimized by maintaining a special cache for the processor
142−flags. &&, || and ! are optimized by maintaining a special 'jmp
143−target' value. No other jmp optimization is currently performed
161+divisions are optimized to shifts when appropriate. Comparison
162+operators are optimized by maintaining a special cache for the
163+processor flags. &&, || and ! are optimized by maintaining a special
164+'jmp target' value. No other jmp optimization is currently performed
144165 because it would require to store the code in a more abstract fashion.
145166
146167 The types and values descriptions are stored in a single 'int'
@@ -151,10 +172,10 @@ solution. · 4 unmodified lines
151172 License:
152173 -------
153174
154−TCC is distributed under the GNU Generic Public License (see COPYING
175+TCC is distributed under the GNU General Public License (see COPYING
155176 file).
156177
157178 I accept only patches where you give your copyright explictely to me
158179 to simplify licensing issues.
159180
160−Fabrice Bellard - Nov 11, 2001.
181+Fabrice Bellard - Nov 17, 2001.
TODO+8−4
@@ -2,10 +2,12 @@ TODO list: · 1 unmodified line
22
33 Critical:
44
5−- initializers
6−- add hash tables for symbols (useful for long programs)
5+- add structure assign.
6+- fix 'char' and 'short' casts.
77 - 0 is pointer - fix type compare
8+- fix L'' and L"" wide chars
89 - add message if external function or variable not found.
10+- function pointers to forward reference (patch code generator).
911 - add float/double support (should be as small as possible while being
1012 usable for RISC code generator too).
1113
@@ -13,6 +15,8 @@ Not critical: · 1 unmodified line
1315
1416 - fix preprocessor symbol redefinition
1517 - better constant opt (&&, ||, ?:)
16−- function pointers to forward reference (patch code generator)
18+- add ELF executable and shared library output option (would be needed
19+ for completness!).
1720 - add PowerPC code generator.
18−- add portable byte code generator and interpreter.
21+- add portable byte code generator and interpreter for other
22+ unsupported architectures.

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t