Wednesday Jan 30, 2008

Boost and Sun Studio 12

The latest released version of Boost 1.34.1 can be compiled under 32-bit mode by Sun Studio 12 from scratch without necessity to apply any additional patches.

If you want to use Boost 1.34.1 under 64-bit mode you still have to apply a small fix to Boost build script.

Upcoming Boost 1.35 can be compiled by Sun Studio 12 under both 32/64-bit mode without any patches.

bjam toolset=sun stdlib=sun-stlport stage # 32-bit mode
bjam toolset=sun stdlib=sun-stlport address-model=64 stage # 64-bit mode

As for advantages over Studio 11 and/or gcc:

  • Sun Studio 12 has a better back-end than Sun Studio 11 and g++ so customers gain performance improvement.
  • Sun Studio 12 better conforms to C++ standard than Sun Studio 11.

Tuesday Aug 14, 2007

How to build Boost 1.34 by Sun C++

Here is the summary of comments to my previous post and results of my experiments.

First of all to build Boost you need bjam. If you work on Linux take pre-compiled binaries of bjam here. If you target OS is Solaris look at my instruction how to build bjam.

If you need to build Boost for 32-bit architecture just untar Boost archive, go to boost_1_34_1 directories and type bjam toolset=sun stdlib=sun-stlport stage. That is all you need.

If you want to build Boost for 64-bit architecture the life became is a bit more complicated. You have to fix tools/build/v2/tools/sun.jam. Add following lines to this file just before comment line # Declare generators.

flags sun OPTIONS <architecture>/<address-model>32 : -m32 ;
flags sun OPTIONS <architecture>/<address-model>64 : -m64 ;
flags sun OPTIONS <link>shared : -Kpic ;

After that you can type bjam toolset=sun stdlib=sun-stlport address-model=64 stage to build Boost. Unfortunately Python Boost library shows an error during compilation. The error comes from python2.5/pyport.h so maybe the reason of this error my own broken Python configuration.

I do not have a time to fix configuration error in the Boost library so if somebody file a bug or/and a patch to Boost bug track it would be really nice.

And the last point. I recommend to read Boost Getting Started article. It has been rewritten since Boost 1.33.

Friday Apr 06, 2007

How to compile Boost 1.34 with stlport

Upcoming Boost 1.34 still has not been released. But it is in a very good shape and compatible with Sun C++ without any annoying patches. If you do not want to get it by CVS you can take its CVS snapshot here. Unfortunately there is one, at least one :-) problem with this version. By default it uses libCstd.2.1.1. This leads to enormous number of errors. Are there any workaround? Sure!

  1. Download and unpack tarball. Let's suppose the created directory name is 'boost'.
  2. cd boost
  3. Create in this directory file 'user-config.jam' with following content (spaces are important):
    import toolset : using ;
    using sun :  : <path to your Sun C++ compier>/bin/CC : <cxxflags>-library=stlport4 <linkflags>-library=stlport4 ;
  4. Build 'bjam' utility as described here. And put it on your $PATH.
  5. Run bjam --v2 -sBOOST_BUILD_PATH=`pwd` --toolset=sun stage
That's all.

Sunday Nov 05, 2006

One more language extension

Upcoming SunStudio Express 3 will include one more c++ language extension. Recently I have implemented explicit template definition aka forward declaration of explicit instantiations. Now this extension is available under -Qoption ccfe -features=gcc command line option.

In the code below compiler will not instantiate (explicitly and implicitly) any members of class S<int>. So it will not waste a time on code generation and optimization. The only source code file should contain explicit template instantiation to successfully link the program.

% cat test.h
template <typename T>
struct S
  void foo();

template <typename T>
void S<T>::foo()
  // a lot of code here

extern template struct S<int>;

% cat
#include "test.h"

template struct S<int>;

% cat
#include "test.h"

int main()
  S<int> s;;

Tuesday Oct 31, 2006

typeof and alignof

