1CCOM(1)                   BSD General Commands Manual                  CCOM(1)
2

NAME

4     ccom — C compiler
5

SYNOPSIS

7     ccom [-gkpsv] [-f features] [-m options] [-W warnings] [-X flags]
8          [-x settings] [-Z flags] [infile] [outfile]
9

DESCRIPTION

11     The ccom utility provides a C compiler.  The frontend is usually pcc(1).
12     It is not intended to be run directly.  ccom reads the C source from
13     infile or standard input and writes the assembler source to outfile or to
14     standard output.
15
16     The options are as follows:
17
18     -f feature
19             Enable language features.  Multiple -f options can be given, the
20             following features are supported:
21
22             stack-protector
23                     Enable stack smashing protection.  Currently the same as
24                     stack-protector-all.
25
26             stack-protector-all
27                     Enable stack smashing protection for all functions.
28
29             pack-struct[=n]
30                     Specify maximum alignment for structure members, similar
31                     to a #pragma pack statement at the start of the file.  If
32                     no value is given, the default is 1.
33
34             freestanding
35                     Emit code for a freestanding environment.  Currently not
36                     implemented.
37
38     -g      Include debugging information in the output code for use by sym‐
39             bolic and source-level debuggers.  Currently this uses the stabs
40             format, encoding information in symbol table entries.
41
42     -k      Generate PIC code.
43
44     -m option
45             Target-specific options, used in machine-dependent code.  Multi‐
46             ple -m options can be given, the following options are supported:
47
48             AMD64
49
50             ARM      little-endian, big-endian, fpe=fpa, fpe=vpf, soft-float,
51                      arch=armv1, arch=armv2, arch=armv2a, arch=armv3,
52                      arch=armv4, arch=armv4t, arch=armv4tej, arch=armv5,
53                      arch=armv5te, arch=armv5tej, arch=armv6, arch=armv6t2,
54                      arch=armv6kz, arch=armv6k & arch=armv7.
55
56             HPPA
57
58             i386
59
60             M16C
61
62             MIPS     little-endian & big-endian.
63
64             NOVA
65
66             PDP-10
67
68             PDP-11
69
70             PowerPC  little-endian, big-endian, soft-float & hard-float.
71
72             Sparc64
73
74             VAX
75
76     -p      Generate profiling code.
77
78     -s      Print statistics to standard error when complete.  This includes:
79             name table entries, name string size, permanent allocated memory,
80             temporary allocated memory, lost memory, argument list unions,
81             dimension/function unions, struct/union/enum blocks, inline node
82             count, inline control blocks, and permanent symtab entries.
83
84     -v      Display version.
85
86     -W warning
87             Do some basic checks and emit warnings about possible coding
88             problems.  Multiple -W options can be given, the following warn‐
89             ings are supported:
90
91             error[=warning]
92                     Enable warning, and treat it as an error condition.  If a
93                     specific warning is not given, producing any warning will
94                     cause an error.
95
96             deprecated-declarations
97                     Report whenever a symbol marked with the ‘deprecated’
98                     attribute is used.  This warning is enabled by default.
99
100             implicit-function-declaration
101                     (TODO) Require explicit prototypes for all called func‐
102                     tions.
103
104             implicit-int
105                     (TODO) Warn when a function declaration lacks a type.
106
107             missing-prototypes
108                     Require explicit prototypes for all global function defi‐
109                     nitions.
110
111             pointer-sign
112                     Warn when pointer operations are done with mismatched
113                     signed and unsigned values.
114
115             sign-compare
116                     (TODO) Warn about comparisons between signed and unsigned
117                     values.
118
119             strict-prototypes
120                     (TODO) Require that function prototypes are strictly C99.
121
122             shadow  Report when a local variable shadows something from a
123                     higher scope.
124
125             truncate
126                     Report when integer values may be implicitly truncated to
127                     fit a smaller type.
128
129             unknown-pragmas
130                     Report unhandled pragma statements.
131
132             unreachable-code
133                     Report statements that cannot be executed.
134
135             Any of the above may be prefixed with “no-” in order to disable
136             the effect.
137
138     -X flags
139             C specific debugging where flags is one or more of the following:
140
141             b       Building of parse trees
142             d       Declarations (using multiple d flags gives more output)
143             e       Pass1 trees at exit
144             i       Initializations
145             n       Memory allocations
146             o       Turn off optimisations
147             p       Prototypes
148             s       Inlining
149             t       Type conversions
150             x       Target-specific flag, used in machine-dependent code
151
152     -x setting
153             Enable setting in the compiler.  Multiple -x options can be
154             given, the following settings are supported:
155
156             ccp     Apply sparse conditional constant propagation techniques
157                     for optimization.  Currently not implemented.
158
159             dce     Do dead code elimination.
160
161             deljumps
162                     Delete redundant jumps and dead code.
163
164             gnu89
165
166             gnu99   Use GNU C semantics rather than C99 for some things.
167                     Currently only inline.
168
169             inline  Replace calls to functions marked with an inline speci‐
170                     fier with a copy of the actual function.
171
172             ssa     Convert statements into static single assignment form for
173                     optimization.  Not yet finished.
174
175             tailcall
176                     Enable optimization of tail-recursion functions.  Cur‐
177                     rently not implemented.
178
179             temps   Locate automatic variables into registers where possible,
180                     for further optimization by the register allocator.
181
182             uchar   Treat character constants as unsigned values.
183
184     -Z flags
185             Code generator (pass2) specific debugging where flags is one or
186             more of the following:
187
188             b       Basic block and SSA building
189             c       Code printout
190             e       Trees when entering pass2
191             f       Instruction matcher, may provide much output
192             g       Print flow graphs
193             n       Memory allocation
194             o       Instruction generator
195             r       Register allocator
196             s       Shape matching in instruction generator
197             t       Type matching in instruction generator
198             u       Sethi-Ullman computations
199             x       Target-specific flag, used in machine-dependent code
200

