Skip to Main Content

DevOps, CI/CD and Automation

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Sun Studio 12 - Compiling for 64-bit sparc using 'cc -xarch=v9'

807578Nov 11 2008 — edited Nov 12 2008
Hello,

I am using Sun Studio 12 on a Sun Blade running 64-bit Solaris 10 u3 for sparc. Properties are set for the "Solaris sparc" platform in my projects. I am compiling HDF5 software (http://www.hdfgroup.org/HDF5/release/obtain5.html), and I noticed this in the INSTALL notes:

Similarly, users compiling on a Solaris machine and desiring to
build the distribution with 64-bit support should specify the
correct flags with the CC variable:

$ CC='cc -xarch=v9' ./configure

Does the fact that the platform architecture is set to sparc in the project properties make it unnecessary to specify -xarch=v9 for the CC environment variable, or should I always use $CC='cc -xarch=v9' when compiling on my sparc?

Thank you in advance...

Comments

807578
Compilation by default on Solaris is always 32-bit. If you want 64-bit compilation you must ask for it.
The -xarch=v9 option is deprecated in Studio 12. Use -m64 instead.

Normally you specify architecture in an option macro (like COPTS) instead of making it part of the compiler command.
807578
Thank you very much for the info!

Could you please steer me in the right direction to find out more about these option macros so that I could learn how to make one? What is COPTS? Is there an example somewhere of a macro that defines the build environment?

Right now I can add a line to the Makefile.mk file under "Environment" reading:

CC='cc -m64'

That will do it for now, right?
807578
Setting CC='cc -m64' in the Makefile.mk does not appear to work, as that is overridden by the env variable set by .login. Where is the best place to set -m64? I can't find any place in Sun Studio to set it, or to otherwise specify 64-bit optimized output. The help for Project Properties General mentions 64-bit, but I cannot find where they are talking about. I could set the environment variable in my .login (set now so that $CC=cc), but I would rather set in the project properties for each project. How do I do that?
807578
Actually, I think the correct cc call for SS12 is:

cc -xarch=sparc -m64
807578
The -xarch=sparc option would be correct if you are compiling for a very old sparc chip, prior to the introduction of the UltraSPARC more than 10 years ago.

Omitting -xarch=sparc gives you the default, code for a generic but modern sparc processor.

The C++ Users Guide has the details, in appendix A for the -xarch option.
807578
Thanks for the info. I'm using and Ultrasparc IIe 640 MHz (Sun Blade 150). Do you think it is worth it to recompile using just -m64 with no xarg=sparc?

http://docs.sun.com/source/820-4155/c.html

Deprecated -xarch Flags and Their Replacements Across SPARC and x86
If you are using -xarch=v9 or -xarch=amd64 to specify a 64-bit address model, use just -m64 instead. No -xarch value is required.

* Use -m64 in place of -xarch=generic64
* Use -m64 -xarch=native in place of -xarch=native64

Deprecated -xarch Flags and Their Replacements on SPARC Only

* Use -xarch=sparc in place -xarch=v8plus
* Use -xarch=sparcvis in place of -xarch=v8plusa
* Use -xarch=sparcvis2 in place of -xarch=v8plusb
* Use -xarch=sparc -m64 in place of -xarch=v9
* Use -xarch=sparcvis -m64 in place of -xarch=v9a
* Use -xarch=sparcvis2 -m64 in place of -xarch=v9b
807578
My processor is actually an UltraSPARC IIi. I think -xarch=sparcvis -m64 would be ideal for my machine, no?

Thank you very much for the tip about the Appendix A in the C++ guide!
807578
Hi, so far, the people answering this posting have (mostly) been compiler people. I'll leave the question of the exact set of
flags to them and answer with respect to getting the sunstudio IDE to use them.

First off, if the project has its own Makefiles (which it probably does if it has a configure script) then you should run the
configure script outside of the IDE and set the options there. In Later Sun Studio releases you can run a configure script
from inside the IDE and you'd use the some CC= (or CFLAGS= or COPTS=).

If you're project doesn't have its own Makefiles then you should set the Architecture in the project's properties panel to
"64 Bits". Right click on your project and select Properties. In the Categories panel, open C/C++/Fortran, then C Compiler,
and then select the General node (in later releases of sunstudio this isn't so buried:-). When you click General you'll get a
set of properties in the right-hand panel. The Architecture property is in the Basic Options portion of this panel

The same properties exist for C++ and Fortran, too.

For general options (ie, options we don't have an explicit property for), click on the Command Line node and add the option
to the Additional Options property to the right.
807578
Ah ha! Thank you, thank you.

You wrote:

Right click on your project and select Properties. In the Categories panel, open C/C++/Fortran, then C Compiler, and then select the General node (in later releases of sunstudio this isn't so buried:-). When you click General you'll get a set of properties in the right-hand panel. The Architecture property is in the Basic Options portion of this panel

The above is just what the help alludes to, but I cannot find any of this. It's almost as if I'm using a different version of SS. (I'm not, it's SS12 for sparc, fully patched). In Project Properties, there is no C/C++/Fortran Category, only General (includes Platform, set to 'Solaris sparc'), Running, Debugging, Advanced (Adv. Profiling, Thread Analysis, Runtime mem. checking), Make, and Code Assistance (C and C++ Compiler, both with General where you can enter include directories and Preprocessor Defs). There is nothing anywhere about Architecture. The Command Line option you and the help mention is also not there. I am completely confused. Any ideas?

I have been running configure from within SS12, and specifying Arguments (such as --prefix=/temp/hdf5-1.8.1) in Properties for the configure file under Important Files. However, with that method I cannot specify the cc options as I can from outside the IDE like this:

./configure CC='cc -xarch=sparcvis -m64'

Could you please tell me how to specify Arguments for the configure run, including CC, CFLAGS, COPTS?

Thanks again for your help!
807578
sparcmaster wrote:
My processor is actually an UltraSPARC IIi. I think -xarch=sparcvis -m64 would be ideal for my machine, no?
Compared to -xarch=sparc, -xarch=sparcvis should give you much better performance. Compared to using no -xarch option (taking the "generic" default), whether you see a difference depends on the characteristics of your code.

With the generic option, the code will run on Ultrasparc II and Niagara (T1000, T2000 systems). With -xarch=sparcvis the code will run only on US III, US IV, or US VI.
807578
For example, configure will NOT run in the SS12 IDE with this as the Argument:

CC='cc -xarch=sparcvis -m64' --prefix=/temp/hdf5-1.8.1
807578
clamage45,

Uh-oh! You said that if I use xarg=sparcvis, the binary will only run on US III+, not on UltraSparc II?

I thought that sparcvis would be optimal for my UltraSparc IIi (that's 2i)? Please clarify.

from C++ guide, appendix A:

sparcvis:

Compile for SPARC-V9 plus the Visual Instruction Set (VIS) version 1.0, and with UltraSPARC extensions. This option enables the compiler to generate code for good performance on the UltraSPARC architecture.

sparcvis2:

Enables the compiler to generate object code for the UltraSPARC architecture, plus the Visual Instruction Set (VIS) version 2.0, and with UltraSPARC III extensions.

The above suggests that sparcvis2 works only on UltraSParc III+.
807578
I ended up using cc xarch=native64.

I think I understand why my Project Properties didn't have reference to 64-bit architecture. That is probably only available when no makefile is present.
807578
sparcmaster wrote:
Uh-oh! You said that if I use xarg=sparcvis, the binary will only run on US III+, not on UltraSparc II?

I thought that sparcvis would be optimal for my UltraSparc IIi (that's 2i)? Please clarify.
Sorry. On my display, IIi and III are hard to tell apart (unless I increase the font size).
The default generic code generation option will work fine for US IIi. The sparcvis option will not work if the object file winds up with US III extensions.
1 - 14
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Dec 10 2008
Added on Nov 11 2008
14 comments
318 views