Solaris 1.x to 2.x Transition Guide

Compilers

The single most significant change for developers migrating from the SunOS release 4.x to the Solaris 2.6 operating environment is the unbundling of the C compiler. One of the factors that allowed the compiler to be unbundled is the dynamic kernel. The compiler is no longer required to reconfigure the kernel as devices are now automatically loaded by the kernel as needed.

An ANSI C compiler is available with unbundled Sun WorkShop(TM). This compiler produces executables in executable and linking format (ELF), the native object format of Solaris 2.6 executables. lint and the lint libraries are also unbundled.

Source Compatibility Guide describes the differences between the C language as implemented by the SunOS release 4.x C compiler (Sun C) and as described by the ANSI Programming Language C document (ANSI C). These differences should be addressed when porting source written for the Sun C compiler to an ANSI C conforming compiler.

Compiler Option Differences

Table 15-1 compares the SunOS release 4.x Sun C and ANSI C compilers to the Solaris 2.6 Sun WorkShop(TM) C++ 4.2. It is provided for your information, and is not intended to describe the range of operations available in default Solaris 2.6 software.


Note -

Table 15-1 presents information based on the publicly available copies of the American National Standard for Information Systems - Programming Language XX3.159-1989, approved December 14, 1989.


Please note the following:

Table 15-1 Comparison of C Compiler Options

Option or Flag 

Sun C 

ANSI C 

Sun WorkShop(TM) C++ 4.2 

Description  

-A symbol

No 

Yes 

Yes 

cpp predicate assertion

-a

Yes 

Yes 

-xa

Counts # basic block executions  

-align

Yes 

Yes 

No 

Page aligns (ld)

-assertx

Yes 

Yes 

-z

Specifies link-time assertion  

-BX

Yes 

Yes 

Yes 

Specifies binding type (only for libraries in SunOS release 5.6) 

-bnzero

Yes 

Yes 

No 

Generates nonzero AR  

-C

Yes 

Yes 

No 

cpp comments left in

-c

Yes 

Yes 

+Yes 

Produces .o file

-cg87

Yes 

Yes 

No 

Sets fp option to -cg87

-cg89

Yes 

Yes 

Yes 

Sets fp option to -cg89

-dryrun

Yes 

Yes 

Yes 

Shows commands constructed by driver  

-Dx

Yes 

Yes 

+Yes 

Defines cpp symbol x

-d

Yes 

Yes 

No 

Forces definition of common (ld)

-dalign

Yes 

Yes 

Yes 

Assumes doubles are double-word aligned  

-dl

Yes 

Yes 

No 

Generates long data segment refs  

-d[y|n]

-BX-BX

Yes 

Dynamic linking [yes|no]  

-E

Yes 

Yes 

+Yes 

Runs source through cpp

-e

No 

No 

No 

Entry point for ld  

-F

-O*

-O*

+No 

Optimization directives  

-f

No 

No 

No 

Floating-point support  

-fast

Yes 

Yes 

Yes 

Options for best performance  

-fsingle

Yes 

No 

No 

Floats are single precision  

-fsingle2

Yes 

No 

No 

Passes float (as float not double)  

-fnonstd

Yes 

Yes 

Yes 

Non-standard float option  

-fstore

Yes 

No 

Yes 

Forces writes on store  

-G

No 

No 

Yes 

Creates shared library, not available with the -dn option

-g

Yes 

Yes 

+Yes 

Generates info for dbx  

-go

Yes 

No 

No 

Generates info for adb  

-H

Yes 

Yes 

Yes 

Prints paths of included files  

-h name

No 

No 

Yes 

Uses name as internal identifier; soname passed to linker

-help

Yes 

Yes 

-flags

Lists options  

-Ix

Yes 

Yes 

+Yes 

Adds x to include path  

-J

sun3 

No 

No 

Generates long offset for switch|case  

-KPIC

-PIC

-PIC

Yes 

Position independent code  

-Kpic

-pic

-pic

Yes 

PIC with short offsets  

-Kminabi

No 

No 

No 

ABI compliant code  

-libmil

Yes 

Yes 

-xlibmil

Passes libm.il as part of -fast

-lx

Yes 

Yes 

Yes 

Reads object library (for ld)  

-Lx

Yes 

Yes 

Yes 

Adds x to ld library path  

-M

Yes 

Yes 

No 

Collects dependencies 

-M mapfile

Yes 

No 

No 

Passes mapfile to the linker

-misalign

Yes 

Yes 

Yes 

Handles misaligned Sun-4 data  

-N

Yes 

No 

No 

Does not make shared  

-n

Yes 

No 

No 

Makes shared  

-native

Yes 

Yes 

Yes 

Uses appropriate -cg option

-noc2

Yes 

Yes 

No 

Doesn't do peephole optimization  

-nolibmil

Yes 

Yes 

-xnolibmil

Doesn't pass libm.il with -fast

-o file

Yes 

Yes 

+Yes 

Sets name of output file  

-O[1,2,3,4]

Yes 

Yes 

-x0[1,2,3,4]

Generates optimized code  

-O

Yes 

Yes 

+Yes 

Generates optimized code  

-P

Yes 

Yes 

+Yes 

Runs source through cpp, output to .i

-PIC

Yes 

No 

-KPIC

Generates pic code with long offset 

-p

Yes 

Yes 

+Yes 

Collects data for prof  

-pg

Yes 

Yes 

-xpg

Collects data for gprof  

-pic

Yes 

Yes 

-Kpic

pic code with short offset  

