Goodbye -xarch=amd64, hello -m64

I've talked before about how the Sun Studio 12 compilers are implementing the -m32 and -m64 options like gcc has. For background, you might want to read my old blog on the subject.  We finally worked out the details for how -xarch was supposed to interact with -m32 and -m64, and got it implemented in our latest development build.  Of course, there's always someone who's surprised by behavior that seems obvious to someone else.  So here's what we ended up with. (Thanks to Fedor for collecting and summarizing this recently for an internal announcement.)

The first thing to note is that old command line combinations will continue to work as before.  So there's no incompatible changes.  But there is a recommended change.

Previously, you specified that you wanted a 64-bit program by using either -xarch=v9 or -xarch=amd64 (or if you followed our docs carefully, you might have been using -xarch=generic64).  The better way to do that now (in Sun Studio 12) is to use -m32 to get a 32-bit program (called ILP32) and use -m64 to get a 64-bit program (called LP64).

Benefits are: 1) You can use the same options on sparc and intel, which is nice if you are building on both platforms. 2) Since our compilers default to 64-bit on a 64-bit capable Linux system, but default to 32-bit on a 64-bit capable Solaris system (long story) it can help to use either -m32 or -m64 all the time if you are building on both Linux and Solaris.  That way you always know what you're getting.

But what do we do about all those old -xarch values which also had the side-effect of specifying 32-bit or 64-bits?  The short answer is:  You don't need to know this.  Just change your makefiles to use -m32 and -m64 when they need to and stop using -xarch.  If you're one of those lucky (?) people who has to worry about specifying exactly which kind of instruction sets you want the compiler to use, then read on.

The gory details:

The -xarch values that exist in Sun Studio 11 will be continue to be supported with their original meaning and without any additional warnings.  So we're not going to annoy you if want to keep using all your old options.

But there will also be some new -xarch values for new instructions sets in Sun Studio 12 (x86 and/or sparc, I don't want to spoil the surprise yet)  If you end up trying to specify both a new -xarch value and an old -xarch value at the same time (like if you're trying to override one with another), the compiler will tell you to get rid of the old -xarch value, and fix up your options to include only the new ones.

More specifically, we had to create new -xarch values for sparc that didn't imply either 32-bit or 64-bit programs.  Otherwise, we wouldn't know whether users are trying to set program size or not.

instruction set old -xarch value in 32bits old -xarch value in 64bits new -xarch value agnostic of bit size
v9 chip no VIS v8plus v9 sparc
VIS v8plusa v9a sparcvis
VIS2 v8plusb v9b sparcvis2
sse2 sse2 amd64 sse2
sse2 plus AMD extensions sse2a amd64a sse2a
new coolness N/A N/A new_coolness

If -m32 and -m64 aren't enough for you, and you really need to say exactly which instruction sets you want to use, then you can use this table to figure out how to convert your stale old-style -xarch value into a shiny new bit-size-agnostic value.

Comments:

Okay, that's great. Now, how do you specify which libraries to link against? The loader will look for a subdirectory called either "32" or "64" in /usr/lib, but not anywhere else. How do you specify the libraries for other directories?

Posted by Brian Utterback on January 31, 2007 at 11:02 PM PST #

We don't have any features to help with this. You have to set special makefile variables and use (for example) -L$(LIB_PATH_32) when building a 32-bit program, and -L$(LIB_PATH_64) when building a 64-bit program. If you're interested in specific Makefile recipes for dealing with this kind of stuff, I can dig up some recommendations. One problem is that there is no standard directory structure for 32 and 64-bit libraries. Solaris has a set of conventions, but there is no built-in support in the linker or the runtime linker for those conventions. If the user says -L/my/dir we could update the linker to also search -L/my/dir/32 for 32-bit programs, and -L/my/dir/64 when building 64-bit programs. Is that the kind of thing you were thinking of? If so, you could suggest that RFE on the tools-linking@opensolaris.org alias. That would be a linker feature.

Posted by Chris Quenelle on February 01, 2007 at 02:57 AM PST #

Post a Comment:
Comments are closed for this entry.
About

Chris Quenelle

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today