Goodbye -xarch=amd64, hello -m64
By Chris Quenelle on Jan 31, 2007
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|
|sse2 plus AMD extensions||sse2a||amd64a||sse2a|
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.