PRAGMAS

202     Input lines starting with a “#pragma” directive can be used to modify be‐
203     haviour of ccom during compilation.  All tokens up to the first unescaped
204     newline are considered part of the pragma command, with the following
205     operations being recognized:
206
207     STDC    Standard C99 operator follows.  Currently no C99 operations are
208             implemented, and any directives starting with this token will be
209             silently ignored.
210
211     GCC diagnostic effect "option"
212             GNU C compatibility.  Alter the effects of compiler diagnostics.
213             The required effect should be stated as warning, error or
214             ignored, followed by the compiler diagnostic option in double
215             quotes.  For example, to force unknown pragmas to always generate
216             an error, a standard header might include
217
218               #pragma GCC diagnostic error "-Wunknown-pragmas"
219
220     GCC poison identifier ...
221             GNU C compatibility.  Cause an error if any of the following
222             identifiers subsequently appear in the code (but not in any macro
223             expansions).  Currently not implemented.
224
225     GCC system_header
226             GNU C compatibility.  Currently not implemented.
227
228     GCC visibility
229             GNU C compatibility.  Currently not implemented.
230
231     pack([n])
232             Set the default maximum alignment for structures and unions, such
233             that members will have their natural alignment requirements
234             clamped at this value and may be stored misaligned.  If n is not
235             given, the alignment is reset to the target default.
236
237     pack(push[, n])
238             Push the current pack setting onto an internal stack then, if n
239             is given, change the default alignment for structures and unions.
240             Currently not implemented.
241
242     pack(pop)
243             Change the pack setting to the most recently pushed value, and
244             remove that setting from the stack.  Currently not implemented.
245
246     packed [n]
247             Set the maximum alignment for the structure or union defined in
248             the current statement.  If n is not given, the default value of 1
249             is used.  (Currently this works except n is not used)
250
251     aligned [n]
252             Set the minimum alignment for the structure or union defined in
253             the current statement.
254
255     rename name
256             Provide an alternative name which will be used to reference the
257             object declared in the current statement.
258
259     weak name[=alias]
260             Mark name as a weak rather than a global symbol, to allow its
261             definition to be overridden at link time.  If an alias is given,
262             this will be used as the default value of name.
263
264     ident   Currently not implemented.
265
266     and the following target-specific operations are handled by machine-
267     dependent code:
268
269     tls     For AMD64 and i386 targets, the variable declared in the current
270             statement will be referenced via the “thread-local storage” mech‐
271             anism.
272
273     init    For AMD64, ARM, HPPA, i386, MIPS and PowerPC targets, when the
274             current statement is a function declaration, generate a reference
275             in the .ctors section, enabling library code to call the function
276             prior to entering main().
277
278     fini    For AMD64, ARM, HPPA, i386, MIPS and PowerPC targets, when the
279             current statement is a function declaration, generate a reference
280             in the .dtors section, enabling library code to call the function
281             when main() returns or the exit() function is called.
282
283     section name
284             For AMD64, ARM, HPPA and i386 targets, place the subsequent code
285             in the named section.  (This is currently broken).
286
287     alias name
288             For AMD64, HPPA and i386 targets, emit assembler instructions
289             providing an alias for the symbol defined by the current state‐
290             ment.
291
292     stdcall
293             For i386 targets, enable “stdcall” semantics during code genera‐
294             tion, where function arguments are passed on the stack in right-
295             to-left order, and the callee is responsible for adjusting the
296             stack pointer before returning.  Any function result is passed in
297             the EAX register.  On win32, the function name is postfixed with
298             an “@” and the size of the stack adjustment.
299
300     cdecl   For i386 targets, enable “cdecl” semantics during code genera‐
301             tion, where function arguments are passed on the stack in right-
302             to-left order, and the caller is responsible for cleaning up the
303             stack after the function returns.  Any function result is passed
304             in the EAX register.  This is the default.
305
306     fastcall
307             For i386-win32 targets, enable “fastcall” semantics during code
308             generation.  (Currently this is equivalent to stdcall, which is
309             likely wrong).
310
311     dllimport
312             For i386-win32 targets, references to the external symbol defined
313             by the current statement will be made via indirect access through
314             a location identified by the symbol name prefixed with “__imp_”.
315
316     dllexport
317             For i386-win32 targets, the external symbol declared by the cur‐
318             rent statement will be exported as an indirect reference to be
319             accessed with dllimport.  The global locator will be the symbol
320             name prefixed with “__imp_”.  Currently this is not completely
321             implemented.
322
323     Any unknown “#pragma” directives will be ignored unless the
324     -Wunknown-pragmas diagnostic is in effect.
325

SEE ALSO

327     as(1), cpp(1), pcc(1)
328

HISTORY

330     The ccom compiler is based on the original Portable C Compiler by S. C.
331     Johnson, written in the late 70's.  Even though much of the compiler has
332     been rewritten (about 50% of the frontend code and 80% of the backend),
333     some of the basics still remain.  Most is written by Anders Magnusson,
334     with the exception of the data-flow analysis part and the SSA conversion
335     code which is written by Peter A Jonsson, and the Mips port that were
336     written as part of a project by undergraduate students at Lulea Univer‐
337     sity of Technology.
338
339     This product includes software developed or owned by Caldera Interna‐
340     tional, Inc.
341
342BSD                             March 22, 2012                             BSD
Impressum