xcode `bjam --toolset=` 和 Apple 编译器的标签值?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3662245/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 19:43:06  来源:igfitidea点击:

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

xcodeboostbjam

提问by jwfearn

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

使用 构建 Boost 二进制库时bjam,可以通过使用选项的某些值来指定要使用的编译器,而无需指定特定的编译器版本--toolset=。例如:

bjam --with-serialization --toolset=msvc

bjam --with-serialization --toolset=msvc

the toolset valuemsvctells bjamto search your system for someversion 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:

工具集值msvc告诉bjam搜索系统的一些版本的Microsoft Visual C ++,然后用它来建立一个数Boost.Serialization库的变种。生成的库将包含一个标记,指示实际使用了哪个工具集。例如,上面的命令会创建如下文件:

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

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

其中vc100文件名中的字符串是一个工具集标记,表明已找到Microsoft Visual C++ 2010编译器版本并用于构建库。[可以在此处找到有关 Boost 库文件命名约定的更多详细信息]

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

还可以使用选项的某些其他值指定编译器的特定版本--toolset=。例如:

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

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

tells bjamthat, 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 vc90to indicate that Microsoft Visual C++ 2008was used to build them.

告诉bjam我,即使我的系统上可能有多个编译器,我还是希望它专门使用Microsoft Visual C++ 2008。生成的库包含标记字符串vc90以指示使用Microsoft Visual C++ 2008来构建它们。

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?)

对于 Mac 上较新的编译器,Boost 文档似乎有点过时(例如,如何区分 GCC、LLVM-GCC 和 LLVM?)

My question is, what are some of the other bjam --toolset=values and their corresponding tags for specific compiler versionsin Xcode 3 and Xcode 4 on the Mac (notthe 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 toolsetand tag values been specified yet?

我的问题是,Mac 上 Xcode 3 和 Xcode 4 中特定编译器版本的其他一些bjam --toolset=值及其对应的标签是什么(不是一般的编译器名称值,如)?这些记录在任何地方吗?即使 Boost 尚不支持使用某些版本构建 Boost 库,是否已指定 和 标记值?darwintoolset

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

请帮助替换???此表中的s:

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.

(1) Apple 生产自己的 GCC 和 LLVM 编译器版本,以添加 Apple 特定的扩展和行为。

(2) Available in Xcode 3 only.

(2) 仅适用于 Xcode 3。

(3) Available in Xcode 4 only.

(3) 仅适用于 Xcode 4。

回答by GrafikRobot

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.jamtoolset 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.jamtoolset code uses the -dumnpversionoption to discover what that version is (see darwin.jamline #123). So a few things:

从指定的工具集到标记的基本部分有直接映射。因此,对于您指定使用darwin.jam工具集的任何 Apple Xcode 编译器,标记的开头将始终是xgcc(对于 Xcode GCC)。第二部分,即编译器的版本号,通常是从编译器本身自动发现的。该darwin.jam工具集代码使用的-dumnpversion选项,来发现什么版本(见darwin.jam线#123)。所以有几点:

  1. For Xcode it will always be toolset=darwinfor the default g++.
  2. For other non-default versions you have to set up a site-config.jamor user-config.jamto tell Boost Build where and which are the compilers you have (see the BB Configurationdocs).
  3. The toolset=darwin-<some_version>matches what you specify in your configuration.
  4. The darwin.jamtoolset supports smart selection of the compiler based on what you are trying to build to make it a bit easier.
  1. 对于 Xcode,它将始终toolset=darwin用于默认g++.
  2. 对于其他非默认版本,您必须设置一个site-config.jamuser-config.jam告诉 Boost Build 您拥有的编译器在哪里以及哪些是(请参阅BB 配置文档)。
  3. toolset=darwin-<some_version>你在配置指定的内容相匹配。
  4. darwin.jam工具集支持根据您尝试构建的内容智能选择编译器,以使其更容易一些。

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

例如,我在 iOS 开发中使用类似以下内容:

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 xgcc42which 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.
  1. bjam toolset=darwin-4.0-- 对于使用 GCC 4.0 的常规 OSX 构建。这导致标记xgcc-42.
  2. bjam toolset=darwin-4.2-- 对于 OSX 和 GCC 4.2 类似。为此,我将获得xgcc-42.
  3. bjam toolset-darwin architecture=arm target-os=iphone-- 使用 GCC 4.2 构建 iPhone 设备。标签最终也是xgcc42碰撞。但是我们可以在这些标签中解释多少是有限的。而且这通常不是问题,因为无论如何都可以跨平台隔离构建的结果。

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

您可以通过添加到您的配置来使用 LLVM 编译器之一进行设置:

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.

并用 调用bjam toolset=darwin-4.2~llvm~gcc。不幸的是,标签也会是xgcc-4.2(同样,它基于 using darwin.jam)。因此,您需要将生成的库与其他 GCC 构建分开。

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.jamlines #801 to #841).

同样不幸的是,除了代码之外,没有记录用于将工具集映射到标记值的位置(参见 BB common.jam行 #801 到 #841)。