xcode 如何在 Mac OSX 上更新 LLVM 和 Clang?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8674546/
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
How to update LLVM & Clang on Mac OSX?
提问by Pietro
On my version of Mac OSX (Lion 10.7.1, XCode 4.1), there is LLVM 3.0svn and Clang 2.1. The current versionsare LLVM 3.0 and Clang 3.0.
在我的 Mac OSX 版本(Lion 10.7.1,XCode 4.1)上,有 LLVM 3.0svn 和 Clang 2.1。在目前的版本是3.0 LLVM锵和3.0。
From the XCode web site, it seems that the latest version (4.2.1) still uses LLVM 2.0, and this seems to be a mistake.
从XCode 网站上看,最新版本(4.2.1)似乎还在使用 LLVM 2.0,这似乎是一个错误。
Do you know if installing the latest XCode I will get a more recent version of LLVM/Clang?
你知道如果安装最新的 XCode 我会得到一个更新版本的 LLVM/Clang 吗?
Do you know of any possible issues installing Clang manually?
您知道手动安装 Clang有任何可能的问题吗?
Once installed, will the new Clang be used automatically by all the IDEs I have (e.g. NetBeans)?
安装后,新的 Clang 是否会被我拥有的所有 IDE(例如 NetBeans)自动使用?
采纳答案by Ned Deily
Software vendors are traditionally conservative about updating build tools and with good reason. If you want to use the latest publicly-supported versions of build tools supplied and modified by Apple, you should stick to those in the latest version of Xcode for the OS X release you are running. There are usually good reasons why Apple has not yet updated to the latest cutting-edge versions of open source components, like serious bugs. If you don't need the Apple-supplied modifications and don't mind living on the edge - i.e. no support from Apple and possibly (re-)discovering known problems - and are not planning to ship compiled files to other people's systems, you couldinstall your own versions in, say, /usr/local/bin
or by using third-party package managers, like MacPorts http://www.macports.org/ports.php?by=name&substr=clang). You should definitely nottry to replace the files at the paths installed by Xcode. Is it worth it? Only you can decide that.
软件供应商传统上对更新构建工具持保守态度,并且有充分的理由。如果您想使用 Apple 提供和修改的最新公开支持版本的构建工具,您应该坚持使用适用于您正在运行的 OS X 版本的最新版本的 Xcode。Apple 尚未更新到开源组件的最新尖端版本通常有充分的理由,例如严重的错误。如果您不需要 Apple 提供的修改并且不介意生活在边缘 - 即没有来自 Apple 的支持并且可能(重新)发现已知问题 - 并且不打算将编译的文件发送到其他人的系统,您可以在/usr/local/bin
例如 MacPorts 等第三方包管理器中或使用第三方包管理器安装您自己的版本http://www.macports.org/ports.php?by=name&substr=clang)。您绝对不应该尝试替换 Xcode 安装的路径中的文件。这值得么?只有你能决定。
回答by Chris Lattner
The web site is incorrect. Xcode 4.2.1 and 4.2 include LLVM 3.0 and clang 3.0:
网站不正确。Xcode 4.2.1 和 4.2 包括 LLVM 3.0 和 clang 3.0:
clang --version
Apple clang version 3.0 (tags/Apple/clang-211.12) (based on LLVM 3.0svn)clang++ --version
Apple clang version 3.0 (tags/Apple/clang-211.12) (based on LLVM 3.0svn)llvm-g++ --version
i686-apple-darwin11-llvm-g++-4.2 (GCC) 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.1.00)llvm-gcc --version
i686-apple-darwin11-llvm-gcc-4.2 (GCC) 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.1.00)
clang --version
Apple clang version 3.0 (tags/Apple/clang-211.12)(基于LLVM 3.0svn)clang++ --version
Apple clang version 3.0 (tags/Apple/clang-211.12)(基于LLVM 3.0svn)llvm-g++ --version
i686-apple-darwin11-llvm-g++-4.2 (GCC) 4.2.1(基于 Apple Inc. build 5658)(LLVM build 2336.1.00)llvm-gcc --version
i686-apple-darwin11-llvm-gcc-4.2 (GCC) 4.2.1(基于 Apple Inc. build 5658)(LLVM build 2336.1.00)
回答by jupp0r
回答by uliwitness
I highly recommend against replacingthe system compiler on macOS:
我强烈建议不要在 macOS 上替换系统编译器:
Many build processes you will see (e.g. Xcode) rely on Apple-specific extensions. For example, last I checked Apple have their own linker.
您将看到的许多构建过程(例如 Xcode)都依赖于 Apple 特定的扩展。例如,上次我检查了 Apple 是否有自己的链接器。
Also, Linuxes do not enforce binary compatibility -- generally, people build software from source, or download specific binaries for each operating system version. As an end-user (as opposed to developer/professional user) operating system, macOS goes to great effort to maintain compatibility with binaries built on older macOS versions.
此外,Linux 不强制执行二进制兼容性——通常,人们从源代码构建软件,或为每个操作系统版本下载特定的二进制文件。作为最终用户(而不是开发人员/专业用户)操作系统,macOS 竭尽全力保持与构建在旧 macOS 版本上的二进制文件的兼容性。
Replacing the compiler, or worse, system libraries, will break these compatibility guarantees. It may also break your system in subtle, non-obvious ways.
替换编译器,或者更糟的是,替换系统库,将破坏这些兼容性保证。它也可能以微妙的、非显而易见的方式破坏你的系统。
But feel free to install a second copyof clang in /usr/local
or so and explore new features, but leave the system compiler alone.
但是可以随意安装一个clang的第二个副本/usr/local
并探索新功能,但不要管系统编译器。
Also note that Apple do not support submitting software to the app stores that aren't built with Xcode and the compiler it includes. While you may go unnoticed if you do that, you may get rejected during app store review if your compiler fails to do anything that Apple's compiler does.
另请注意,Apple 不支持向应用商店提交不是使用 Xcode 及其包含的编译器构建的软件。如果您这样做,您可能会被忽视,但如果您的编译器没有执行 Apple 编译器所做的任何事情,您可能会在应用商店期间被拒绝。
回答by Abhisek Mukherjee
On Mountain Lion 10.8.2 with XCode 4.6, the versions are:
在带有 XCode 4.6 的 Mountain Lion 10.8.2 上,版本是:
$ clang --version
Apple LLVM version 4.2 (clang-425.0.24) (based on LLVM 3.2svn)
Target: x86_64-apple-darwin12.2.0
Thread model: posix
$ clang++ --version
Apple LLVM version 4.2 (clang-425.0.24) (based on LLVM 3.2svn)
Target: x86_64-apple-darwin12.2.0
Thread model: posix
$ llvm-g++ --version
i686-apple-darwin11-llvm-g++-4.2 (GCC) 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00)
Copyright (C) 2007 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$ llvm-gcc --version
i686-apple-darwin11-llvm-gcc-4.2 (GCC) 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00)
Copyright (C) 2007 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
You can update XCode for Lion too from App Store or Apple Developer Account direct download, and install the command line tools, which will update clang & llvm to above versions.
您也可以从 App Store 或 Apple Developer Account 直接下载更新 XCode for Lion,并安装命令行工具,这会将 clang 和 llvm 更新到以上版本。
回答by tngn
OS X Update version 10.9.2 brings XCode to version 5.1 (5B130a), and clang to the latest stable (for OS X):
OS X Update 10.9.2 版将 XCode 带到了 5.1 版 (5B130a),并将 Clang 带到了最新的稳定版(对于 OS X):
$ clang --version
Apple LLVM version 5.1 (clang-503.0.38) (based on LLVM 3.4svn)
Target: x86_64-apple-darwin13.1.0
Thread model: posix
On my Mac llvm-gcc and llvm-g++ are symlinks to this clang:
在我的 Mac 上,llvm-gcc 和 llvm-g++ 是这个 clang 的符号链接:
lrwxr-xr-x 1 root wheel 5B 25 Oct 16:48 /usr/bin/llvm-gcc -> clang
lrwxr-xr-x 1 root wheel 7B 25 Oct 16:48 /usr/bin/llvm-g++ -> clang++
My latest R installation is configured to use llvm-gcc-4.2 which would cause error when building SHLIB. Creating symlinksfor llvm-gcc-4.2 and llvm-g++-4.2 the same way, instead of replacing LLVM or CLANG, is enough to resolve the errors.
我最新的 R 安装配置为使用 llvm-gcc-4.2,这会在构建 SHLIB 时导致错误。以相同的方式为 llvm-gcc-4.2 和 llvm-g++-4.2创建符号链接,而不是替换 LLVM 或 CLANG,足以解决错误。