Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ cc(1) — GL1 W2.3

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

ccom(1)

cpp(1)

ld(1)

extcentry(1)

mkf2c(1)

a.out(5)

CC(1)  —  Silicon Graphics

NAME

cc, pc, f77 − C, Pascal and FORTRAN compilers for the 68000

SYNOPSIS

cc [ options ] files ... 
pc [ options ] files ... 
f77 [ options ] files ... 

DESCRIPTION

cc is the UNIX C, Pascal and Fortran compiler for the 68000.  It is also available under the names f77 and pc.  The names are synonymous except during the linking phase, when it is used to create the appropriate run-time environment.  Cc accepts many types of input files, determined by the file’s suffix.  The highest form of input is language source - C (.c), Pascal (.p) or FORTRAN (.f).  These are translated to the language’s intermediate format (68000 assembler (.s), in the case of C, and a special binary format (.j), in the case of FORTRAN and Pascal).  After translating to the intermediate format, the next transformation is to UNIX object files (.o), and finally to an executable file called a.out.  Input to cc may consist of any of these types of files and translation may be stopped at any point. 

Translation proceeds as follows:

a) Each .c, .p and .f input is run through the C macro preprocessor cpp.  In the case of Pascal source, cpp is given the -p switch. This switch tells cpp to ignore Pascal-style comments and do the correct things with preprocessor control lines so that the line numbers in the resultant Pascal file will be the same as the original. 

b) The preprocessed C files are then run through the C compiler ccom and, if specified, the C optimizer c2.  The resulting .s files are then assembled, producing UNIX binaries (.o). 

c) Preprocessed FORTRAN (.f)  and Pascal (.p) files are run through the appropriate SVS front end, fortran or pascal, then through the code generator code, producing special binary files (.j).  All special binary files are combined with the FORTRAN/Pascal library and passed to an object file formatter ulinker, producing a single UNIX object file (.o). 

d) Finally, all UNIX object files are passed to ld(1), along with the UNIX startup file /lib/crt0.o, to produce a single executable named a.out. 

Preprocessed source files and assembler files are usually removed.  All C binaries (.o) and special binary files (.j) are preserved, unless there was a single source (.f, .p, or .c) file being compiled, no previously-compiled binaries are being loaded, and the compilation is continuing to an executable.  In this case, the single binary file is removed after the executable is created. 

If C and FORTRAN files are mixed in a single executable, special interface routines may need to be generated as described in Appendix D of the IRIS Workstation Guide and Appendix C of the IRIS Workstation Guide, Series 2000.  If C and Pascal procedures are mixed, the user should consult the SVS Pascal reference manual for instructions on altering the external procedure declarations in Pascal. 

OPTIONS

