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
|
.\" $Id: cc.1,v 1.1 2007/10/07 17:58:50 otto Exp $
.\" $NetBSD$
.\" $OpenBSD: cc.1,v 1.1 2007/10/07 17:58:50 otto Exp $
."\
.\" Copyright (c) 2007 Jeremy C. Reed <reed@reedmedia.net>
.\"
.\" Permission to use, copy, modify, and/or distribute this software for any
.\" purpose with or without fee is hereby granted, provided that the above
.\" copyright notice and this permission notice appear in all copies.
.\"
.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR AND CONTRIBUTORS DISCLAIM
.\" ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
.\" WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL AUTHOR AND
.\" CONTRIBUTORS BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
.\" DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
.\" PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
.\" ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
.\" THIS SOFTWARE.
.\"
.Dd September 14, 2007
.Dt cc 1
.Os
.Sh NAME
.Nm cc
.Nd front-end to the C compiler
.Sh SYNOPSIS
.Nm
.Op Fl cEgkLMPOStvxX
.Op Fl fPIC
.Op Fl fpic
.Op Fl nostartfiles
.Op Fl nostdinc
.Op Fl nostdlib
.Op Fl pg
.Op Fl pthread
.Op Fl static
.Op Fl B Ar prefix
.Op Fl D Ar macro[=value]
.Op Fl d Ar option
.Op Fl I Ar directory
.Op Fl include Ar path
.Op Fl isystem Ar path
.Op Fl o Ar outfile
.Op Fl Wl Ar flags
.Op Ar
.Pp
.Sh DESCRIPTION
The
.Nm
utility provides a front-end to the
.Dq portable C compiler.
Multiple files may be given on the command line.
Unrecognized options are all sent directly to
.Xr ld 1 .
.Pp
.\" Brief description of its syntax:
Filenames that end with
.Sy .c
are passed via
.Xr cpp 1 ->
.Xr ccom 1 ->
.Xr as 1 ->
.Xr ld 1 .
.Pp
Filenames that end with
.Sy .i
are passed via
.Xr ccom 1 ->
.Xr as 1 ->
.Xr ld 1 .
.Pp
Filenames that end with
.Sy .s
are passed via
.Xr as 1 ->
.Xr ld 1 .
.Pp
Filenames that end with
.Sy .o
are passed directly to
.Xr ld 1 .
.Pp
.\"
The options are as follows:
.Bl -tag -width Ds
.It Fl B Ar prefix
Define alternate prefix path for
.Xr cpp 1 ,
.Xr ccom 1 ,
.Xr as 1 ,
or
.Xr ld 1
executables.
.\" TODO: provide an example of -B
.It Fl C
Passed to the
.Xr cpp 1
preprocessor to not discard comments.
.It Fl c
Only compile or assemble and then stop.
Do not link.
The resulting object output is saved
as a filename with a
.Dq .o
suffix unless
.Fl o
option is used.
Note: cannot be combined with
.Fl o
if multiple files are given.
.It Fl D Ar macro[=value]
Passed to the
.Xr cpp 1
preprocessor to define
.Ar macro .
.It Fl d Ar option
Passed to the
.Xr as 1
assembler.
.\" TODO: what is as -dfoo for?
.It Fl E
Stop after preprocessing with
.Xr cpp 1 .
Do not compile, assemble, or link.
Output is sent to standard output unless the
.Fl o
option is used.
.It Fl fPIC
Generate PIC code.
.\" TODO: document about avoiding machine-specific maximum size?
.It Fl fpic
Tells C compiler to generate PIC code
and tells assembler that PIC code has been generated.
.\" TODO: document difference between PIC and pic
.\" other -f GCC compatibility flags are ignored for now
.It Fl g
Send
.Fl g
flag to
.Xr ccom 1
to create debug output.
This unsets the
.Fl O
option.
.It Fl I Ar path
Passed to the
.Xr cpp 1
preprocessor to add header search directory to override system defaults.
.It Fl include Ar file
Tells the
.Xr cpp 1
preprocessor to include the
.Ar file
during preprocessing.
.It Fl isystem Ar path
Defines
.Ar path
as a system header directory for the
.Xr cpp 1
preprocessor.
.It Fl k
Generate PIC code.
See
.Fl fpic
option.
.It Fl L
.\" TODO
.It Fl M
Pass
.Fl M
flag to
.Xr cpp 1
to generate dependencies for
.Xr make 1 .
.It Fl nostartfiles
.\" TODO
.It Fl nostdinc
.\" TODO
.It Fl nostdlib
.\" TODO
.\" implies -nostartfiles ??
.It Fl O
Enable optimizations.
Currently passes
.Fl xdeljumps
and
.Fl xtemps
to
.Xr ccom 1 .
Note: this is unset if
.Fl g
option is set.
.It Fl o Ar outfile
Save result to
.Ar outfile .
.It Fl P
TODO: what is this?
.\" TODO: Looks like it does cpp only, but I couldn't get it to work for me.
.It Fl pg
Not implemented.
.It Fl pthread
Defines
.Sy _PTHREADS
preprocessor directive for
.Xr cpp 1 .
Uses
.Sy -lpthread
for
.Xr ld 1 linker.
.It Fl S
Stop after compilation by
.Xr ccom 1 .
Do not assemble and do not link.
The resulting assembler-language output is saved
as a filename with a
.Dq .s
suffix unless the
.Fl o
option is used.
Note: cannot be combined with
.Fl o
if multiple files are given.
.It Fl static
Do not use dynamic linkage.
By default, it will link using the dynamic linker options
and/or shared objects for the platform.
.It Fl t
Passes
.Fl t
to
.Xr cpp 1
for traditional C preprocessor syntax.
.It Fl U Ar macro
Passes to the
.Xr cpp 1
preprocessor to remove the initial macro definition.
.It Fl v
Outputs the version of
.Nm
and shows what commands will be ran with their command line arguments.
.It Fl Wl Ar flags
Options for the linker
.\" what is ignored? llist?
.It Fl X
TODO
.It Fl x
TODO
.El
.Sh Predefined Macros
A few
macros are predefined by
.Nm
went sent to
.Xr cpp 1 .
.Bl -diag
.\" TODO:
.\" .It __ASSEMBLER__
.\" Defined if suffix is .S -- why not with .s? what does this mean?
.It __PCC__
Set to the major version of
.Xr pcc 1 .
These macros can be used to select code based on
.Xr pcc 1
compatibility.
See
.Fl v
option.
.It __PCC_MINOR__
Set to the minor version.
.It __PCC_MINORMINOR__
Set to the minor-minor version -- the number after the minor version.
.It _PTHREADS
Defined when
.Fl pthread
switch is used.
.El
.Pp
Also system- and/or machine-dependent macros may also be predefined;
for example:
.Dv __NetBSD__ ,
.Dv __ELF__ ,
and
.Dv __i386__ .
.Sh SEE ALSO
.Xr as 1 ,
.Xr ccom 1 ,
.Xr cpp 1 ,
.Xr ld 1
.Sh HISTORY
The
.Nm
command comes from the original Portable C Compiler by S. C.
Johnson, written in the late 70's.
.Pp
This product includes software developed or owned by Caldera
International, Inc.
|