Amiga Unix — 68040 · 68060

Manual pages › General commands (1)

cc(1)

C compiler

From the original Amiga UNIX 2.1 manual. Some things it mentions may not be in this release.

Also by this name: cc(1B), BSD versions of commands

NAME · SYNOPSIS · DESCRIPTION · FILES · SEE ALSO · NOTES

NAME

cc - C compiler

SYNOPSIS

/usr/ccs/bin/cc [options] file ...

DESCRIPTION

cc is the interface to the C compilation system. The compilation tools conceptually consist of a preprocessor, compiler, optimizer, basic block analyzer, assembler, and link editor. cc processes the supplied options and then executes the various tools with the proper arguments. cc accepts several types of files as arguments.

Files whose names end with .c are taken to be C source files and may be preprocessed, compiled, optimized, instrumented for profiling, assembled, and link edited. The compilation process may be stopped after the completion of any pass if the appropriate options are supplied. If the compilation process runs through the assembler, then an object file is produced whose name is that of the source with .o substituted for .c. However, the .o file is normally deleted if a single C file is compiled and then immediately link edited. In the same way, files whose names end in .s are taken to be assembly source files; they may be assembled and link edited. Files whose names end in .i are taken to be preprocessed C source files, and they may be compiled, optimized, instrumented for profiling, assembled, and link edited. Files whose names do not end in .c, .s, or .i are handed to the link editor, which produces a dynamically linked executable whose name by default is a.out.

Since cc usually creates files in the current directory during the compilation process, it is necessary to run cc in a directory in which a file can be created.

The following options are interpreted by cc:

-A name[(tokens)]

Associates name as a predicate with the specified tokens as if by a #assert preprocessing directive.

     Preassertions:system(unix)
                 cpu(m68k)
                 machine(m68k)

-A - Causes all predefined macros  (other  than  those  that
     begin  with __) and predefined assertions to be forgot-
     ten.

-B c c can be either dynamic or static.  -B  dynamic  causes
     the  link  editor  to  look for files named libx.so and
     then for files named libx.a when given the -lx  option.
     -B static causes the link editor to look only for files
     named libx.a.  This option may  be  specified  multiple
     times on the command line as a toggle.  This option and
     its argument are passed to ld.

-C   Cause the preprocessing phase to pass  along  all  com-
     ments  other  than  those  on  preprocessing  directive
     lines.

-c Suppress the link editing phase of the compilation and do not remove any produced object files.

-D name[=tokens]

Associates name with the specified tokens as if by a #define preprocessing directive. If no =tokens is specified, the token 1 is supplied.

     Predefinitions:m68k

                 unix

-d c c can be either y or n.  -dy specifies dynamic linking,
     which  is  the default, in the link editor.  -dn speci-
     fies static linking in the link  editor.   This  option
     and its argument are passed to ld.

-E Only preprocess the named C files and send the result to the standard output. The output will contain preprocessing directives for use by the next pass of the compilation system.

-f This option is obsolete and will be ignored.

-G Used to direct the link editor to produce a shared object rather than a dynamically linked executable. This option is passed to ld. It cannot be used with the -dn option.

-g Cause the compiler to generate additional information needed for the use of sdb. Use of sdb on a program compiled with both the -g and -O options is not recommended unless the user understands the behavior of optimization.

-H Print, one per line, the path name of each file included during the current compilation on the standard error output.

-I dir

Alter the search for included files whose names do not begin with / to look in dir prior to the usual directories. The directories for multiple -I options are searched in the order specified.

-J sfm

Specify the assembly language source math library, libsfm.sa. This library is searched when its name is encountered, so the placement of this option is significant. Note that this is a special-purpose library and should be used only when necessary [see intro(3M)]. This option and its argument are passed to the optimizer only when both -O and -Ksd are also specified.

-K [mode, goal, PIC, minabi]

     -K mode

mode can be either fpe (software floating point emulation) or mau (hardware math accelerator unit). Compile with the indicated floating-point mode.

-K goal

goal can be either sd to optimize for speed, or sz to optimize for size; either have an effect only if the -O option is also specified.

-K PIC

Causes position-independent code (PIC) to be generated.

-K minabi

Directs the compilation system to use a version of the C library that minimizes dynamic linking, without changing the application's ABI conformance (or non-conformance, as the case may be). Applications that use the Network Services Library or the X library may not use -K minabi.

The -K option can accept multiple arguments. For example,

-K fpe,sz can be used instead of -K fpe -K sz.

-L dir

Add dir to the list of directories searched for libraries by ld. This option and its argument are passed to ld.

-l name

Search the library libname.so or libname.a. Its placement on the command line is significant as a library is searched at a point in time relative to the placement of other libraries and object files on the command line. This option and its argument are passed to ld.

-O Arrange for compilation phase optimization. This option has no effect on .s files.

-o pathname

Produce an output object file pathname, instead of the default a.out. This option and its argument are passed to ld.

-P Only preprocess the named C files and leave the result in corresponding files suffixed .i. The output will not contain any preprocessing directives, unlike -E.

-p Arrange for the compiler to produce code that counts the number of times each routine is called; also, if link editing takes place, profiled versions of libc.a and libm.a (with the -lm option) are linked if the -dn option is used. A mon.out file will then be produced at normal termination of execution of the object program. An execution profile can then be generated by use of prof.

-Q c c can be either y or n.   If  c  is  y,  identification
     information about each invoked compilation tool will be
     added to the output files (the default behavior).  This
     can  be  useful  for software administration.  Giving n
     for c suppresses this information.