The following options are interpreted by cc (f77,pc).  Some options have meaning for only one of these languages.  (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 source file is given. 

−g Generate debugging information.  Currently, this does not have meaning when C is intermixed with another language.  For FORTRAN and Pascal files, the appropriate compiler will be called with the +d switch and the symbol table produced by the pre-linker will be placed in x.dbg, where x is the name of the final program.  For pure C programs, additional symbol table information will be generated for dbx(1). 

−l x Include libx.a as a library ld should search for undefined references.  ld will look for the library first in the directory /lib, then in /usr/lib, and finally in /usr/local/lib.  The string x may be more than one letter. 

−−n Normally, cc passes the −n switch to ld, which causes it to load the program with shared text.  The −−n switch suppresses the passing of -n to ld. 

−ooutput
Name the final output file output. 

−p Tell ccom to generate code to count subroutine calls for use with prof.  FORTRAN and Pascal do not support profiling. 

−−x By default, cc passes a −x flag to ld, in order to suppress local symbols from the final symbol table.  The −−x flag inhibits this default. 

−C prevent the macro preprocessor from removing C style comments found in the source.  Such comments are always removed from Pascal programs. 

−Dname=def

−Dname
Define the name to the preprocessor, as if by #define.  (There should be no blanks between the D and the symbol to be defined.)  If no definition is given, the name is defined as "1". 

−E Run only the macro preprocessor on the named C, Pascal and FORTRAN source and send the result to the standard output. 

−I dir Look in directory dir for missing #include files.  Include files whose names are surrounded by double quotes and do not begin with ‘/’ are always first sought in the directory of the input file, then in directories named in −I options, then in /usr/include, and finally in /usr/local/include.  Include files names beginning with ‘/’ are treated as absolute paths.  The directory of the input file is not used as a search path for include files whose names are surrounded by pointed brackets. 

−L Produce an assembly listing for each C or assembler source file, and a FORTRAN listing of each FORTRAN source file.  Assembler listings have the suffix .lst and FORTRAN listings have the suffix .l. 

−O xx Invoke an object-code improver on each C file.  xx are options to c2.  Possible options are S (perform stack optimizations), P (remove stackprobes), K (omit kernel optimizations).  Use of these options is not recommended for the standard compilation environment. 

−P Run only the macro preprocessor on the named C, FORTRAN, and Pascal files, and place the results on file.i. 

−S Compile the named files, leaving the C assembly language output in files suffixed .s, and the FORTRAN and Pascal binaries in files suffixed .j. 

−Uname
Remove any initial definition of name. (There should be no blanks between U and the name to be undefined). 

−Zf Cause instructions for the Sky floating point processor to be generated.  When this switch is used, the Sky math library -lmsky will be substituted for the standard math library -lm if it is specified.  Use of this switch on systems which do NOT have the floating point unit installed will cause a run-time abort. 

−Zg Load the program with the special files and libraries necessary for IRIS graphics programs.  When this switch is used, the graphics library -lg and the math library -lm (or -lmsky if the -Zf flag has also been specified) is given by default.  Special files must be loaded for using graphics with each source language.  Hence, cc must be able to determine the combination of languages involved in the link step.  If the compilation line specified f77, a FORTRAN source file (with the extension .f) OR the switch -ZF is given, cc assumes that FORTRAN routines are present. In this case, the program is also loaded with the FORTRAN graphics interface library -lfgl and the FORTRAN object file containing the block data initialization of the common areas DEVICE and GL (/usr/lib/fgldat.j).  If the compilation line specified pc, a Pascal source file (with the extension .p) OR the switch -ZP is given, cc assumes that Pascal routines are present.  The program is loaded with the special Pascal jump table (/usr/lib/pjmptbl.o), and ld is told to make only eight characters significant in function names during calls to the graphics library. 

−Zi filename
Use the file named filename as the run-time startup, rather than the standard C run time startup.  This may be useful for generating standalone programs. 

−Zq Time all subprocesses, and report these times on stdout at the end of the compilation. 

−Zr Load the program for the remote graphics environment.  If the source contains FORTRAN or .j files, the FORTRAN remote graphics library will be loaded, otherwise the C remote graphics library will be loaded.  As does loading  the standard graphics library, loading the remote graphics library automatically causes the math library (-lm or -lmsky) to be loaded.  If the program is a C program, the directory /usr/include/rgl will be searched prior to /usr/include for graphics header files. 

−Zv Turn on verbose mode. In verbose mode, the C compiler ccom will give additional diagnostics.  This includes such things as flagging any use of the C type double, and complaining about too many register declarations. 

−Zz Print a trace of all exec() calls. 

−ZA pass the remainder of the string to as.  Thus, the cc switch −ZA−q will pass as the switch −q. 

−ZC pass the remainder of the string to ccom.  Thus, the cc switch −ZC−v will pass ccom the switch −v. 

−ZF pass the remainder of the string to the FORTRAN compiler front-end fortran.  Thus, the cc switch −ZF+d will pass fortran the switch +d.  This switch (with or without a switch to pass to the FORTRAN front-end) also informs cc that FORTRAN files were present in the compilation. 

−ZM Cause the FORTRAN pre-linker to generate a load map of the FORTRAN program.  This will be placed in a file by the same name as the executable file with the added extension .fmap. 

−ZP Pascal files are present in this compilation.  cc cannot determine this unless it sees a .p file or the name pc is used. 

Other flags are passed to ld.  The files may consist of any mix of C, object, FORTRAN, assembler, binary or library files.  The files are passed to ld, if opted, after rearranging according to the file type, to produce an executable program nameed a.out or that specified by the −o option.  Files of unknown type (i.e., with an extension other than .c, .f, .j, .o, .a, .p, or .s) are given to ld as if they had been previously loaded (i.e., are in a.out format). The order of files of unknown type in the load step is indeterminate. 

FILES

file.c C source file
file.f FORTRAN source file
file.p Pascal source file
file.j Pascal and FORTRAN binary files
file.o binary (relocatable) file
file.s assembly file
a.out executable file
/lib/ccom C compiler
/lib/cpp C preprocessor
/lib/crt0.o run time startup
/lib/libc.a C library
/usr/lib/paslib.obj FORTRAN library
/usr/lib/fortran FORTRAN front-end
/usr/lib/pascal Pascal front-end
/usr/lib/code FORTRAN code-generator
/usr/lib/ulinker FORTRAN pre-linker
/bin/as 68000 assembler
/bin/ld linking loader
/usr/include default include directory
/usr/lib/fgldat.j block data routine for graphics commons
/usr/lib/pjmptbl.o Pascal graphics jump table and C string converter

SEE ALSO

IRIS Workstation Guide Appendices D and E. 
IRIS Workstation Guide,Series 2000, Appendices C and D. 
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
SVS FORTRAN Reference Manual
SVS Pascal Reference Manual
as(1)
, ccom(1), cpp(1), ld(1), extcentry(1), mkf2c(1), a.out(5)

BUGS

Three bugs are currently outstanding in the C compiler system.  The first bug is the result of the compiler running out of temporary registers when compiling an expression.  This has been seen to occur in an expression as junk[c].i += a and in certain bitfield assignment expressions in a function which contains many register variables.  The compiler aborts with the message expression causes compiler loop, try simplifying.  Rather than to reserve an additional register for the compiler’s internal use, it has been left to the user to alleviate this problem by reducing the number of data registers being used in this instance to five or less. 

The second bug occurs when using the optimizer c2.  In certain situations, the optimizer gets confused as to the boundary between functions when optimizing functions which are declared as static.  This can result in optimizing away necessary register save/restore code at function entry and exit.  Although the problem occurs rarely even in conjunction with such declarations, users are currently warned against declaring functions as static when using the optimizer. 

The third bug occurs when passing an autoincremented (or autodecremented) bit field to a function, as in foo(a.i++), where i is a bitfield element of structure foo.  In some cases, the compiler will autoincrement the bitfield correctly, but pass the incorrect value to foo.  The value may have little or no relationship to the true value of a.i either before or after autoincrementing. 

The compiler may also complain about assigning enumeration constants to variables of that type if the variable is a bitfield.  The complaint is in the form of a warning, and the correct code is generated. 

DIAGNOSTICS

The diagnostics produced by C, FORTRAN, and Pascal are intended to be self-explanatory.  Occasional messages may be produced by the assembler or loader. 

Version 2.3  —  July 04, 1985

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026