Boost logo

Boost-Build :

Subject: Re: [Boost-build] Cannot get feature/subfeature not working with Oracle Solaris Studio C++ compiler
From: Edward Diener (eldiener_at_[hidden])
Date: 2015-03-26 14:25:46

On 03/26/2015 12:21 PM, Steven Watanabe wrote:
> On 03/26/2015 06:15 AM, Edward Diener wrote:
>> I am trying to use the feature/subfeature part boost build in order to
>> run different setups of the Oracle Solaris Studio C++ compiler on Linux.
>> This is still called the 'sun' compiler in the Boost Build
>> doocumentation. Under linux I have versions 12.2, 12.3, and 12.4 on the
>> compiler installed. I have a bash file for switching between the
>> versions before using build to invoke the sun compiler.
> What does this bash script need to do? Ideally you
> should be able to handle this in user-config.jam.

The bash script is run first from a bash shell to put a version of
Oracle Solaris Studio C++ in the PATH.

The actual 'using sun' lines are:

using sun : 12.2 : /opt/oracle/solstudio12.2/bin/CC :
<cxxflags>-features=tmplife <cxxflags>-features=tmplrefstatic ;
using sun : 12.3 : /opt/oracle/solarisstudio12.3/bin/CC :
<cxxflags>-features=tmplife <cxxflags>-features=tmplrefstatic ;
using sun : 12.4 : /opt/oracle/solarisstudio12.4/bin/CC :
<cxxflags>-features=tmplife <cxxflags>-features=tmplrefstatic ;

Sorry I gave this wrong in my OP.

When b2 picks out the correct path to execute, the C++ compiler needs
its 'bin' directory in the PATH according to the setup for Solaris
Studio. That's the purpose of my bash script.

>> My lines in user_config.jam for sun are:
>> import feature ;
>> import toolset ;
>> using sun : 12.2 : : <cxxflags>-features=tmplife
>> <cxxflags>-features=tmplrefstatic ;
>> using sun : 12.3 : : <cxxflags>-features=tmplife
>> <cxxflags>-features=tmplrefstatic ;
>> using sun : 12.4 : : <cxxflags>-features=tmplife
>> <cxxflags>-features=tmplrefstatic ;
>> feature.subfeature toolset sun-12.4 : library : stlport apache cxx03
>> cxx11 : optional composite propagated ;
> Don't specify the version when defining the
> subfeature. <toolset-sun:version> is also
> a subfeature. I don't think that subfeatures
> can be nested like this.

OK. I changed my features/subfeatures to:

feature.subfeature toolset sun : library : stlport apache cxx03 cxx11 :
optional composite propagated ;

feature.compose <toolset-sun:library>stlport : <cxxflags>-library=stlport4 ;
feature.compose <toolset-sun:library>apache : <cxxflags>-library=stdcxx4 ;
feature.compose <toolset-sun:library>cxx03 : <cxxflags>-std=c++03 ;
feature.compose <toolset-sun:library>cxx11 : <cxxflags>-std=c++11 ;

and invoked b2 as:

b2 toolset=sun-12.4-cxx11

and b2 correctly invoked the correct version and used the
features/subfeature correctly to add -std=c++11 to the command line. So
your suggestion worked completely. But unfortunately the boost build jam
file automatically adds -library=stlport4 to the command line. When this
happens the compiler issues the message:

"CC: -library=stlport4 cannot be used with -std=c++11"

and the compilation fails.

I will look at the sun.jam file to see if I can change it locally for
12.4. Would you look into making such a change permanently as I am
hardly an expert of Boost Build as you are ? Without the change in the
Boost Build jam file it is not possible to use -std=c++11 with the the

>> feature.compose <toolset-sun-12.4:library>stlport :
>> <cxxflags>-library=stlport4 ;
>> feature.compose <toolset-sun-12.4:library>apache :
>> <cxxflags>-library=stdcxx4 ;
>> feature.compose <toolset-sun-12.4:library>cxx03 : <cxxflags>-std=c++03 ;
>> feature.compose <toolset-sun-12.4:library>cxx11 : <cxxflags>-std=c++11 ;
>> If I then invoke b2 with
>> b2 toolset=sun-cxx11
> toolset=sun will always select toolset=sun-12.2,
> since that's the first one that you declared.
> This doesn't match up with the fact that you
> declared the library subfeature for 12.4.
> To be honest, I have no idea how this works
> at all. I would have expected it to fail
> when trying to parse the subfeature. I'm sure
> that Boost.Build is getting very confused. I'll
> see if I can improve the error checking.
>> I would then assume that -std=c++11 is part of the compiler command
>> line. But it is not. Instead -library=stlport is part of the compiler
>> command line no matter how I invoke the compiler.
> What version of Boost are you using?

The latest from Git. For boost build I tried 'master' first but then
switched to 'develop'.

> Until recently
> Jamroot set <toolset>sun:<stdlib>sun-stlport, which
> forces -library=stlport4. I would guess that Boost.Build
> is picking up this and ignoring your subfeature.
>> How do I correct this so that I can pass -std=c++11 and not pass
>> -library=stlport to the command line of the compiler ?
> See also

Boost-Build list run by bdawes at, david.abrahams at, gregod at, cpdaniel at, john at