-q c c can be either l or p.  -ql causes the  invocation  of
     the  basic  block analyzer and arranges for the produc-
     tion of code that  counts  the  number  of  times  each
     source line is executed.  A listing of these counts can
     be generated by use of lprof.  -qp is a synonym for -p.

-S Compile, optimize (if -O is present), and do not assemble or link edit the named C files. The assemblerlanguage output is left in corresponding files suffixed .s.

-U name

Causes any definition of name to be forgotten, as if by a #undef preprocessing directive. If the same name is specified for both -D and -U, name is not defined, regardless of the order of the options.

-V Cause each invoked tool to print its version information on the standard error output.

-v Cause the compiler to perform more and stricter semantic checks, and to enable certain lint-like checks on the named C files.

-W tool,arg [,arg  ...]

Hand o1f the2argument(s) arg each as a separate argument to tool. Each argumentimust be separated from the preceding by only a comma. (A comma can be part of an argument by escaping it by an immediately preceding backslash (\) character; the backslash is removed from the resulting argument.) tool can be one of the following:

p    A synonym for 0
0    compiler
2    optimizer
b    basic block analyzer
a    assembler
l    link editor

For example, -Wa,-o,objfile passes -o and objfile to the assembler, in that order; also -Wl,-I,name causes the linking phase to override the default name of the dynamic linker, /usr/lib/libc.so.1.

The order in which the argument(s) are passed to a tool with respect to the other specified command line options may change.

-X c Specify the degree of conformance to the ANSI  C  stan-
     dard.  c can be one of the following:

     t (transition)

The compiled language includes all new features compatible with older (pre-ANSI) C (the default behavior). The compiler warns about all language constructs that have differing behavior between the new and old versions and uses the pre-ANSI C interpretation. This includes, for example, warning about the use of trigraphs the new escape sequence \a, and the changes to the integral promotion rules.

a (ANSI)

The compiled language includes all new features of ANSI C and uses the new interpretation of constructs with differing behavior. The compiler continues to warn about the integral promotion rule changes, but does not warn about trigraph replacements or new escape sequences.

c (conformance)

The compiled language and associated header files are ANSI C conforming, but include all conforming extensions of -Xa. Warnings will be produced about some of these. Also, only ANSI defined identifiers are visible in the standard header files.

The predefined macro __STDC__ has the value 0 for -Xt and -Xa, and 1 for -Xc. All warning messages about differing behavior can be eliminated in -Xa through appropriate coding; for example, use of casts can eliminate the integral promotion change warnings.

-Y item,dir

Specify a new directory dir for the location of item. item can consist of any of the characters representing tools listed under the -W option or the following characters representing directories containing special files:

F    obsolete.  Use -YP instead.  For this release, -YF
     will  be simulated using -YP.  -YF will be removed
     in the next release.
I    directory searched last for include files:  INCDIR
     (see -I)
S    directory containing the  start-up  object  files:
     LIBDIR
L    obsolete.  Use -YP instead.  For this release, -YL
     will  be simulated using -YP.  -YL will be removed
     in the next release.
U    obsolete.  Use -YP instead.  For this release, -YU
     will  be simulated using -YP.  -YU will be removed
     in the next release.
P    Change the default directories  used  for  finding
     libraries. dir is a colon-separated path list.

If the location of a tool is being specified, then the new path name for the tool will be dir/tool. If more than one -Y option is applied to any one item, then the last occurrence holds.

cc recognizes -a, -B, -e, -h -m, -o, -r, -s, -t, -u, and -z and passes these options and their arguments to ld. cc also passes any unrecognized options to ld without any diagnostic.

When cc is put in a file prefixcc, the prefix will be recognized and used to prefix the names of each tool executed. For example, OLDcc will execute OLDacomp, OLDnewoptim, OLD-basicblk, OLDas, and OLDld, and will link the object file(s) with OLDcrt1.o. Therefore, be careful when moving cc around. The prefix applies to the compiler, optimizer, basic block analyzer, assembler, link editor, and the start-up routines.

FILES

file.c                C source file
file.i                preprocessed C source file
file.o                object file
file.s                assembly language file
a.out                 link-edited output
LIBDIR/*crti.o        startup initialization code
LIBDIR/*crt1.o        startup routine
LIBDIR/*crtn.o        last startup routine
TMPDIR/*              temporary files
LIBDIR/acomp          preprocessor and compiler
LIBDIR/newoptim       optimizer
LIBDIR/basicblk       basic block analyzer
BINDIR/as             assembler
BINDIR/ld             link editor
LIBDIR/libc.so        shared standard C library
LIBDIR/libc.a         archive standard C library

INCDIR                usually /usr/include
LIBDIR                usually /usr/ccs/lib
BINDIR                usually /usr/ccs/bin
TMPDIR                usually /var/tmp but can be  redefined
                      by  setting  the  environment variable
                      TMPDIR (see tempnam in tmpnam(3S)).

SEE ALSO

s(1),  libc.ad(1),  lint(1),  lprofFP(1),  prof(1),  sdb(1),
monitor(3C), tmpnam(3S).
The ``C Compilation System''  chapter  in  the  Programmer's
Guide: ANSI C and Programming Support Tools.
Kernighan, B. W., and Ritchie,  D.  M.,  The  C  Programming
Language, Second Edition, Prentice-Hall, 1988.
American National Standard for Information  Systems  -  Pro-
gramming Language C, X3.159-1989.

NOTES

Obsolescent but still recognized cc options include -f, -F, -YF, -YL, and -YU. The -ql and -O options do not work together; -O will be ignored.