CC(1-SVR3) RISC/os Reference Manual CC(1-SVR3)
NAME
cc - MIPS C compiler
SYNOPSIS
cc [ option ] ... file ...
DESCRIPTION
cc, the MIPS ucode C compiler, produces files in the follow-
ing formats: MIPS object code in MIPS extended coff format
(the normal result), binary or symbolic ucode, ucode object
files, and binary or symbolic assembly language.
cc accepts several types of arguments:
Arguments whose names end with `.c' are assumed to be C
source programs. They are compiled, and each object
program is left in the file whose name consists of the
last component of the source with `.o' substituted for
`.c'. The `.o' file is only deleted when a single
source program is compiled and loaded all at once.
Arguments whose names end with `.s' are assumed to be
symbolic assembly language source programs. They are
assembled, producing a `.o' file.
Arguments whose names end with `.i' are assumed to be C
source after being processed by the C preprocessor.
They are compiled without being processed by the C
preprocessor.
If the highest level of optimization is specified (with
the -O3 flag) or only ucode object files are to be pro-
duced (with the -j flag), each C source file is com-
piled into a ucode object file. The ucode object file
is left in a file whose name consists of the last com-
ponent of the source with `.u' substituted for `.c'.
The suffixes described below primarily aid compiler
development and are not generally used. Arguments
whose names end with `.B', `.O', `.S', and `.M' are
assumed to be binary ucode, produced by the front end,
optimizer, ucode object file splitter and ucode merger
respectively. Arguments whose names end with `.U' are
assumed to be symbolic ucode. Arguments whose names
end with `.G' are assumed to be binary assembly
language, which is produced by the code generator and
the symbolic to binary assembler.
Files that are assumed to be binary ucode, symbolic
ucode, or binary assembly language by the suffix con-
ventions are also assumed to have their corresponding
symbol table in a file with a `.T' suffix.
Printed 11/19/92 Page 1
CC(1-SVR3) RISC/os Reference Manual CC(1-SVR3)
cc always defines the C preprocessor macros mips, hostmips
and unix to the C macro preprocessor and defines the C
preprocessor macro LANGUAGEC when a `.c' file is being com-
piled. cc will define the C preprocessor macro
LANGUAGEASSEMBLY when a `.s' file is being compiled. It
also defines SYSTYPESYSV by default but this changes if the
-systype name option is specified (see the description
below).
OPTIONS
The following options are interpreted by cc. See ld(1) for
load-time options.
-c Suppress the loading phase of the compilation and
force an object file to be produced even if only one
program is compiled.
-g0 Have the compiler produce no symbol table informa-
tion for symbolic debugging. This is the default.
-g1 Have the compiler produce additional symbol table
information for accurate but limited symbolic debug-
ging of partially optimized code.
-g or -g2
Have the compiler produce additional symbol table
information for full symbolic debugging and not do
optimizations that limit full symbolic debugging.
-g3 Have the compiler produce additional symbol table
information for full symbolic debugging for fully
optimized code. This option makes the debugger
inaccurate.
-w or -w1
Suppress warning messages.
-w2 Abort on warnings after printing them as if an error
occurred.
-w3 Do not print warning messages, however exit with non
zero status when warnings occur.
-nonshared
Do not produce dynamic executable. The loader will
use regular archives to resolve undefines and .o's
from archives are included in the executable pro-
duced.
-msft Allow Microsoft C extensions.
-shared Produce dynamic sharable objects. The loader will
Page 2 Printed 11/19/92
CC(1-SVR3) RISC/os Reference Manual CC(1-SVR3)
produce a sharable object that other dynamic execut-
ables can use at run-time.
-callshared
Produce dynamic executable that uses sharable
objects during run-time. This is the default. The
loader will use sharable objects to resolve unde-
fines. The run-time linker will be invoked to bring
in all required sharable objects and resolve any
symbols that remained undefined during static link-
time.
-noarchive
This option is used in conjunction with -callshared
or -shared The loader will use shared objects, that
are specified with the -l option to resolve unde-
fined symbols. For example, with -lc , (libc.so)
will be used If it cannot find the shared object,
it's corresponding archive (libc.a) will be used
instead. This option disallow using of archives to
resolve symbols
-callshared
Produce dynamic executable that uses sharable
objects during run-time. This is the default. The
loader will use sharable objects to resolve unde-
fines. The run-time linker will be invoked to bring
in all required sharable objects and resolve any
symbols that remained undefined during static link-
time.
-exactversion
This option is used in conjunction with -callshared
or -shared. The loader will set a flag in the
dynamic object that it produces to indicate to the
run-time linker and ensure that the version of
shared objects the object uses at run-time matches
with the version of the shared objects the loader
recorded during static link time.
-jmpopt See ld(1) for more details.
-nojmpiot
See ld(1) for more details.
-p0 Do not permit any profiling. This is the default.
If loading happens, the standard runtime startup
routine (crt1.o) is used, no profiling library is
searched.
-p1 or -p
Set up for profiling by periodically sampling the
Printed 11/19/92 Page 3
CC(1-SVR3) RISC/os Reference Manual CC(1-SVR3)
value of the program counter. This option only
affects the loading. When loading happens, this
option replaces the standard runtime startup routine
with the profiling runtime startup routine (mcrt1.o)
and searches the level 1 profiling library
(libprof1.a). When profiling happens, the startup
routine calls monstartup see monitor(3) and produces
a file mon.out that contains execution-profiling
data for use with the postprocessor prof(l).
-O0 Turn off all optimizations.
-O1 Turn on all optimizations that can be done quickly.
This is the default.
-O or -O2
Invoke the global ucode optimizer.
-O3 Do all optimizations, including global register
allocation and procedure inlining. This option must
precede all source file arguments. With this
option, a ucode object file is created for each C
source file and left in a `.u' file. The newly
created ucode object files, the ucode object files
specified on the command line and the runtime
startup routine and all the runtime libraries are
ucode linked. Optimization is done on the resulting
ucode linked file and then it is linked as normal
producing an ``a.out'' file. No resulting `.o' file
is left from the ucode linked result as in previous
releases. In fact -c can no longer be specified
with -O3.
-feedback file
Used with the -cord or -O2 or -O3 option to
specify file to be used as a feedback file. This
file is produced by prof(1) with its -feedback
option from an execution of the program produced by
pixie(1).
-cord Run the procedure-rearranger, cord(1), on the
resulting file after linking. The rearrangement is
done to reduce the cache conflicts of the program's
text. The output of cord(1) is left in the file
specified by the -o output option or `a.out' by
default. At least one -feedback file must be speci-
fied.
-j Compile the specified source programs, and leave the
ucode object file output in corresponding files suf-
fixed with `.u'.
Page 4 Printed 11/19/92
CC(1-SVR3) RISC/os Reference Manual CC(1-SVR3)
-noinline
Disable the inlining optimization performed under
-O3 option. This flag is meaningful only when -O3
is specified.
-ko output
Name the output file created by the ucode loader as
output. This file is not removed. If this file is
compiled, the object file is left in a file whose
name consists of output with the suffix changed to a
`.o'. If output has no suffix, a `.o' suffix is
appended to output.
-k Pass options that start with a -k to the ucode
loader. This option is used to specify ucode
libraries (with -klx ) and other ucode loader
options.
-S Compile the specified source programs and leave the
symbolic assembly language output in corresponding
files suffixed with `.s'.
-P Run only the C macro preprocessor and put the result
for each source file (by suffix convention, i.e.
`.c' and `.s') in a corresponding `.i' file. The
`.i' file has no `#' lines in it. This sets the
-cpp option.
-E Run only the C macro preprocessor on the files
(regardless of any suffix or not), and send the
result to the standard output. This sets the -cpp
option.
-C
-M
-Q These three options are passed directly to cpp(1).
Please see cpp(1) for details.
-Dname=def
-Dname Define the name to the C macro preprocessor, as if
by `#define'. If no definition is given, the name
is defined as "1".
-Uname Remove any initial definition of name.
-Idir `#include' files whose names do not begin with `/'
are always sought first in the directory of the file
argument, then in directories specified in -I
options, and finally in the standard directory
(/usr/include).
-I This option will cause `#include' files never to be
Printed 11/19/92 Page 5
CC(1-SVR3) RISC/os Reference Manual CC(1-SVR3)
searched for in the standard directory
(/usr/include).
-o output
Name the final output file output. If this option
is used, the file `a.out' is undisturbed.
-G num Specify the maximum size, in bytes, of a data item
that is to be accessed from the global pointer. num
is assumed to be a decimal number. If num is zero,
no data is accessed from the global pointer. The
default value for num is 8 bytes.
-v Print the passes as they execute with their argu-
ments and their input and output files. Also print
resource usage in the C-shell time(1) format. If
specified more than once, the passes are printed but
not executed.
-V Print the version of the driver and the versions of
all passes. This is done with the what(1) command.
-std[0,1]
Have the compiler produce warnings for language con-
structs that are not standard in the language.
-std0 enforces the K & R standard with some ANSI
extensions, -std1 enforces the ANSI C standard, and
-std enforces the ANSI C standard with popular
extensions. The -std option causes the macro
STDC=0 to be passed to the preprocessor, -std1
causes the macro STDC=1 to be passed, and -std0
causes STDC to be undefined. The default is
-std0. See Chapters 6 and 7 of the RISCompiler and
C Programmer's Guide for details on MIPS-C and ANSI
C languages.
-traditional
Is the same as the -std0 option.
-Zpn Align structure members on alignment specified by
the integer n
-proto[is]
extract prototype declarations for function defini-
tions into a .H suffixed file. The option i is to
include identifiers in the prototype, and the option
s is to generate prototypes for static functions as
well.
-wimplicit
Warn whenever a function is implicitly declared
(i.e. when a function call does not have a visible
Page 6 Printed 11/19/92
CC(1-SVR3) RISC/os Reference Manual CC(1-SVR3)
prototype).
-cpp Run the C macro preprocessor on C and assembly
source files before compiling. This is the default
for cc.
-nocpp Do not run the C macro preprocessor on C and assem-
bly source files before compiling.
-Olimit num
Specify the maximum size, in basic blocks, of a rou-
tine that will be optimized by the global optimizer.
If a routine has more than this number of basic
blocks it will not be optimized and a message will
be printed. An option specifying that the global
optimizer is to be run (-O, -O2, or -O3) must also
be specified. num is assumed to be a decimal
number. The default value for num is 500 basic
blocks.
-edit[0-9]
Invoke the editor of choice (as defined by the
environment variable EDITOR), or vi(1) (if EDITOR is
not defined) when syntax or semantic errors are
detected by the compiler's frontend. When compiling
on a character based terminal, the compile job has
to be in the foreground for this option to take
effect. For compile jobs done on a RISCwindow based
terminal/workstation, this option would always take
effect whether it is in the foreground or back-
ground. The editor is invoked with two files: the
error message file and the source file. First use
the error message file to locate the line numbers of
all the errors, then switch to the source file to
make corrections. Once you exit out of the editor,
the compile job is restarted. This process can be
repeated up to 9 times, depending on the single
digit number specified in the option. If no number
is specified in the option, this compile-edit-
compile process repeats indefinitely until all
errors are corrected. -edit0 turns off this edit
feature.
-trapuv Force all un-initialized stack, automatic and dynam-
ically allocated variables to be initialized with
0xFFFA5A5A. When this value is used as a floating
point variable, it is treated as a floating point
NaN and it will cause a floating point trap. When
it is used as a pointer, an address or segmentation
violation will most likely to occur.
-framepointer
Printed 11/19/92 Page 7
CC(1-SVR3) RISC/os Reference Manual CC(1-SVR3)
Assert the requirement of frame pointer for all pro-
cedures defined in the source file.
-oldcomment
In the preprocessor, delete comments (i.e. replace
comments with nothing at all), rather than replacing
comments with a space. This allows traditional
token concatenation. This is the default in -std0
mode.
-verbose
This option causes output of the long form of error
and warning messages. These may give the user some
hints as to the reason the compilation failed.
Either object file target byte ordering can be produced by
cc. The default target byte ordering matches the machine
where the compiler is running. The options -EB and -EL
specify the target byte ordering (big-endian and little-
endian, respectively). The compiler also defines a C
preprocessor macro for the target byte ordering. These C
preprocessor macros are MIPSEB and MIPSEL for big-endian and
little-endian byte ordering respectively.
If the specified target byte ordering does not match the
machine where the compiler is running, then the runtime
startups and libraries come from /usr/libeb for big-endian
runtimes on a little-endian machine and from /usr/libel for
little-endian runtimes on a big-endian machine.
-EB Produce object files targeted for big-endian byte ord-
ering. The C preprocessor macro MIPSEB is defined by
the compiler.
-EL Produce object files targeted for little-endian byte
ordering. The C preprocessor macro MIPSEL is defined
by the compiler.
The following options are specific to C:
-signed
Cause all char declarations to be signed char declara-
tions, the default is to treat them as unsigned char
declarations.
-volatile
Cause all variables to be treated as volatile.
-varargs
Print warnings for lines that may require the varargs.h
macros.
Page 8 Printed 11/19/92
CC(1-SVR3) RISC/os Reference Manual CC(1-SVR3)
-float
Cause the compiler to never promote expressions of type
float to type double.
The options described below is primarily used to provide
UNIX compilation environments other than the native compila-
tion environment.
To facilitate setting of default compiler options for cross
compilation environments, an option configuration file named
comp.config is used. This file, located at the compiler
target directory, contains a single line of ASCII text of
compiler options. These options are processed ahead of the
user specified options in the command line, except for the
command line -systype option, which is first processed to
locate the configuration file. The line can be up to
BUFSIZE-1 long with up to 64 tokens (separated by blanks and
tabs). Options specified in the command line override those
specified in the configuration file.
-crt0
use crt0.o as compiler startup routine in BSD-like
environments.
-crt1
Use crt1.o and crtn.o as compiler startup and finish
routines in SVR3-like environments. This is the
default.
-systype name
Use the named compilation environment name. The names
of the compilation environments supported are bsd43,
svr3, and svr4. This has the effect of changing the
standard directory for `#include' files, the runtime
libraries and where runtime libraries are searched for.
The new items are located in their usual paths but with
/name prepended to their paths. Also a preprocessor
macro of the form SYSTYPENAME (with name capitalized)
is defined in place of the default SYSTYPESYSV.
-mips1
Generate code using the instruction set of the
R2000/R3000 RISC architecture. This is the default for
all MIPS systems.
-mips2
Generate code using the instruction set of the R6000
RISC architecture.
-mips3
Generate code using the instruction set of the R4000
RISC architecture. Warning: executables compiled this
Printed 11/19/92 Page 9
CC(1-SVR3) RISC/os Reference Manual CC(1-SVR3)
way will not run without special support from the
operating system.
The options described below primarily aid compiler develop-
ment and are not generally used:
-Hc Halt compiling after the pass specified by the charac-
ter c, producing an intermediate file for the next
pass. The c can be [ fjusmoca ]. It selects the com-
piler pass in the same way as the -t option. If this
option is used, the symbol table file produced and used
by the passes, is the last component of the source file
with the suffix changed to `.T' and is not removed.
-K Build and use intermediate file names with the last
component of the source file's name replacing its suf-
fix with the conventional suffix for the type of file
(for example `.B' file for binary ucode, produced by
the front end). These intermediate files are never
removed even when a pass encounters a fatal error.
When ucode linking is performed and the -K option is
specified the base name of the files created after the
ucode link is `u.out' by default. If -ko output is
specified, the base name of the object file is output
without the suffix if it exists or suffixes are
appended to output if it has no suffix.
-# Converts binary ucode files (`.B') or optimized binary
ucode files (`.O') to symbolic ucode (a `.U' file)
using btou(1). If a symbolic ucode file is to be pro-
duced by converting the binary ucode from the C com-
piler front end then the front end option -Xu is used
instead of btou(1).
-Wc[c...],arg1[,arg2...]
Pass the argument[s] argi to the compiler pass/passes:
c[c..]. The c's are one of [ pfjusdqmocablyz ]. The c's
selects the compiler pass in the same way as the -t
option.
The options -t[hpfjusmocabqdlyzrnt], -hpath, and -Bstring
select a name to use for a particular pass, startup routine,
or standard library. These arguments are processed from
left to right so their order is significant. When the -B
option is encountered, the selection of names takes place
using the last -h and -t options. Therefore, the -B option
is always required when using -h or -t. Sets of these
options can be used to select any combination of names.
The -EB or -EL options, the -p[01] options and the -systype
option must precede all -B options because they can affect
the location of runtimes and what runtimes are used.
Page 10 Printed 11/19/92
CC(1-SVR3) RISC/os Reference Manual CC(1-SVR3)
-t[hpfqdjusmocablyzrnt]
Select the names. The names selected are those desig-
nated by the characters following the -t option accord-
ing to the following table:
Name Character
include h (see note below)
cfe p,f
ddopt d
uopt0 q
ujoin j
uld u
usplit s
umerge m
uopt o
ugen c
as0 a
as1 b
ld l
ftoc y
cord z
[m]crt[1n].o r
libprof1.a n
btou, utob t
If the character `h' is in the -t argument then a directory
is added to the list of directories to be used in searching
for `#include' files. This directory name has the form
$COMP_TARGET_ROOT/usr/includestring. This directory is to
contain the include files for the string release of the com-
piler. The standard directory is still searched.
-hpath
Use path rather than the directory where the name is
normally found.
-Bstring
Append string to all names specified by the -t option.
If no -t option has been processed before the -B, the
-t option is assumed to be ``hpfjusmocablyzrnt''. This
list designates all names. If no -t argument has been
processed before the -B then a -Bstring is passed to
the loader to use with its -lx arguments.
Invoking the compiler with a name of the form ccstring has
the same effect as using a -Bstring option on the command
line.
If the environment variable COMP_HOST_ROOT is set, the value
is used as the root directory for all pass names rather than
the default /. If the environment variable COMP_TARGET_ROOT
is set, the value is used as the root directory for all
include and library names rather than the default /. This
affects the standard directory for `#include' files,
Printed 11/19/92 Page 11
CC(1-SVR3) RISC/os Reference Manual CC(1-SVR3)
/usr/include, and the standard library, /usr/lib/libc.a. If
this is set, the first directory that is searched for
libraries, using the -lx option, is
$COMP_TARGET_ROOT/usr/lib/cmplrs/cc. The standard direc-
tories for libraries are then searched, see ld(1).
If the environment variable TMPDIR is set, the value is used
as the directory to place any temporary files rather than
the default /tmp/.
If the environment variable RLS_ID_OBJECT is set, the value
is used as the name of an object to link in if a link takes
place. This is used to add release identification informa-
tion to objects. It is always the last object specified to
the loader. See rls_id(1) for the tools to create this
information.
The user can choose which error message file to use at the
time the compiler is invoked. The following locations are
searched (in order):
1. A filename specified on the command line
2. A file specified by the environment variable __ERROR_FILE
3. A file in the same directory as the resulting binary, with filename
"err.$__LANG.cc", where $__LANG is the value of the environment
variable __LANG. The default for __LANG is "english".
4. A file "err$__LANG.cc" in the current directory.
5. If none of the above are present, the file /usr/lib/cmplrs/err.cc
is used.
Other arguments are assumed to be either loader options or
C-compatible object files, typically produced by an earlier
cc run, or perhaps libraries of C-compatible routines.
These files, together with the results of any compilations
specified, are loaded in the order given, producing an exe-
cutable program with the default name a.out.
FILES
file.c input file
file.o object file
a.out loaded output
err.english.cc compiler error messages in english
/tmp/ctm? temporary
/usr/lib/cmplrs/cc/comp.config
compiler configuration file (optional)
/usr/lib/cmplrs/cc/cfe
C front end
/usr/lib/cmplrs/cc/cpp
C macro preprocessor
/usr/lib/cmplrs/cc/ujoin
binary ucode and symbol table joiner
/usr/bin/cmplrs/cc/uld
Page 12 Printed 11/19/92
CC(1-SVR3) RISC/os Reference Manual CC(1-SVR3)
ucode loader
/usr/lib/cmplrs/cc/usplit
binary ucode and symbol table splitter
/usr/lib/cmplrs/cc/umerge
procedure intergrator
/usr/lib/cmplrs/cc/uopt
optional global ucode optimizer
/usr/lib/cmplrs/cc/ugen
code generator
/usr/lib/cmplrs/cc/as0
symbolic to binary assembly language
translator
/usr/lib/cmplrs/cc/as1
binary assembly language assembler and
reorganizer
/usr/lib/cmplrs/cc/crt1.o
runtime startup
/usr/lib/cmplrs/cc/crtn.o
runtime startup
/usr/lib/cmplrs/cc/mcrt1.o
startup for profiling
/usr/lib/libc.a standard library, see intro(3)
/usr/lib/libstdc.a ANSI C library
/usr/lib/cmplrs/cc/libprof1.a
level 1 profiling library
/usr/include standard directory for `#include' files
/usr/bin/ld MIPS loader
/usr/lib/rld MIPS run-time linker
/usr/lib/ftoc interface between prof(1) and cord(1)
/usr/lib/cord procedure-rearranger
/usr/bin/btou binary to symbolic ucode translator
/usr/bin/utob symbolic to binary ucode translator
mon.out file produced for analysis by prof(1)
SEE ALSO
ANSI X3.159-1989 B. W. Kernighan and D. M. Ritchie, The C
Programming Language, Prentice-Hall, 1978
B. W. Kernighan, Programming in C-a tutorial
D. M. Ritchie, C Reference Manual
RISCompiler and C Programmer's Guide.
as(1), cord(1), dbx(1), ftoc(1), ld(1), pixie(1), prof(1),
what(1).
monitor(3) in the Programmer's Reference Manual.
DIAGNOSTICS
The diagnostics produced by cc are intended to be self-
explanatory. Occasional messages may be produced by the
assembler or loader.
NOTES
The standard library, /usr/lib/libc..{so,a}, is loaded by
using the -lc loader option and not a full path name. The
wrong one could be loaded if there are files with the name
libc..{so,a}string in the directories specified with the -L
loader option or in the default directories searched by the
Printed 11/19/92 Page 13
CC(1-SVR3) RISC/os Reference Manual CC(1-SVR3)
loader.
The handling of include directories and libc..{so, a} is
confusing.
Page 14 Printed 11/19/92