CCOM(1)

NAME
ccom - C compiler

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

DESCRIPTION
The ccom utility provides a C compiler. The frontend is usually pcc(1). It is not intended to be run directly. ccom reads the C source from infile or standard input and writes the assembler source to outfile or to standard output.

The options are as follows:

-f feature
    Enable language features. Multiple -f options can be given, the following features are supported:

    stack-protector
        Enable stack smashing protection. Currently the same as stack-protector-all.

    stack-protector-all
        Enable stack smashing protection for all functions.

    pack-struct[=n]
        Specify maximum alignment for structure members, similar to a #pragma pack statement at the start of the file. If no value is given, the default is 1.

    freestanding
        Emit code for a freestanding environment. Currently not implemented.

-g  Include debugging information in the output code for use by symbolic and source-level debuggers. Currently this uses the stabs format, encoding information in symbol table entries.

-k  Generate PIC code.

-m option
    Target-specific options, used in machine-dependent code. Multiple -m options can be given, the following options are supported:

    AMD64

    ARM little-endian, big-endian, fpe=fpa, fpe=vpf, soft-float, arch=armv1, arch=armv2, arch=armv2a, arch=armv3, arch=armv4, arch=armv4t, arch=armv4tej, arch=armv5, arch=armv5te, arch=armv5tej, arch=armv6, arch=armv6t2, arch=armv6kz, arch=armv6k & arch=armv7.

    HPPA

    i386

    M16C

    MIPS
        little-endian & big-endian.

    NOVA

    PDP-10

    PDP-11

    PowerPC
        little-endian, big-endian, soft-float & hard-float.

    Sparc64

    VAX

-p  Generate profiling code.

-s  Print statistics to standard error when complete. This includes: name table entries, name string size, permanent allocated memory, temporary allocated memory, lost memory, argument list unions, dimension/function unions, struct/union/enum blocks, inline node count, inline control blocks, and permanent symtab entries.

-v  Display version.

-W warning
    Do some basic checks and emit warnings about possible coding problems. Multiple -W options can be given, the following warnings are supported:

    error[=warning]
        Enable warning, and treat it as an error condition. If a specific warning is not given, producing any warning will cause an error.

    attributes
        Warn when unsupported attributes are used. This warning is enabled by default.

    deprecated-declarations
        Report whenever a symbol marked with the ‘deprecated’ attribute is used. This warning is enabled by default.

    implicit-function-declaration
        (TODO) Require explicit prototypes for all called functions.

    implicit-int
        (TODO) Warn when a function declaration lacks a type.

    missing-prototypes
        Require explicit prototypes for all global function definitions.

    pointer-sign
        Warn when pointer operations are done with mismatched signed and unsigned values.

    sign-compare
        (TODO) Warn about comparisons between signed and unsigned values.

    strict-prototypes
        (TODO) Require that function prototypes are strictly C99.

    shadow
        Report when a local variable shadows something from a higher scope.

    truncate
        Report when integer values may be implicitly truncated to fit a smaller type.

    uninitialized
        A variable is read before being written.

    unknown-pragmas
        Report unhandled pragma statements.

    unreachable-code
        Report statements that cannot be executed.

    Any of the above may be prefixed with “no-” in order to disable the effect.

-X flags
    C specific debugging where flags is one or more of the following:

    b   Building of parse trees
    d   Declarations (using multiple d flags gives more output)
    e   Pass1 trees at exit
    i   Initializations
    n   Memory allocations
    o   Turn off optimisations
    p   Prototypes
    s   Inlining
    t   Type conversions
    x   Target-specific flag, used in machine-dependent code

-x setting
    Enable setting in the compiler. Multiple -x options can be given, the following settings are supported:

    ccp Apply sparse conditional constant propagation techniques for optimization. Currently not implemented.

    dce Do dead code elimination.

    deljumps
        Delete redundant jumps and dead code.

    gnu89

    gnu99
        Use GNU C semantics rather than C99 for some things. Currently only inline.

    inline
        Replace calls to functions marked with an inline specifier with a copy of the actual function.

    ssa Convert statements into static single assignment form for optimization. Not yet finished.

    tailcall
        Enable optimization of tail-recursion functions. Currently not implemented.

    temps
        Locate automatic variables into registers where possible, for further optimization by the register allocator.

    uchar
        Treat character constants as unsigned values.

-Z flags
    Code generator (pass2) specific debugging where flags is one or more of the following:

    b   Basic block and SSA building
    c   Code printout
    e   Trees when entering pass2
    f   Instruction matcher, may provide much output
    g   Print flow graphs
    n   Memory allocation
    o   Instruction generator
    r   Register allocator
    s   Shape matching in instruction generator
    t   Type matching in instruction generator
    u   Sethi-Ullman computations
    x   Target-specific flag, used in machine-dependent code