-pipe

Yes 

No 

No 

Uses pipes instead of temp files  

-purecross

Yes 

No 

No 

Doesn't have slash in VROOT  

-Qdir x

Yes 

Yes 

-Y*

Looks for compiler passes in x  

-Qpath x

Yes 

Yes 

-Y*

Same as -Qdir

-Qn

No 

No 

Yes 

Doesn't add version stamp info  

-Qy

No 

No 

Yes 

Adds version stamp info  

-qdir x

Yes 

Yes 

No 

Looks for compiler passes in x  

-ql

No 

No 

No 

Collects data for lprof  

-qp

-p

-p

-p

Collects data for prof  

-qpath x

Yes 

Yes 

No 

Same as -Qdir

-Qoption cpp x

Yes 

Yes 

Yes 

Passes option x on to program cpp

-Qoption iropt x

Yes 

Yes 

Yes 

Passes option x on to program iropt  

-Qoption cg x

Yes 

Yes 

Yes 

Passes option x on to program cg

-Qoption inline x

Yes 

Yes 

No 

Passes option x on to program inline  

-Qoption as x

Yes 

Yes 

No 

Passes option x on to program as

-Qoption asS x

Yes 

Yes 

No 

Passes option x on to program asS

-Qoption ld x

Yes 

Yes 

Yes 

Passes option x on to program ld

-qoption cpp x

Yes 

Yes 

No 

Passes option x on to program cpp

-qoption ccom x

Yes 

Yes 

No 

Passes option x on to program ccom

-qoption lintl x

Yes 

Yes 

No 

Passes option x on to program lint1

-qoption iropt x

Yes 

Yes 

Yes 

Passes option x on to program iropt

-qoption cg x

Yes 

Yes 

Yes 

Passes option x on to program cg

-qoption inline x

Yes 

Yes 

No 

Passes option x on to program inline

-qoption cat x

Yes 

Yes 

No 

Passes option x on to program cat

-qoption c2 x

Yes 

Yes 

No 

Passes option x on to program c2

-qoption as x

Yes 

Yes 

No 

Passes option x on to program as

-qoption asS x

Yes 

Yes 

No 

Passes option x on to program asS

-qoption ld x

Yes 

Yes 

Yes 

Passes option x on to program ld

-Qproduce .o

Yes 

Yes 

Yes 

Produces type .o file (Object file)

-Qproduce .s

Yes 

Yes 

Yes 

Produces type .s file (Assembler source)

-Qproduce .c

Yes 

Yes 

No 

Produces type .c file (C source)

-Qproduce .i

Yes 

Yes 

Yes 

Produces type .i file (C source after cpp)

-qproduce .o

Yes 

Yes 

Yes 

Produces type .o file (Object file)

-qproduce .s

Yes 

Yes 

Yes 

Produces type .s file (Assembler source)

-qproduce .c

Yes 

Yes 

No 

Produces type .c file (C source)

-qproduce .i

Yes 

Yes 

Yes 

Produces type .i file (C source after cpp)

-r

Yes 

Yes 

No 

Makes relocatable; pass to linker  

-R

Yes 

Yes 

No 

Merges data into text segment  

-R

No 

No 

Yes 

Specifies search directories for the run-time linker 

-S

Yes 

Yes 

+Yes 

Produces .s file only

-s

Yes 

Yes 

Yes 

Strips (4.1); pass to linker  

-sb

Yes 

Yes 

-xsb

Collects information for code browser  

-strconst

No 

Yes 

No 

Places string literals in read-only text segment 

-sun2

Yes 

No 

No 

Generates code for a Sun-2(TM) system  

-sun3x

Yes 

No 

No 

Generates code for a Sun-3x(TM) system  

-sun386

Yes 

No 

No 

Generates code for a Sun386i(TM) 

-sun3

Yes 

No 

No 

Generates code for a Sun-3 system  

-sun4c

Yes 

No 

No 

Generates code for a Sun4c(TM) system  

-sun4

Yes 

No 

No 

Generates code for a Sun-4(TM) system  

-target

Yes 

No 

-xtarget

Sets target architecture to x  

-temp=dir

Yes 

Yes 

Yes 

Set directory for temps to dir  

-time

Yes 

Yes 

Yes 

Reports the execution times  

-u

Yes 

Yes 

No 

Enters symbol arg as undef (ld)  

-Ux

Yes 

Yes 

+Yes 

Undefines cpp symbol x

-v

Yes 

Yes 

Yes 

Verbose mode 

-v

No 

No 

Yes 

Strict semantic checking 

-V

Yes 

Yes 

+Yes 

Reports versions of programs  

-W

No 

No 

No 

Arguments to other components  

-w

Yes 

Yes 

Yes 

Does not print warnings  

-X[t,a,c,s]

No 

Yes 

No 

Compatibility options  

-Y

No 

No 

No 

Changes path name to components  

-yx

Yes 

No 

No 

Traces symbol  

-z

-assert

-assert

No 

Turns on asserts in linker  

-#

-v

-v

No 

Verbose mode  

-EOF

No 

No 

No 

File argument  

The C compiler accepts the types of file-name arguments shown in Table 15-2.

Table 15-2 File-name Extensions Used by the C Compiler

Suffix 

File Type 

.a

Object library 

.il

In-line expansion file  

.o

Object file  

.so

Shared object  

.s

Assembler source  

.S

Assembler source for cpp

.c

C source  

.i

C source after cpp

"file.X=.Y" will read the file "file.X" but treat it as if it had suffix "Y"