#1186 closed Bugs (fixed)
Lack of 64-bit address model support using Sun Studio C++
Reported by: | Owned by: | Vladimir Prus | |
---|---|---|---|
Milestone: | To Be Determined | Component: | build |
Version: | Boost 1.34.1 | Severity: | Problem |
Keywords: | Cc: |
Description
It is not possible to build 64-bit version of Boost libraries using Sun Studio C++.
- 'tools/build/v2/tools/sun.jam' should conatin something like:
flags sun OPTIONS <architecture>/<address-model>32 : -m32 ; flags sun OPTIONS <architecture>/<address-model>64 : -m64 ;
- To build shared libraries Sun Studio C++ requires -Kpic or -KPIC command line option for compilation and linking. This option mandatory for 64-bit shared libraries and strongly recommended for 32-bit ones. What option to choose (-Kpic or -KPIC) depends on the size of the Global Offset Table (GOT). For Boost libraries -Kpic is enough.
Here is corresponded Sun Studio documentation article: http://docs.sun.com/app/docs/doc/819-5267/6n7c46duv?a=view
Change History (11)
comment:1 by , 15 years ago
Component: | Building Boost → build |
---|---|
Owner: | set to |
comment:2 by , 15 years ago
comment:3 by , 15 years ago
Re point 1, I've added this code:
flags sun OPTIONS <address-model>32 : -m32 ; flags sun OPTIONS <address-model>64 : -m64 ;
Note there's no 'architecture', because with the original code, -m32 will be only used if no architecture is specified. So, if user wanted to be explicit and say 'architecture=sparc' on the command like, then -m32 and -m64 will disappear.
comment:4 by , 15 years ago
I am not sure about -Kpic vs. -KPIC. Boost.Build is for general use, and we have no idea how large GOT table will be required by libraries it builds. Will -KPIC be OK?
comment:5 by , 15 years ago
Starting with Sun Studio 12, the options for 32-bit and 64-bit compiling are -m32 and -m64, as with gcc. 32-bit mode is the default on Solaris, and on 32-bit Linux. On 64-bit Linux, 64-bit mode is the default.
Earlier versions of Sun Studio did not recognize the -m32 and -m64 options. On those versions, use -xarch=generic64 for 64-bit compilation instead.
comment:6 by , 15 years ago
Here's the story on -Kpic and -KPIC:
On x86/x64, there is no difference between -KPIC and -Kpic.
On sparc, -Kpic is slightly more efficient, but the difference is not always enough to notice.
You compile for position-independent code (-Kpic or -KPIC) usually only when building a shared library.
The difference on sparc is in the instructions used to access the symbol via the offset in the Global Offset Table (GOT) in the shared library. The -Kpic option causes the compiler to generate a single instruction with 13 bits for the offset value. The -KPIC option uses two instructions to get a 32-bit offset.
You compile a file with -Kpic when you know it will be used in a shared library with a modest number of global symbols (references or definitions).
When building your own shared library, you can try building with -Kpic. If it links, you are done. A shared library built with -Kpic can be linked to a program with a large number of global symbols, because uses of the symbol offsets in the shared library are confined to the library itself.
If you build a "loose" .o file or an archive (.a) to be used by other people in their own shared libraries, it is safest to use -KPIC. That allows the files to be linked into a big shared library.
You can mix -Kpic and -KPIC code in the same shared library, as long as the -Kpic code doesn't need an offset taking more than 13 bits. In other words, a client who used -Kpic can still use your -KPIC binaries in the client library.
comment:8 by , 15 years ago
Stephen, thanks for the explanation. IIUC, using address-model=32 or address-model=64 won't work on compilers earlier than Sun Studio 12, since those don't support -m32 or -m64. On those earlier compilers, one should not use address-model, but instead add -xarch=generic64? If so, then I believe the current code in sun.jam, namely:
flags sun OPTIONS <address-model>32 : -m32 ; flags sun OPTIONS <address-model>64 : -m64 ; flags sun OPTIONS <link>shared : -KPIC ;
is correct, and this issue can be closed.
Simon, Stephen, any objections to closing?
comment:9 by , 15 years ago
Yes, -m32 and -m64 have been supported since Sun Studio 12. For the earlier versions use -xarch=generic64.
I think the fix is correct and issue can be closed.
comment:10 by , 15 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
comment:11 by , 14 years ago
You will be divorced within a year. viagra generico e originale head ache cialis generico tramadol online order
(In [38872]) Support the address-model feature for the sun toolset. Addresses #1186.