PRAGMAS
Input lines starting with a “#pragma” directive can be used to modify behaviour of ccom during compilation. All tokens up to the first unescaped newline are considered part of the pragma command, with the following operations being recognized:

STDC
    Standard C99 operator follows. Currently no C99 operations are implemented, and any directives starting with this token will be silently ignored.

GCC diagnostic effect "option"
    GNU C compatibility. Alter the effects of compiler diagnostics. The required effect should be stated as warning, error or ignored, followed by the compiler diagnostic option in double quotes. For example, to force unknown pragmas to always generate an error, a standard header might include

        #pragma GCC diagnostic error "-Wunknown-pragmas"

GCC poison identifier ...
    GNU C compatibility. Cause an error if any of the following identifiers subsequently appear in the code (but not in any macro expansions). Currently not implemented.

GCC system_header
    GNU C compatibility. Currently not implemented.

GCC visibility
    GNU C compatibility. Currently not implemented.

pack([n])
    Set the default maximum alignment for structures and unions, such that members will have their natural alignment requirements clamped at this value and may be stored misaligned. If n is not given, the alignment is reset to the target default.

pack(push[, n])
    Push the current pack setting onto an internal stack then, if n is given, change the default alignment for structures and unions. Currently not implemented.

pack(pop)
    Change the pack setting to the most recently pushed value, and remove that setting from the stack. Currently not implemented.

packed [n]
    Set the maximum alignment for the structure or union defined in the current statement. If n is not given, the default value of 1 is used. (Currently this works except n is not used)

aligned [n]
    Set the minimum alignment for the structure or union defined in the current statement.

rename name
    Provide an alternative name which will be used to reference the object declared in the current statement.

weak name[=alias]
    Mark name as a weak rather than a global symbol, to allow its definition to be overridden at link time. If an alias is given, this will be used as the default value of name.

ident
    Currently not implemented.

and the following target-specific operations are handled by machine-dependent code:

tls For AMD64 and i386 targets, the variable declared in the current statement will be referenced via the “thread-local storage” mechanism.

init
    For AMD64, ARM, HPPA, i386, MIPS and PowerPC targets, when the current statement is a function declaration, generate a reference in the .ctors section, enabling library code to call the function prior to entering main().

fini
    For AMD64, ARM, HPPA, i386, MIPS and PowerPC targets, when the current statement is a function declaration, generate a reference in the .dtors section, enabling library code to call the function when main() returns or the exit() function is called.

section name
    For AMD64, ARM, HPPA and i386 targets, place the subsequent code in the named section. (This is currently broken).

alias name
    For AMD64, HPPA and i386 targets, emit assembler instructions providing an alias for the symbol defined by the current statement.

stdcall
    For i386 targets, enable “stdcall” semantics during code generation, where function arguments are passed on the stack in right-to-left order, and the callee is responsible for adjusting the stack pointer before returning. Any function result is passed in the EAX register. On win32, the function name is postfixed with an “@” and the size of the stack adjustment.

cdecl
    For i386 targets, enable “cdecl” semantics during code generation, where function arguments are passed on the stack in right-to-left order, and the caller is responsible for cleaning up the stack after the function returns. Any function result is passed in the EAX register. This is the default.

fastcall
    For i386-win32 targets, enable “fastcall” semantics during code generation. ( Currently this is equivalent to stdcall, which is likely wrong).

dllimport
    For i386-win32 targets, references to the external symbol defined by the current statement will be made via indirect access through a location identified by the symbol name prefixed with “__imp_”.

dllexport
    For i386-win32 targets, the external symbol declared by the current statement will be exported as an indirect reference to be accessed with dllimport. The global locator will be the symbol name prefixed with “__imp_”. Currently this is not completely implemented.

Any unknown “#pragma” directives will be ignored unless the -Wunknown-pragmas diagnostic is in effect.

SEE ALSO
as(1), cpp(1), pcc(1)

HISTORY
The ccom compiler is based on the original Portable C Compiler by S. C. Johnson, written in the late 70's. Even though much of the compiler has been rewritten (about 50% of the frontend code and 80% of the backend), some of the basics still remain. Most is written by Anders Magnusson, with the exception of the data-flow analysis part and the SSA conversion code which is written by Peter A Jonsson, and the Mips port that were written as part of a project by undergraduate students at Lulea University of Technology.

This product includes software developed or owned by Caldera International, Inc.