HC(1)
NAME
hc − Harris ANSI C Compiler
SYNOPSIS
hc [ options ] ... files ...
DESCRIPTION
Hc is the Harris Common Code Generator (CCG) based C compiler. Hc is also known as cc.
The Harris C compiler accepts both the traditional dialect of C (as specified by the first addition of The C Programming Language by Kernighan and Ritchie, and as specified by existing UNIX practice), and the language as specified by the ANSI C standard. In order to address conflicts between existing practice and the ANSI C standard, the hc compiler supports several compilation modes that provide varying degrees of conformance to the standard. Exactly which compilation mode is in use can be controlled by the command line −X option (discussed below). By default hc attempts to be compatible with the traditional dialect of C supported in previous releases of hc.
Hc accepts several types of arguments:
Arguments whose names end with ’.c’ are interpreted as C source programs. When a source program is compiled, the output is placed in a file of the same name ending in ’.o’. If a single program is compiled and linked, the ’.o’ file is automatically deleted after the linker has run. In the same way, arguments whose names end with ’.s’ are taken to be assembly source programs and are assembled to produce ’.o’ files.
All options that are not interpreted by hc are passed through to the link editor ld(1). All file names not ending in ’.c’ or ’.s’ are interpreted as either C compatible object files (’.o’ files), or libraries of C compatible routines. These options and files, together with the results of any ’.c’ or ’.s’ files that were compiled, are loaded (in the order given) to produce an executable program with the name a.out.
The following options are interpreted by hc.
−k Do syntax checking only. No object file will be produced.
−E Preprocess the named source files and write the output to standard output.
−P Preprocess the named source files and leave the result in the corresponding files suffixed ’.i’.
−S Compile the named C files and leave the assembler-language output in the corresponding files suffixed by ’.s’. No object file or executable is produced.
−c Suppress the loading phase of the compilation, and force an object file to be produced even if only one program is compiled.
−C Prevent the macro preprocessor from eliminating comments.
−D name=def
−D name Define the name to the preprocessor, as if by #define. If no definition is given, name is defined as "1".
−U name
Remove any initial definition of name.
−I directory
Add directory to the list of directories to search for #include files. #include file names that do not begin with ’/’ are sought first in the directory of the source file that contained the #include directive, then in directories named in −I options, and finally in /usr/include. If the file specified by the #include directive is surrounded by angle brackets, then the directory of the source file is not searched.
−i include
Include the specified file prior to reading the source file. This allows any number of compiler directives or other definitions to be made visible during a compilation.
−o output
Passed on to ld, to name the final output file output. If this option is used the file a.out will be left undisturbed.
−g Produce additional symbolic debugging information.
−K Treat signed and volatile as normal identifiers, not as ANSI C keywords. The hc compiler implements the ANSI standard keywords signed and volatile. This option causes them to be treated as normal identifiers rather than as keywords so that pre-existing code that already uses signed and/or volatile as identifiers may be compiled.
−X[acto]
Select one of the four compilation modes supported by the Harris C compiler. The four modes are:
−Xo Old (compatibility) Mode. This is the default compilation mode for this release of the compiler. Maximum compatibility is maintained with previous releases of the Harris C compiler.
−Xt ANSI Transition Mode. Provides the same semantics as ANSI mode, but prints extra diagnostic messages where code contains statements whose semantics may differ between ANSI and Old modes.
−Xa ANSI Mode. ANSI C compatible mode. Compiles the full C language as defined by the ANSI C standard, with Harris extensions. This is the mode of choice for most programming.
−Xc Strictly Conforming ANSI C Mode. Compiles the C language as defined by the ANSI C standard. Provides a full ANSI-conforming identifier name-space. Extensions to the C language which are provided in ANSI-specified include files are disabled.
As a group the three compilation modes, Xt, Xa, and Xc, are called the ANSI C compilation modes. Please refer to the Harris C Reference Manual for more information about the differences between these four modes.
−w Suppress warning diagnostics.
−n Nitpick over small errors (similar to running lint(1)). This causes the compiler to generate caution messages about problematic source code constructions that may represent coding errors but that are still legal. These messages include detection of calls to undeclared functions, detection of assignment in the expressions that control if-statements and loops, and detection of variables that are declared but not used.
−v Be verbose when running the compiler. Writes information about the compilation to stderr. This can be used to determine the processors (and their arguments) invoked during the compilation. Also, enables informational messages about optimization.
−O level[switch]
Set the compiler optimization level. The optional level argument specifies the optimization level to be performed. It may be one of the following:
| level | meaning |
| _ | _ |
| <blank> | GLOBAL |
| 1 | MINIMAL |
| 2 | GLOBAL |
| 3 | MAXIMAL |
The default level if this option is not specified is MINIMAL. The optional switch argument can be specified to control whether or not instruction scheduling optimizations and post-linker optimizations are performed. Switch may be one of the following:
| reorder | enable instruction scheduling optimizations |
| noreorder | suppress instruction scheduling optimizations |
| no_post_linker | suppress post-linker optimizations |
By default, the instruction-scheduling optimizations are not performed at level MINIMAL, but are performed at GLOBAL and MAXIMAL. Instruction scheduling can make symbolic debugging difficult and/or confusing; see the "Program Optimization" chapter of the CX/UX Programmer’s Guide for more information. If a −O option is specified, then post-linker optimizations will be performed during the final link phase unless the no_post_linker switch is specified. See analyze88(1) and ld(1) for information on post-linking optimizations.
−F Turns intrinsic functions on. The hc compiler will then generate in-line code for certain commonly-used C library functions and for accessing special machine instructions. Please refer to the Harris C Reference Manual for a description of the intrinsic functions.
−p Arrange for the compiler to produce code that counts the number of times a routine is called. If loading takes place, arrange for the object program to produce a mon.out file at normal termination when executed. An execution profile can then be generated by using prof(1). Note: The format of a profile file is not guaranteed to be portable across systems provided by different vendors. In particular, Motorola 88000 programs that are certified to conform to the 88open Compatibility Standards may not have the capability of being profiled on a foreign system.
−G Like −p, but for use with gprof(1).
−fsingle
Cause all floating point constants to have type float instead of the default type, double. This can be used to prevent type promotion of floating point expressions involving constants to double precision. Note that it is possible to force individual floating point constants to have type float by adding a ’f’ or ’F’ suffix. For example, 3.14f has type float while 3.14 has type double (by default). This eliminates the need to use the −fsingle option and allows greater flexibility in controlling the types of floating point literals.
−fsingle2
Like the −fsingle option, but this also disables the automatic type promotion of floating point expressions to type double when passed as parameters to functions. With this option it is possible to write and use true single precision functions, but it becomes the user’s responsibility to provide double precision arguments to functions that expect them (such as standard library routines like printf). Note that function prototypes may be used to declare routines that accept float arguments, regardless of the default type promotion rules. This can eliminate the need to use the −fsingle2 option. In ANSI mode, prototype declarations for the single precision math library routines are available in <math.h>. See trig(3m).
−f float
Use float as the floating point mode during compilation, and as the floating point mode of the resulting object file.
| Modes | Argument Values | ||
| _ | _ | _ | _ |
| IEEE-COMPATIBLE | 3 | ieeecom | |
| IEEE-NEAREST | 4 | ieeenear | near |
| IEEE-ZERO | 5 | ieeezero | zero |
| IEEE-POS-INFINITY | 6 | ieeepos | pos |
| IEEE-NEG-INFINITY | 7 | ieeeneg | neg |
Any one of the listed argument values may be used for float. If no −f option is provided, the default is IEEE-NEAREST.
−W1,-7 Causes the compiler to align doubles on 4-byte boundaries. Structures and unions are also aligned on 4-byte boundaries and are rounded up to a multiple of 4-bytes in size. This is equivalent to the default behavior on Series 1000 and 3000 systems prior to the CX/UX 5.0 release. Please note that the use of this option on Series 4000 and 5000 systems can cause a major reduction in program execution speed and should be avoided whenever possible. The current behavior is for doubles to be aligned on 8-byte boundaries and for structures and unions to be aligned according to the most restrictive requirement of their fields. The sizes of structures and unions are then rounded up to be a multiple of their alignment constraint.
−R Make initialized variables shared and read-only. Passes the −r option to the assembler, as(1).
−T symtab_size
Passed on to the assembler, see as(1).
−l name
Passed on to ld, to search the library libname.a from /lib or /usr/lib, and load referenced modules from that library into the executable file. For example, −lm would specify the mathematical library, /lib/libm.a, and -lcurses would specify /usr/lib/libcurses.a (since /lib/libcurses.a does not exist).
−Q flag
−Q provides access to a number of special purpose compiler control options, some of which are target machine dependent. Many of these options specify optimization parameters that are common to all Harris CCG based compilers; see the "Program Optimization" chapter of the CX/UX Programmer’s Guide for a detailed description of CCG optimizations and the use of these options. Currently, the following flags are available:
P [ahX]
Write a source listing with line numbers, file names, and headings to stdout. The P may be followed by the letters a, h, and X to control the listing. They cause the listing to expand include files (a), include an object listing (h), and to show the expansion of preprocessor macros (X).
benchmark
Remove all safety limits on optimizations and sets the other time and space limits to extremely high values. By default the optimizer attempts to avoid exponential compile time and memory usage by limiting optimizations. This flag implicitly sets the optimization level to MAXIMAL (−O3).
growth_limit=N
Limit the amount of intermediate code the optimizer is allowed to duplicate when performing optimizations such as loop unrolling and when repairing irreducible flow graphs. The integer constant N represents the percentage increase in code size permitted. The default if this option is not specified is 25.
loops=N
Set the number of loops for which the compiler will perform the copy-variable optimization. The default if this option is not specified is 20.
objects=N
Set the maximum number of "variables" that the compiler will optimize when GLOBAL or MAXIMAL optimization is specified to N, where N must be an integer constant. The default if this option is not specified is 128.
unroll_limit=N
Control the number of times a loop may be unrolled. N must be an integer between 0 and 8. The default if this option is not specified is 4.
inline_divide
Generate extra code to detect and perform integer divisions that involve negative numbers without generating exceptions handled by the operating system. Normally the compiler generates a simple divide instruction for all integer division, and then permits the operating system to complete the instruction when negative numbers are divided. This option may be used for applications where division of or by negative numbers happens so frequently that the extra overhead of permitting the operating system to handle the exceptions has a significant performance impact.
fast_math
Permit the compiler to perform floating point operations with faster integer instructions that do not generate floating point exceptions or handle special IEEE values such as NaN.
optimize_for_space
Make space rather than time the critical factor in optimizing this program.
opt_class=class
Select the class of compiler optimization. Hc has two possible classes of optimization: STANDARD and UNSAFE. If opt_class is set to UNSAFE, then the compiler will make assumptions as to how the program was written in order to produce more efficient code. If opt_class is set to STANDARD, then unsafe optimizations will not be performed. UNSAFE is the default if this option is not specified.
target=machine
Select the target architecture for compilation. machine may be one of M88100, M88110, or M88110compat. M88100 is the default for compilations hosted on Series 4000 machines. M88110 is the default for compilations hosted on Series 5000 machines. Currently, these options simply set a macro (see PREDEFINED MACROS section) to permit conditional compilation based on the target architecture. In the next release of the Harris C Compiler, code generation and optimization will differ for different targets. Use M88100 to compile for a Series 4000. Use M88110 to compile for a Series 5000. Use M88110compat for produce object which can be run on either the Series 4000 or Series 5000.
ocs Generate object files that conform to the 88open Object Compatibility Standard (OCS). This option has the following effects: it causes the macro _OCS to be predefined for the compilation; it passes the −Qocs option to ld(1); and it adds /lib/ocs.o to the command line options passed to ld(1) and as(1). The predefined macro _OCS causes <stdio.h> to be OCS conforming. The −Qocs option causes ld(1) to generate OCS conforming tdesc information. Linking in the object file /lib/ocs.o changes some of the libraries’ run-time behavior to conform to OCS requirements where they differ from traditional UNIX practice. See the "88open Compatibility Standards" chapter of the CX/UX Programmer’s Guide for more information. As an alternative to this option, the shell environment variable SDE_TARGET can be set to 88open.
sync_volatile
Ensure that the 88110 processor in Series 5000 systems does not reorder loads and stores to volatile variables. Use this option when compiling applications such as device drivers for which a load will change the state of the device.
spill_register_if_address_taken
If the address of a formal parameter is taken, copy the contents of all argument registers to memory locations. This option can sometimes be used to work around problems with functions that attempt to step through argument lists assuming that they were passed in as a list of arguments on the stack. This does not work if the functions fail to account for the 8-byte alignment requirement of double type arguments. Typically these functions should have been coded using the varargs(5) or stdargs(5) interface for passing variable argument lists to functions.
In addition to the above options, several options exist to control the search paths for the various processors invoked during compilation (see the COMPILATION PROCESSORS section of this man page).
PREDEFINED MACROS
The compiler defines several macro names automatically for use with conditional compilation directives to account for target machine and operating system dependencies. These macros all expand to the token 1, and therefore, can be used in #if as well as #ifdef constructs. The predefined macros are listed below:
_M88K Defined for all Series 4000 and Series 5000 target compilations
_M88100 Defined when compiling with the -Qtarget=M88100 option, or when compiling on a Series 4000 with no -Qtarget= flag
_M88110 Defined when compiling with the -Qtarget=M88110 option, or when compiling on a Series 5000 with no -Qtarget= flag
_M88110COMPAT
Defined when compiling on a Series 4000 or Series 5000 with the -Qtarget=M88110compat option
_OCS Defined when compiling with the -QOCS option, or when the shell variable SDE_TARGET is set to
unix Traditional macro to define for all UNIX operating systems
_unix Alternate spelling for unix
_CX_UX Indicates that the operating system is CX/UX
att_universe Defined if the universe switch is set to att
ucb_universe Defined if the universe switch is set to ucb
__HC__ Defined to indicate that this is the Harris C Compiler
Note that the macros unix, _unix, att_universe, and ucb_universe are not available when the compiler is run in Conforming Mode (−Xc option).
COMPILATION PROCESSORS
The hc program itself is a driver program that invokes several other processors (sometimes called passes) to do the actual work of compiling and linking your program. Exactly which processors are invoked and in what order is dependent on the command line options, the source files specified, the target machine hc is being used on, and on the particular release of hc in use. Here is a list of processors and the corresponding codes:
Preprocessor (denoted by the letter ’p’)
hc invokes one of two separate external preprocessors (depending on the compilation mode) to perform preprocessing on C source files. In Old mode (the default mode or when the −Xo option is specified), the traditional UNIX preprocessor cpp(1) located at /lib/cpp is used. In any of the ANSI modes (−Xa, −Xc, −Xt), the ANSI C Preprocessor, located at /lib/acpp, is invoked.
Compiler/Optimizer (denoted by the numbers ’0’, ’1’, or ’2’)
The Harris CCG based C compiler cxc, located at /lib/cxc, is invoked to perform the actual work of compiling the preprocessed source code. This processor is denoted by one of three numbers for historical reasons; however, all three numbers refer to the same processor.
Instruction Scheduler (denoted by the letter ’r’)
The cxc-reorder tool, located at /lib/cxc-reorder, is used to perform the final pass of code generation and instruction scheduling optimizations. At optimization level MINIMAL it performs peephole optimizations and fills branch delay slots. At GLOBAL and MAXIMAL it also performs instruction-scheduling optimizations. This processor is not intended for use with arbitrary assembler input, and is not invoked for assembler source files.
Assembler (denoted by the letter ’a’)
hc invokes an assembler pass as(1) to generate object files from assembler source (either for user-specified .s files or on the assembler output of the Compiler/Optimizer [or Instruction Scheduler] pass). When the −S command line option is specified the compilation is terminated just prior to the assembler pass, leaving assembly files as the final output of the compilation.
Link Editor (denoted by the letter ’l’)
The link editor ld(1), located at /bin/ld is invoked by hc to perform the final link of object files. When the −c command line option is used the link editor is not invoked, leaving object files as the final output of the compilation.
Post Link Optimizer (denoted by the number ’8’)
Hc invokes the analyze88(1) tool, located at /bin/analyze88, to perform post-linker optimizations on any linked executable generated by ld(1). This processor is invoked only if the −O is specified to hc when the link editor, ld(1) is invoked to generate the final executable. See the description of the −O option above.
When hc is used to link the final executable it includes one of several startup routines. These routines are located by default in the /lib directory. With the -QOCS flag, the versions located in /usr/88open/lib are used instead. The startup routines are crt0.o (default), gcrt0.o (if −G was used), or mcrt0.o (if −p was used). In addition to those, hc may link in one of several other auxiliary object files to control the run time behavior of the C library. These are: /lib/ocs.o (used with -Qocs), /lib/ansi.o (used with ANSI and Transition Mode compilations), and /lib/strict.o (used to enforce ANSI Conforming Mode).
The following command line options can be used to alter the search paths that hc uses to find the above processors and startup routines.
−bstring
Find substitute assembler, link editor, and post link optimizer processors in the files named string with the suffixes as, ld and analyze88, respectively. Multiple −b options may be used to specify multiple strings to try. By default these processors are searched for with the prefix /bin/.
−Bstring
Find substitute preprocessor, compiler, and instruction scheduler passes in the files named string with the suffixes cpp or acpp, cxc, and cxc-reorder, respectively. string is used as the prefix for the path names of the startup routines and auxiliary object files, as well. Multiple −B options may be used to specify multiple strings to try. By default these processors and object files are searched for with the prefix /lib/.
−t[p012arl8c]
Find only the designated compiler passes in the files whose names are constructed by a −B or −b option. The letters indicate the processors as listed above. The letter ’c’ indicates the startup routines and auxiliary object files.
−Wx,arg1[,arg2...]
Hand off the specified arguments to the processor x, where x is one of the letters [p012arl8] corresponding to the processors listed above. This can be used to pass special arguments to particular processors that hc invokes during the compilation. For instance to tell ld(1) to search for libraries in your home directory use -Wl,-L$HOME/ on the hc command line.
−X Do not look in unspecified search paths for include files or compilation processors. An error message will be generated if the files cannot be found in the specified search paths. Note that −X should not be immediately followed by additional arguments that conflict with the −X[acto] compilation mode options listed above.
The −v command line option is useful for determining exactly which processors are being invoked and from which paths they are being picked up. Alternate search paths are tried in the order in which they are specified. If a processor cannot be found in a specified path, a warning is issued, and the next path specified is tried.
FILES
| file.c | C input file |
| file.i | preprocessed C input file |
| file.s | assembler input file |
| file.o | object file |
| a.out | loaded output |
| /usr/include | standard directory for ’#include’ files |
| /tmp/hctm? | temporary files |
| /lib/crt0.o | runtime startup |
| /lib/mcrt0.o | runtime startup for prof(1). −p option |
| /lib/gcrt0.o | runtime startup for gprof(1). −G option |
| /lib/ansi.o | ANSI and Transitional Mode indicator. |
| /lib/strict.o | ANSI Conforming mode indicator. |
| /lib/libc.a | standard library |
| /lib/libp/libc.a | standard library when −p or −G is used |
| /lib/ocs.o | OCS conformance auxiliary object file |
| /usr/88open/lib/crt0.o | runtime startup with -QOCS |
| /usr/88open/lib/mcrt0.o | runtime startup for prof(1). −p option with -QOCS |
| /usr/88open/lib/gcrt0.o | runtime startup for gprof(1). −G option woth -QOCS |
| /usr/88open/lib/libc.a | standard library with -QOCS |
| /usr/88open/lib/libp/libc.a | standard library when −p or −G is used with -QOCS |
| /lib/acpp | ANSI C preprocessor. |
| /lib/cpp | C preprocessor cpp(1) |
| /lib/cxc | C compiler pass |
| /lib/cxc-reorder | instruction scheduler |
| /bin/as | assembler as(1) |
| /bin/ld | link editor ld(1) |
| /bin/analyze88 | post link editor optimizer |
SEE ALSO
CX/UX Harris C Reference Manual, CX/UX Programmer’s Guide,
adb(1), analyze88(1), as(1), cc(1), cpp(1), gdb(1), gprof(1), lint(1), ld(1), prof(1)
DIAGNOSTICS
The diagnostics produced by hc itself are intended to be self-explanatory.
BUGS
The asm pseudo function is not accepted.
CX/UX Harris C Reference Manual