-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtcc.1
406 lines (406 loc) · 13 KB
/
tcc.1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
.\" Automatically generated by Pod::Man 2.25 (Pod::Simple 3.16)
.\"
.\" Standard preamble:
.\" ========================================================================
.de Sp \" Vertical space (when we can't use .PP)
.if t .sp .5v
.if n .sp
..
.de Vb \" Begin verbatim text
.ft CW
.nf
.ne \\$1
..
.de Ve \" End verbatim text
.ft R
.fi
..
.\" Set up some character translations and predefined strings. \*(-- will
.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
.\" double quote, and \*(R" will give a right double quote. \*(C+ will
.\" give a nicer C++. Capital omega is used to do unbreakable dashes and
.\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff,
.\" nothing in troff, for use with C<>.
.tr \(*W-
.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
.ie n \{\
. ds -- \(*W-
. ds PI pi
. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
. ds L" ""
. ds R" ""
. ds C` ""
. ds C' ""
'br\}
.el\{\
. ds -- \|\(em\|
. ds PI \(*p
. ds L" ``
. ds R" ''
'br\}
.\"
.\" Escape single quotes in literal strings from groff's Unicode transform.
.ie \n(.g .ds Aq \(aq
.el .ds Aq '
.\"
.\" If the F register is turned on, we'll generate index entries on stderr for
.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
.\" entries marked with X<> in POD. Of course, you'll have to process the
.\" output yourself in some meaningful fashion.
.ie \nF \{\
. de IX
. tm Index:\\$1\t\\n%\t"\\$2"
..
. nr % 0
. rr F
.\}
.el \{\
. de IX
..
.\}
.\"
.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
.\" Fear. Run. Save yourself. No user-serviceable parts.
. \" fudge factors for nroff and troff
.if n \{\
. ds #H 0
. ds #V .8m
. ds #F .3m
. ds #[ \f1
. ds #] \fP
.\}
.if t \{\
. ds #H ((1u-(\\\\n(.fu%2u))*.13m)
. ds #V .6m
. ds #F 0
. ds #[ \&
. ds #] \&
.\}
. \" simple accents for nroff and troff
.if n \{\
. ds ' \&
. ds ` \&
. ds ^ \&
. ds , \&
. ds ~ ~
. ds /
.\}
.if t \{\
. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
. ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
.\}
. \" troff and (daisy-wheel) nroff accents
.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
.ds 8 \h'\*(#H'\(*b\h'-\*(#H'
.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
.ds ae a\h'-(\w'a'u*4/10)'e
.ds Ae A\h'-(\w'A'u*4/10)'E
. \" corrections for vroff
.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
. \" for low resolution devices (crt and lpr)
.if \n(.H>23 .if \n(.V>19 \
\{\
. ds : e
. ds 8 ss
. ds o a
. ds d- d\h'-1'\(ga
. ds D- D\h'-1'\(hy
. ds th \o'bp'
. ds Th \o'LP'
. ds ae ae
. ds Ae AE
.\}
.rm #[ #] #H #V #F C
.\" ========================================================================
.\"
.IX Title "TCC 1"
.TH TCC 1 "2014-04-04" " " " "
.\" For nroff, turn off justification. Always turn off hyphenation; it makes
.\" way too many mistakes in technical documents.
.if n .ad l
.nh
.SH "NAME"
tcc \- Tiny C Compiler
.SH "SYNOPSIS"
.IX Header "SYNOPSIS"
usage: tcc [options] [\fIinfile1\fR \fIinfile2\fR...] [\fB\-run\fR \fIinfile\fR \fIargs\fR...]
.SH "DESCRIPTION"
.IX Header "DESCRIPTION"
\&\s-1TCC\s0 options are a very much like gcc options. The main difference is that \s-1TCC\s0
can also execute directly the resulting program and give it runtime
arguments.
.PP
Here are some examples to understand the logic:
.ie n .IP """\f(CBtcc \-run a.c\f(CW""" 4
.el .IP "\f(CW\f(CBtcc \-run a.c\f(CW\fR" 4
.IX Item "tcc -run a.c"
Compile \fIa.c\fR and execute it directly
.ie n .IP """\f(CBtcc \-run a.c arg1\f(CW""" 4
.el .IP "\f(CW\f(CBtcc \-run a.c arg1\f(CW\fR" 4
.IX Item "tcc -run a.c arg1"
Compile a.c and execute it directly. arg1 is given as first argument to
the \f(CW\*(C`main()\*(C'\fR of a.c.
.ie n .IP """\f(CBtcc a.c \-run b.c arg1\f(CW""" 4
.el .IP "\f(CW\f(CBtcc a.c \-run b.c arg1\f(CW\fR" 4
.IX Item "tcc a.c -run b.c arg1"
Compile \fIa.c\fR and \fIb.c\fR, link them together and execute them. arg1 is given
as first argument to the \f(CW\*(C`main()\*(C'\fR of the resulting program.
.ie n .IP """\f(CBtcc \-o myprog a.c b.c\f(CW""" 4
.el .IP "\f(CW\f(CBtcc \-o myprog a.c b.c\f(CW\fR" 4
.IX Item "tcc -o myprog a.c b.c"
Compile \fIa.c\fR and \fIb.c\fR, link them and generate the executable \fImyprog\fR.
.ie n .IP """\f(CBtcc \-o myprog a.o b.o\f(CW""" 4
.el .IP "\f(CW\f(CBtcc \-o myprog a.o b.o\f(CW\fR" 4
.IX Item "tcc -o myprog a.o b.o"
link \fIa.o\fR and \fIb.o\fR together and generate the executable \fImyprog\fR.
.ie n .IP """\f(CBtcc \-c a.c\f(CW""" 4
.el .IP "\f(CW\f(CBtcc \-c a.c\f(CW\fR" 4
.IX Item "tcc -c a.c"
Compile \fIa.c\fR and generate object file \fIa.o\fR.
.ie n .IP """\f(CBtcc \-c asmfile.S\f(CW""" 4
.el .IP "\f(CW\f(CBtcc \-c asmfile.S\f(CW\fR" 4
.IX Item "tcc -c asmfile.S"
Preprocess with C preprocess and assemble \fIasmfile.S\fR and generate
object file \fIasmfile.o\fR.
.ie n .IP """\f(CBtcc \-c asmfile.s\f(CW""" 4
.el .IP "\f(CW\f(CBtcc \-c asmfile.s\f(CW\fR" 4
.IX Item "tcc -c asmfile.s"
Assemble (but not preprocess) \fIasmfile.s\fR and generate object file
\&\fIasmfile.o\fR.
.ie n .IP """\f(CBtcc \-r \-o ab.o a.c b.c\f(CW""" 4
.el .IP "\f(CW\f(CBtcc \-r \-o ab.o a.c b.c\f(CW\fR" 4
.IX Item "tcc -r -o ab.o a.c b.c"
Compile \fIa.c\fR and \fIb.c\fR, link them together and generate the object file \fIab.o\fR.
.PP
Scripting:
.PP
\&\s-1TCC\s0 can be invoked from \fIscripts\fR, just as shell scripts. You just
need to add \f(CW\*(C`#!/usr/local/bin/tcc \-run\*(C'\fR at the start of your C source:
.PP
.Vb 2
\& #!/usr/local/bin/tcc \-run
\& #include <stdio.h>
\&
\& int main()
\& {
\& printf("Hello World\en");
\& return 0;
\& }
.Ve
.PP
\&\s-1TCC\s0 can read C source code from \fIstandard input\fR when \fB\-\fR is used in
place of \fBinfile\fR. Example:
.PP
.Vb 1
\& echo \*(Aqmain(){puts("hello");}\*(Aq | tcc \-run \-
.Ve
.SH "OPTIONS"
.IX Header "OPTIONS"
.IP "\fB\-c\fR" 4
.IX Item "-c"
Generate an object file.
.IP "\fB\-o outfile\fR" 4
.IX Item "-o outfile"
Put object file, executable, or dll into output file \fIoutfile\fR.
.IP "\fB\-run source [args...]\fR" 4
.IX Item "-run source [args...]"
Compile file \fIsource\fR and run it with the command line arguments
\&\fIargs\fR. In order to be able to give more than one argument to a
script, several \s-1TCC\s0 options can be given \fIafter\fR the
\&\fB\-run\fR option, separated by spaces:
.Sp
.Vb 1
\& tcc "\-run \-L/usr/X11R6/lib \-lX11" ex4.c
.Ve
.Sp
In a script, it gives the following header:
.Sp
.Vb 1
\& #!/usr/local/bin/tcc \-run \-L/usr/X11R6/lib \-lX11
.Ve
.IP "\fB\-dumpversion\fR" 4
.IX Item "-dumpversion"
Print only the compiler version and nothing else.
.IP "\fB\-v\fR" 4
.IX Item "-v"
Display \s-1TCC\s0 version.
.IP "\fB\-vv\fR" 4
.IX Item "-vv"
Show included files. As sole argument, print search dirs (as below).
.IP "\fB\-bench\fR" 4
.IX Item "-bench"
Display compilation statistics.
.IP "\fB\-print\-search\-dirs\fR" 4
.IX Item "-print-search-dirs"
Print the configured installation directory and a list of library
and include directories tcc will search.
.PP
Preprocessor options:
.IP "\fB\-Idir\fR" 4
.IX Item "-Idir"
Specify an additional include path. Include paths are searched in the
order they are specified.
.Sp
System include paths are always searched after. The default system
include paths are: \fI/usr/local/include\fR, \fI/usr/include\fR
and \fIPREFIX/lib/tcc/include\fR. (\fI\s-1PREFIX\s0\fR is usually
\&\fI/usr\fR or \fI/usr/local\fR).
.IP "\fB\-Dsym[=val]\fR" 4
.IX Item "-Dsym[=val]"
Define preprocessor symbol \fBsym\fR to
val. If val is not present, its value is \fB1\fR. Function-like macros can
also be defined: \fB\-DF(a)=a+1\fR
.IP "\fB\-Usym\fR" 4
.IX Item "-Usym"
Undefine preprocessor symbol \fBsym\fR.
.PP
Compilation flags:
.PP
Note: each of the following warning options has a negative form beginning with
\&\fB\-fno\-\fR.
.IP "\fB\-funsigned\-char\fR" 4
.IX Item "-funsigned-char"
Let the \f(CW\*(C`char\*(C'\fR type be unsigned.
.IP "\fB\-fsigned\-char\fR" 4
.IX Item "-fsigned-char"
Let the \f(CW\*(C`char\*(C'\fR type be signed.
.IP "\fB\-fno\-common\fR" 4
.IX Item "-fno-common"
Do not generate common symbols for uninitialized data.
.IP "\fB\-fleading\-underscore\fR" 4
.IX Item "-fleading-underscore"
Add a leading underscore at the beginning of each C symbol.
.PP
Warning options:
.IP "\fB\-w\fR" 4
.IX Item "-w"
Disable all warnings.
.PP
Note: each of the following warning options has a negative form beginning with
\&\fB\-Wno\-\fR.
.IP "\fB\-Wimplicit\-function\-declaration\fR" 4
.IX Item "-Wimplicit-function-declaration"
Warn about implicit function declaration.
.IP "\fB\-Wunsupported\fR" 4
.IX Item "-Wunsupported"
Warn about unsupported \s-1GCC\s0 features that are ignored by \s-1TCC\s0.
.IP "\fB\-Wwrite\-strings\fR" 4
.IX Item "-Wwrite-strings"
Make string constants be of type \f(CW\*(C`const char *\*(C'\fR instead of \f(CW\*(C`char
*\*(C'\fR.
.IP "\fB\-Werror\fR" 4
.IX Item "-Werror"
Abort compilation if warnings are issued.
.IP "\fB\-Wall\fR" 4
.IX Item "-Wall"
Activate all warnings, except \fB\-Werror\fR, \fB\-Wunusupported\fR and
\&\fB\-Wwrite\-strings\fR.
.PP
Linker options:
.IP "\fB\-Ldir\fR" 4
.IX Item "-Ldir"
Specify an additional static library path for the \fB\-l\fR option. The
default library paths are \fI/usr/local/lib\fR, \fI/usr/lib\fR and \fI/lib\fR.
.IP "\fB\-lxxx\fR" 4
.IX Item "-lxxx"
Link your program with dynamic library libxxx.so or static library
libxxx.a. The library is searched in the paths specified by the
\&\fB\-L\fR option.
.IP "\fB\-Bdir\fR" 4
.IX Item "-Bdir"
Set the path where the tcc internal libraries (and include files) can be
found (default is \fIPREFIX/lib/tcc\fR).
.IP "\fB\-shared\fR" 4
.IX Item "-shared"
Generate a shared library instead of an executable.
.IP "\fB\-soname name\fR" 4
.IX Item "-soname name"
set name for shared library to be used at runtime
.IP "\fB\-static\fR" 4
.IX Item "-static"
Generate a statically linked executable (default is a shared linked
executable).
.IP "\fB\-rdynamic\fR" 4
.IX Item "-rdynamic"
Export global symbols to the dynamic linker. It is useful when a library
opened with \f(CW\*(C`dlopen()\*(C'\fR needs to access executable symbols.
.IP "\fB\-r\fR" 4
.IX Item "-r"
Generate an object file combining all input files.
.IP "\fB\-Wl,\-rpath=path\fR" 4
.IX Item "-Wl,-rpath=path"
Put custom seatch path for dynamic libraries into executable.
.IP "\fB\-Wl,\-\-oformat=fmt\fR" 4
.IX Item "-Wl,--oformat=fmt"
Use \fIfmt\fR as output format. The supported output formats are:
.RS 4
.ie n .IP """elf32\-i386""" 4
.el .IP "\f(CWelf32\-i386\fR" 4
.IX Item "elf32-i386"
\&\s-1ELF\s0 output format (default)
.ie n .IP """binary""" 4
.el .IP "\f(CWbinary\fR" 4
.IX Item "binary"
Binary image (only for executable output)
.ie n .IP """coff""" 4
.el .IP "\f(CWcoff\fR" 4
.IX Item "coff"
\&\s-1COFF\s0 output format (only for executable output for TMS320C67xx target)
.RE
.RS 4
.RE
.IP "\fB\-Wl,\-subsystem=console/gui/wince/...\fR" 4
.IX Item "-Wl,-subsystem=console/gui/wince/..."
Set type for \s-1PE\s0 (Windows) executables.
.IP "\fB\-Wl,\-[Ttext=# | section\-alignment=# | file\-alignment=# | image\-base=# | stack=#]\fR" 4
.IX Item "-Wl,-[Ttext=# | section-alignment=# | file-alignment=# | image-base=# | stack=#]"
Modify executable layout.
.IP "\fB\-Wl,\-Bsymbolic\fR" 4
.IX Item "-Wl,-Bsymbolic"
Set \s-1DT_SYMBOLIC\s0 tag.
.PP
Debugger options:
.IP "\fB\-g\fR" 4
.IX Item "-g"
Generate run time debug information so that you get clear run time
error messages: \f(CW\*(C` test.c:68: in function \*(Aqtest5()\*(Aq: dereferencing
invalid pointer\*(C'\fR instead of the laconic \f(CW\*(C`Segmentation
fault\*(C'\fR.
.IP "\fB\-b\fR" 4
.IX Item "-b"
Generate additional support code to check
memory allocations and array/pointer bounds. \fB\-g\fR is implied. Note
that the generated code is slower and bigger in this case.
.Sp
Note: \fB\-b\fR is only available on i386 for the moment.
.IP "\fB\-bt N\fR" 4
.IX Item "-bt N"
Display N callers in stack traces. This is useful with \fB\-g\fR or
\&\fB\-b\fR.
.PP
Misc options:
.IP "\fB\-MD\fR" 4
.IX Item "-MD"
Generate makefile fragment with dependencies.
.IP "\fB\-MF depfile\fR" 4
.IX Item "-MF depfile"
Use \fIdepfile\fR as output for \-MD.
.PP
Note: \s-1GCC\s0 options \fB\-Ox\fR, \fB\-fx\fR and \fB\-mx\fR are
ignored.
.SH "SEE ALSO"
.IX Header "SEE ALSO"
\&\fIgcc\fR\|(1)
.SH "AUTHOR"
.IX Header "AUTHOR"
Fabrice Bellard