Now Sun Studio C++ accepts g++ extension - operator __typeof__ (as well as __typeof and typeof). Keyword typeof is available under -features=gcc command line option. So you can write:

int \* x;
__typeof__(\*x) n;

Operator __alignof__ now accepts expression:

unsigned v = 0;
unsigned a = __alignof__(v);

Thursday Oct 05, 2006

To google public source code

New Google project - Search public source code. And if you use Firefox you can install search plugin.

Why BOOST_HAS_THREADS is not defined

I've got a question on Sun C++ forum why BOOST_HAS_THREADS is not defined explicitly in the sunpro_cc.hpp. The answer can be found just by grep on Boost source code but I decide to put explanation here.

Let's look at the piece of boost/config/suffix.hpp:

#if (defined(__MT__) || defined(_MT) || defined(_REENTRANT) \\
    || defined(_PTHREADS)) && !defined(BOOST_HAS_THREADS)

When you compile multithread application you should use -mt command line option. This option implicitly defines _REENTRANT so Boost defines BOOST_HAS_THREADS automatically. You can check it by hand:

% cat
#include <boost/thread.hpp>

#error BOOST_HAS_THREADS is defined

% CC -mt -I$HOME/storage/boost_1_32_0 -c
"", line 4: Error: #error BOOST_HAS_THREADS is defined.

Friday Sep 29, 2006

Patch for boost::filesystem under Solaris

Lars Fürstenberg share his patch for operations_posix_windows.cpp. This patch fixes the problem with usage of dirent structure in the boost::filesystem library under Solaris.

Thanks again Lars!

Tuesday Sep 26, 2006

Boost and 64-bit mode again

Here is the quote from comments I received from Lars Fuerstenberg:

I used your patch to build Boost 1.32 in 64-bit mode with the latest
Sun compiler patches. With the comandline:
bjam "-sBUILD=<threading>multi <runtime-link>dynamic <instruction-set>v9" \\
     "-sTOOLS=sunpro" -sSUNPRO_CXX="CC -xtarget=native64 -xarch=v9 -xcode=abs64 -I\\"../../../\\" "
I was able to compile filesystem, program_options and iostreams
(these are all Boost libraries that we need for our product).
Our applications run without problems using these libraries.

Thanks Lars!

Tuesday Sep 12, 2006

Boost and 64-bit mode

Although my patch for Boost 1.32 contains settings to build Boost at 64-bit mode I have not tested it. Upcoming Boost 1.34 uses new build scheme so I do not plan to spent significant time to allow 64-bit at Boost 1.32.

Saturday Aug 12, 2006

New patches for Sun Studio 11

We've just released 121017-03 (sparc) and 121018-03 (intel) patches for Sun Studio 11 C++. You can find them here. Sorry for a long delay.

Tuesday Jul 25, 2006

-KPIC on amd

Markus Bernhardt pointed to the error in the sunpro-tools.jam. The -KPIC was absent for the amd64 platform. Bug and patch have been fixed. Thanks Markus.

Thursday Jul 20, 2006

Loki library

If you take a look at the Links block you will see Loki-0.1.5 Patch. Yes, I have fixed some bugs in the compiler and created a patch for Loki source code. Unfortunately at this moment these fixes are in the development branch only. But you can try to play with Studio Express. Studio Express is a preview of the next release, updated every few months. We plan to release new build in the near future.

And the second piece of news. Third patch for Sun Stusio 11 C++ is almost ready. I hope in a week or so it will be released.

Monday Jun 26, 2006


I've moved from C++ sustaining to C++ development team. So I will be able to dedicate all my time to C++ compiler. Boost has still been on my focus but now I can work on some other important tasks related to Sun C++ compiler.

My colleagues from sustaining team made a present for me. It's the best professional award I have got ever before (link is on my russian blog but photos do not need translation).

Monday Jun 19, 2006

External interface for bug submitting

Take a look at Vijay post. Now even if you do not have a service contract you are able to file a bug realted to Sun C++.




« April 2014