C++11 variant of the gcc toolset?
Currently, when I want to test under g++ in C++11 mode, I use b2 toolset=gcc cxxflags=-std=c++11 This works, but (a) prevents me from combining this with other toolsets, (b) prevents me from testing both 03 and 11 at once, and (c) boost.build doesn't treat the two modes of the gcc toolset as distinct and uses the same directory for both. Am I missing something simple, or if not, shouldn't we have a separate gcc11 toolset that is exactly the same as the gcc toolset, but with -std=c++11 applied?
On Dec 13, 2013, at 12:51 PM, Peter Dimov
Currently, when I want to test under g++ in C++11 mode, I use
b2 toolset=gcc cxxflags=-std=c++11
This works, but (a) prevents me from combining this with other toolsets, (b) prevents me from testing both 03 and 11 at once, and (c) boost.build doesn't treat the two modes of the gcc toolset as distinct and uses the same directory for both.
Am I missing something simple, or if not, shouldn't we have a separate gcc11 toolset that is exactly the same as the gcc toolset, but with -std=c++11 applied?
I have this in in user-config.jam: using darwin : 11 : "/Sources/gcc/gcc-4.8.2/bin/bin/g++" : <cxxflags>"-std=c++11" ; And I just use: b2 toolset=darwin-11 — Marshall
Marshall Clow wrote:
I have this in in user-config.jam:
using darwin : 11 : "/Sources/gcc/gcc-4.8.2/bin/bin/g++" : <cxxflags>"-std=c++11" ;
And I just use: b2 toolset=darwin-11
This works, but it's not as convenient as having a separate gcc11 toolset. Currently, toolset=gcc finds whatever g++ there is in the PATH, and automatically detects its version, so for instance, if I have g++ 4.5.3, it puts the compiler output into a gcc-4.5.3 directory, and if I then run b2 with g++ 4.8.1 in the PATH, it can see that the previous test run is not the same, so it re-runs the tests, putting the result into a gcc-4.8.1 directory. Which is exactly what I want. Ideally, the C++11 mode tests would go into gcc11-(detected version), for the same reason. A similar problem occurs when I need to run several test runs using different #defines, but that's probably harder to solve. Ideally, if I define=THIS and define=THAT, the output should probably go into a define-a6d9ba0c subdirectory (similar to how threading=multi goes into threading-multi/.)
AMDG On 12/14/2013 08:23 AM, Peter Dimov wrote:
Marshall Clow wrote:
I have this in in user-config.jam:
using darwin : 11 : "/Sources/gcc/gcc-4.8.2/bin/bin/g++" : <cxxflags>"-std=c++11" ;
And I just use: b2 toolset=darwin-11
This works, but it's not as convenient as having a separate gcc11 toolset. Currently, toolset=gcc finds whatever g++ there is in the PATH, and automatically detects its version, so for instance, if I have g++ 4.5.3, it puts the compiler output into a gcc-4.5.3 directory, and if I then run b2 with g++ 4.8.1 in the PATH, it can see that the previous test run is not the same, so it re-runs the tests, putting the result into a gcc-4.8.1 directory. Which is exactly what I want. Ideally, the C++11 mode tests would go into gcc11-(detected version), for the same reason.
import feature ; feature.feature cxx11 : on : optional composite propagated ; feature.compose <cxx11>on : <toolset>gcc:<cxxflags>-std=c++11 ; b2 gcc cxx11=on In Christ, Steven Watanabe
Steven Watanabe wrote:
import feature ; feature.feature cxx11 : on : optional composite propagated ; feature.compose <cxx11>on : <toolset>gcc:<cxxflags>-std=c++11 ;
Thanks Steven. Putting this in my user-config.jam works in that it creates the feature and allows me to use it, but it doesn't actually seem to pass -std=c++11 to the compiler. I also tried <toolset>gcc-*, and that also didn't work. C:\Projects\boost-git\boost\libs\smart_ptr\test>b2 -a -n toolset=gcc cxx11=on shared_from_this_test [...] gcc.compile.c++ ..\..\..\bin.v2\libs\smart_ptr\test\shared_from_this_test.test\gcc-mingw-4.8.1\debug\cxx11-on\shared_from_this_test.o "g++" -ftemplate-depth-128 -O0 -fno-inline -Wall -g -Wno-non-virtual-dtor -DBOOST_ALL_NO_LIB=1 -I"..\..\.." -c -o "..\..\..\bin.v2\libs\smart_ptr\test\shared_from_this_test.test\gcc-mingw-4.8.1\debug\cxx11-on\shared_from_this_test.o" "shared_from_this_test.cpp" It's not the fact that I'm using gcc-mingw-4.8.1; the cygwin g++ also doesn't work: gcc.compile.c++ ..\..\..\bin.v2\libs\smart_ptr\test\shared_from_this_test.test\gcc-4.5.3\debug\cxx11-on\shared_from_this_test.o "g++" -ftemplate-depth-128 -O0 -fno-inline -Wall -g -Wno-non-virtual-dtor -DBOOST_ALL_NO_LIB=1 -I"..\..\.." -c -o "..\..\..\bin.v2\libs\smart_ptr\test\shared_from_this_test.test\gcc-4.5.3\debug\cxx11-on\shared_from_this_test.o" "shared_from_this_test.cpp"
Peter Dimov wrote:
Steven Watanabe wrote:
import feature ; feature.feature cxx11 : on : optional composite propagated ; feature.compose <cxx11>on : <toolset>gcc:<cxxflags>-std=c++11 ;
Thanks Steven. Putting this in my user-config.jam works in that it creates the feature and allows me to use it, but it doesn't actually seem to pass -std=c++11 to the compiler.
In this thread: http://boost.2283326.n4.nabble.com/Building-OpenMP-targets-td4650306.html it's claimed that feature.compose doesn't parse its second argument properly, which is why the above doesn't work, although it's supposed to. This, however, works: import feature ; import toolset ; using gcc ; feature.subfeature toolset gcc : std : cxx11 : optional composite propagated ; feature.compose toolset-gcc:stdcxx11 : <cxxflags>-std=c++11 ; and is actually better for my needs, because it supports building for both C++03 and C++11 at once: b2 toolset=gcc,gcc-cxx11
On Thu, Dec 19, 2013 at 2:46 PM, Peter Dimov
Peter Dimov wrote:
Steven Watanabe wrote:
import feature ; feature.feature cxx11 : on : optional composite propagated ; feature.compose <cxx11>on : <toolset>gcc:<cxxflags>-std=c++11 ;
Thanks Steven. Putting this in my user-config.jam works in that it creates the feature and allows me to use it, but it doesn't actually seem to pass -std=c++11 to the compiler.
In this thread:
http://boost.2283326.n4.nabble.com/Building-OpenMP-targets-td4650306.html
it's claimed that feature.compose doesn't parse its second argument properly, which is why the above doesn't work, although it's supposed to.
This, however, works:
import feature ; import toolset ;
using gcc ;
feature.subfeature toolset gcc : std : cxx11 : optional composite propagated ; feature.compose toolset-gcc:stdcxx11 : <cxxflags>-std=c++11 ;
and is actually better for my needs, because it supports building for both C++03 and C++11 at once:
b2 toolset=gcc,gcc-cxx11
Just wanted to ask if this could be added to the official Boost.Build code. Ideally, the produced binaries should also be mangled with the C++ version. I suppose, the new toolset name does that already?
Andrey Semashev wrote:
Ideally, the produced binaries should also be mangled with the C++ version. I suppose, the new toolset name does that already?
I don't know about the binaries, as I only use it to run the tests, but the output files do go into the proper directory, gcc-mingw-cxx11-4.8.1 in my case.
participants (4)
-
Andrey Semashev
-
Marshall Clow
-
Peter Dimov
-
Steven Watanabe