Updated 2001/05/15
 

Sun WorkShop(TM) 6 update 2:  64-Bit Compilers README



Introduction

This release of the Sun WorkShop(TM) compilers (C, C++, FORTRAN 77, Fortran 95) supports the 64-bit SPARC(TM) Platform Editions of the Solaris(TM) 7 and Solaris 8 Operating Environments. This means that the cc, CC, f77, and f95 compilers can generate 64-bit object binaries to run in a 64-bit enabled Solaris Operating Environment.

Compilation, linking, and execution of these programs must all take place in a Solaris 7 or 8 environment. The compilers (with the exception of C++) can also produce 64-bit applications when compiling on a 32-bit system, but compilation still must take place under Solaris 7 or 8. In all cases, the flag -xarch=v9,-xarch=v9a, or -xarch=v9b must be specified. This is what is meant by "compiling for a 64-bit SPARC environment".

This README provides basic information for developers of 64-bit C, C++, FORTRAN 77, and Fortran 95 applications under a 64-bit Solaris operating environment and pointers to more detailed sources.


For More Information

Details can be found from the following:


Compiling For 64-Bit Solaris Environments

The compilers in this release can produce 64-bit objects on either 32-bit or 64-bit architectures running a 64-bit enabled Solaris operating environment (the Solaris 7 or 8 SPARC Platform Edition). The resulting executable will run only on 64-bit UltraSPARC(TM) processors with the Solaris  64-bit kernel. Compilation, linking, and execution of 64-bit objects can only take place in a 64-bit Solaris environment.

Compiling for a 64-bit environment is indicated by the -xarch=v9 (or v9a or v9b) options. Note that one of these options must be specified even if -xtarget or -fast are also specified. In such a case, the -xarch=v9 (or v9a, v9b) option must appear AFTER -xtarget or -fast or any other option that sets -xarch. For example:

    -xtarget=ultra -xarch=v9

Note that -xtarget=ultra, ultra2, ultra2i, or ultra3,  imply -xarch=v8 and do not automatically signal -xarch=v9 ,v9a, or v9b. Also, -fast implies -xarch=native (which in turn implies -xarch=v8). 

Also note that if compiling specifically for the UltraSPARC III platform, use -xarch=v8plusb to generate 32-bit object binaries, or -xarch=v9b for 64-bit object binaries.



What's So Special About 64-Bit Solaris Operating Environments

The 64-bit Solaris operating environment is a complete 32-bit and 64-bit application and development environment supported by a 64-bit operating system. The 64-bit Solaris operating environment overcomes the limitations of the 32-bit system by supporting a 64-bit virtual address space as well as removing other existing 32-bit system limitations.

For C, C++, and Fortran software developers, this means the following when compiling with -xarch=v9,v9a, or v9b in a Solaris 7 or Solaris 8 environment:


General Considerations:

The following items are general issues regarding compiling for 64-bit Solaris environments. For specific issues, see the individual compiler man pages and READMEs.


The Solaris SPARC Assembler 

The SPARC-V9 architecture differs from the SPARC-V8 architecture in the following areas: registers, alternate space access, byte order, and instruction set. The Solaris SPARC Assembler has been extended to accommodate these new features.

The SPARC Assembly Language Reference Manual can be viewed athttp://docs.sun.com and appears under the Solaris 7 Software Developer Collection.

There is one undocumented pseudo instruction that is important for those porting assembly language code to SPARC-V9:

    .register %g{2|3|6|7}, {#scratch|symbol_name}

With SPARC-V9, the four registers %g2, %g3, %g6, %g7, should not be used unless explicitly declared on a .register pseudo-op. Under -xarch=v9, the SPARC assembler will issue an error message if it detects the use of %g2 or %g3 registers without a .register declaration. A .register declaration is not required for %g6 or %g7, but its appearance does invoke checking for proper use of these registers.

Specify the #scratch option when the register is used as a scratch register:

    .register %g3, #scratch

Or, declare the global register with a symbolic name, as in:
    .register %g2, xyz

A .register declaration must appear before the first use of the register. Linking objects containing conflicting registers will cause the linker to issue error messages.

Frequently Asked Questions

These questions appear in the Solaris 64-bit Developer's Guide, and refer to running on 32-bit and 64-bit versions of Solaris 7 or 8:

Q: Can I run the 64-bit version of the Solaris 7 operating environment on 32-bit hardware? 
A: No. Though the 32-bit operating environment can run on 64-bit hardware, it is not possible to run the 64-bit operating environment on 32-bit hardware. The 64-bit operating environment requires 64-bit MMU and CPU hardware.

Q: Do I need to change my 32-bit application if I plan to run that application on a system with a 32-bit operating environment? 
A: No. Your application does not require changes or recompilation if it is being executed only on a system running the 32-bit operating environment.

Q: Do I need to change my 32-bit application if I plan to run that application on a system with the 64-bit operating environment? 
A: Most applications can remain 32-bit and still execute on a system running the 64-bit operating environment without requiring code changes or recompilation. Those 32-bit applications not requiring 64-bit capabilities can remain 32-bit to maximize portability.

Q: What program do I need to invoke in order to get the 64-bit capabilities? 
A: No program is available that specifically invokes 64-bit capabilities. In order to take advantage of the 64-bit capabilities of your system running the 64-bit version of the operating environment, you need to rebuild your applications using the -xarch=v9 option of the compiler or assembler.

Q: Can I build a 32-bit application on a system running the 64-bit Solaris 7 operating environment? 
A: Yes. Both native and cross-compilation modes are supported. The default compilation mode is 32-bit, whether on a system running the 32-bit or 64-bit version of the operating environment.

Q: Can I build a 64-bit application on a system running the 32-bit operating environment? 
A: Yes, provided you have the 64-bit library packages installed. However, it is not possible to run the 64-bit application on a system running the 32-bit operating environment.

Q: Can I combine 32-bit libraries and 64-bit libraries when building and linking applications? 
A: No. 32-bit applications must link with 32-bit libraries and 64-bit applications with 64-bit libraries. Attempts to build or link with the wrong version of a library will result in an error.


Copyright  2001 Sun Microsystems, Inc., 901 San Antonio Road, Palo Alto, CA 94303, U.S.A. All rights reserved. 
Sun, Sun Microsystems, the Sun logo, docs.sun.com, and Solaris are trademarks, registered trademarks, or service marks of Sun Microsystems Inc. in the U.S. and other countries.