Sun WorkShop(TM) 6:  64-Bit Compilers README
Updated 00/04/05
 
Contents 
  • Introduction
  • For More Information
  • Compiling For 64-Bit Solaris Environments
  • What's So Special About 64-Bits?
  • General Considerations
  • SPARC Assembler
  • Frequently Asked Questions


  • 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 environment".

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


    For More Information

    For more information, consult:

    • cc(1), CC(1), f77(1), and f95(1) man pages

    •  
    • The c, c++, fortran_95, and fortran_77 READMEs, viewable by running:

    •            cc -xhelp=readme     or
                 CC -readme           or
                 f77 -xhelp=readme    or
                 f95 -xhelp=readme
       
    • The "Solaris 64-bit Developer's Guide" in Solaris AnswerBook, part of the Solaris Software Developer Collection.

    •  
    • The http://www.sun.com/developers/64bits/ website.

    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 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, or ultra2i, imply -xarch=v8 and do not automatically signal -xarch=v9 or v9a. Also, -fast implies -xarch=native (which in turn implies -xarch=v8). 


    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 or v9a in a Solaris 7 environment:
     

  • Full 64-bit integer arithmetic for 64-bit applications. Though 64-bit arithmetic has been available in all Solaris 2 releases, the 64-bit implementation now uses full 64-bit machine registers for integer operations and parameter passing.

  •  
  • A 64-bit virtual address space allows programs to access very large blocks of memory.

  •  
  • For C and C++, the data model is "LP64" for 64-bit applications: long and pointer data types are 64-bits and the programmer needs to be aware that this change may be the cause of many 32-bit to 64-bit conversion issues. The details are spelled out in the Solaris 64-bit Developer's Guide, available on AnswerBook2. Also, the lint -errchk=longptr64 option can be used to check a C program's portability to an LP64 environment. Lint will check for assignments of pointer expressions and long integer expressions to plain (32-bit) integers, even for explicit casts.

  •  
  • The Fortran programmer needs to be aware that POINTER variables in a 64-bit environment are INTEGER*8. Also, certain library routines and intrinsics will require INTEGER*8 arguments and/or return INTEGER*8 values when programs are compiled with -xarch=v9 or v9a that would otherwise require INTEGER*4.

  •  

     

    Be aware however that even though a program is compiled to run in a 64-bit environment, default data sizes for INTEGER, REAL, COMPLEX, and DOUBLE PRECISION do not change. That is, even though a program is compiled with -xarch=v9, default INTEGER and REAL are still INTEGER*4 and REAL*4, etc. To use the full features of the 64-bit environment, some explicit typing of variables as INTEGER*8 and REAL*8 may be required. Also, some 64-bit specific library routines (such as QSORT64(3F) and MALLOC64() ) may have to be used. For details, see the FORTRAN 77 or Fortran 95 READMEs (viewable with the f77 or f95 compiler option: -xhelp=readme).


    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.
     

  • For programs creating large files or using the 64-bit address space, check the system resource limits for the shell in which the program will run. (See the limit(1) or ulimit(1) man pages.) In particular, maximum file size and data heap size should be set "unlimited". Note however that programs compiled by cc, CC, f77, and f95 currently are limited to a stack size maximum of 2 Gigabytes.

  •  
  • When building shared dynamic libraries with -xarch=v9 or v9a in a 64-bit Solaris environment, the -Kpic or -KPIC option MUST be specified. See also the new -xcode=abs32|abs44|abs64|pic13|pic32 option for specifying code address sizes.

  •  
  • A new environment variable, LD_LIBRARY_PATH_64 is provided in Solaris 7 and 8 and is similar to LD_LIBRARY_PATH, but overrides it when during linking when searching for 64-bit dependencies.

  •  
    • On 32-bit SPARC processor  LD_LIBRARY_PATH_64 is ignored.
    • If only LD_LIBRARY_PATH is defined, it is used for both 32-bit and 64-bit linking. 
    • If both LD_LIBRARY_PATH and LD_LIBRARY_PATH_64 are defined, 32-bit linking will be done using LD_LIBRARY_PATH, and 64-bit linking with LD_LIBRARY_PATH_64.
    (See the "Solaris Linker and Libraries Guide" on AnswerBook2 and the ld(1) man page for details.)
     
  • 64-bit math libraries: With the exception of libcx and the profiling libraries, all of the math libraries provided with Sun WorkShop Compilers are now available in versions that can be used with programs compiled for the 64-bit Solaris environment. Unless otherwise noted, you do not need to specify any additional options to link with these versions of the libraries; the compilers will automatically select the correct set of libraries based on the -xarch option specified on the link line. Be sure to read the "math_libraries" README file in the <install_path>/SUNWspro/READMEs/ directory. (Usually this is /opt/SUNWspro/READMEs/ ).

  •  
  • 64-bit Solaris operating environments can run with either a 32-bit or 64-bit environment on UltraSPARC platforms. Use the command isainfo(1) to determine which is running. For example, on an UltraSPARC running the 64-bit kernel of Solaris 7 or 8:
  •          % isainfo -v
               64-bit sparcv9 applications
               32-bit sparc applications
    indicates that the system will accept both 64-bit and 32-bit applications. See isainfo(1) on Solaris 7 or 8 for more details. ("isa" by the way stands for "Instruction Set Architectures.)


    The SPARC Assembler 

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

    The SPARC Assembly Language Reference Manual can be viewed at http://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 register 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  2000 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.