`bjam --toolset=` and tag values for Apple compilers?
Asked Answered
S

1

5

When building Boost binary libraries with bjam, one may specify which compiler to use, without specifying a particular compiler version, by using certain values for the --toolset= option. For example:

bjam --with-serialization --toolset=msvc

the toolset value msvc tells bjam to search your system for some version of Microsoft Visual C++ and then use it to build a number of variants of the Boost.Serialization library. The resulting libraries will contain a tag indicating which toolset was actually used. For example, the above command creates files such as:

libboost_serialization-vc100-mt-s-1_44.lib
libboost_serialization-vc100-mt-sgd-1_44.lib
...

where the string vc100 in the filename is a toolset tag indicating that the Microsoft Visual C++ 2010 compiler version was found and used to build the libraries. [More details about Boost library file naming conventions can be found here.]

One may specify also a specific version of a compiler using certain other values for the --toolset= option. For example:

bjam --with-serialization --toolset=msvc-9.0

tells bjam that, even though I may have several compilers on my system, I want it to specifically use Microsoft Visual C++ 2008. The resulting libraries contain the tag string vc90 to indicate that Microsoft Visual C++ 2008 was used to build them.

The Boost documentation seems to be a bit out-of-date with respect to newer compilers on the Mac (e.g., how does one distinguish between GCC, LLVM-GCC and LLVM?)

My question is, what are some of the other bjam --toolset= values and their corresponding tags for specific compiler versions in Xcode 3 and Xcode 4 on the Mac (not the general compiler name values like darwin)? Are these documented anywhere? Even if building Boost libraries with some versions is not yet supported by Boost, have the toolset and tag values been specified yet?

Please help replace the ???s in this table:

TOOL AND VERSION               --toolset=     TAG
======================================================
Microsoft Visual C++ 2008      msvc-9.0       vc90
Microsoft Visual C++ 2010      msvc-10.0      vc100
Apple (1) GCC 4.0 (2)            ???          xgcc40
Apple GCC 4.2                    ???          xgcc42
Apple LLVM GCC 4.2               ???           ???
Apple LLVM compiler 1.5 (2)      ???           ???
Apple LLVM compiler 2.0 (3)      ???           ???

(1) Apple produces their own versions of the GCC and LLVM compilers to add Apple-specific extensions and behavior.

(2) Available in Xcode 3 only.

(3) Available in Xcode 4 only.

Stubborn answered 7/9, 2010 at 20:1 Comment(0)
S
7

There is a direct mapping from the toolset specified to the base part of the tag. Hence for any Apple Xcode compiler that you specify that uses the darwin.jam toolset the start of the tag will always be xgcc (for Xcode GCC). The second part, i.e the version number of the compiler, is usually automatically discovered from the compiler itself. The darwin.jam toolset code uses the -dumnpversion option to discover what that version is (see darwin.jam line #123). So a few things:

  1. For Xcode it will always be toolset=darwin for the default g++.
  2. For other non-default versions you have to set up a site-config.jam or user-config.jam to tell Boost Build where and which are the compilers you have (see the BB Configuration docs).
  3. The toolset=darwin-<some_version> matches what you specify in your configuration.
  4. The darwin.jam toolset supports smart selection of the compiler based on what you are trying to build to make it a bit easier.

For example I use something like the following for iOS development:

using darwin : : /Xcode-path/usr/bin/g++-4.0 ;
using darwin : : /Xcode-path/usr/bin/g++-4.2 ;
using darwin : 4.2~iphone
:   /Xcode-path/Platforms/iPhoneOS.platform/Developer/usr/bin/g++-4.2 -arch armv6
:   <striper>
:   <architecture>arm <target-os>iphone
;
using darwin : 4.2~iphonesim
:   /Xcode-path/Platforms/iPhoneSimulator.platform/Developer/usr/bin/g++-4.2
:   <striper>
:   <architecture>x86 <target-os>iphone
;

For which I can:

  1. bjam toolset=darwin-4.0 -- For a regular OSX build with GCC 4.0. Which results in the tag xgcc-42.
  2. bjam toolset=darwin-4.2 -- Similarly for OSX and GCC 4.2. For which I would get a tag of xgcc-42.
  3. bjam toolset-darwin architecture=arm target-os=iphone -- To do an iPhone device build with GCC 4.2. The tag ends up also being xgcc42 which is a collision. But there's a limit to how much we can account for in those tags. And it's usually not a problem because one segregates built results across platforms anyway.

You might set up using one of the LLVM compilers by adding to your configuration:

using darwin : 4.2~llvm~gcc : /Xcode-path/user/bin/llvm-g++ ;

And invoke with bjam toolset=darwin-4.2~llvm~gcc. Unfortunately the tag would also be xgcc-4.2 (as again, it's based on using darwin.jam). So you would need to segregate the resulting libs from the other GCC builds.

Also unfortunate is that there isn't a documented location of mapping the toolset used to the tag value other than in code (see the BB common.jam lines #801 to #841).

Steck answered 7/9, 2010 at 20:43 Comment(3)
Thanks for the info! Note that no modifications are necessary to any .jam files to use --toolset=darwin-4.0 or --toolset=darwin-4.2. I've updated the table in the question to include these and their associated tags.Stubborn
Oops, I spoke too soon. Although one can use, say, --toolset=darwin-4.2 to generate a library with the tag xgcc42 this does not guarantee that Apple's GCC 4.2 was actually used. Table in original question updated to reflect this.Stubborn
Right.. Boost Build tries to be forgiving and will build with what it can find given the information. So for anything other than the default g++ you have to set up a configuration file. You could fill in the second column for Xcode as darwin-/user-configured/. And for the third column At minimum LLVM GCC will produce an xgcc42 tag.Steck

© 2022 - 2024 — McMap. All rights reserved.