是否有可能编译一个较新版本的LLVM并将其与Xcode一起使用? [英] Is it possible to compile a newer version of LLVM and use it with Xcode?

查看:185
本文介绍了是否有可能编译一个较新版本的LLVM并将其与Xcode一起使用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一台旧计算机无法升级到Lion,但我想使用它进行编码,同时仍然利用语法如 instancetype 和Objective-C字面量。有没有人试图编译一个更新的Clang和LLVM使用一个旧的Xcode和成功?

I have an old computer that cannot upgrade to Lion, but I would like to use it for coding while still taking advantage of syntax such as instancetype and Objective-C literals. Has anyone tried to compile a newer Clang and LLVM to use with an older Xcode and been successful?

推荐答案

有多种方法可以使用最新的LLVM / Clang版本。

There are various ways to use the newest LLVM/Clang version.

(1)插件,如上述注释中所述,例如:
http://blog.wadetregaskis.com/tot-clang-llvm-in-xcode/

(1) Plugins, as described in the comments above, e.g.: http://blog.wadetregaskis.com/tot-clang-llvm-in-xcode/

As在链接的博客文章中指出,你可能会从Xcode的实时语法检查中得到错误/警告,因为Xcode使用较旧版本的libclang(更多的是在(3)下)。它可能编译良好,但编辑源代码不会很有趣。

As pointed out in the linked blog post, you may get errors/warnings from Xcode's real-time syntax checking as Xcode uses an older version of libclang (more on that under (3)). It is likely to compile fine, but editing source code won't be a lot of fun.

(2)通过设置编译器 CC 标志。这可能是最简单/最快的解决方案,设置只影响一个项目。转到项目的构建设置,选择添加构建设置 - >添加用户定义的设置(在Xcode 5中,这隐藏在编辑器菜单中),命名为 CC ,并将值设置为您的Clang版本的路径。对我来说工作得很好,但是和(1)一样,你可能会遇到与实时错误报告冲突,特别是如果你想使用新的语法,如文字,或传递警告,旧版本不明白。

(2) Set the compiler via the CC flag. This is probably the easiest/fastest solution and the setting only affects one project. Go to the project's Build Settings, choose "Add Build Setting" -> "Add User-Defined Setting" (in Xcode 5, this is hidden in the Editor menu), name it CC and set the value to the path of your version of Clang. Worked fine for me, but as with (1), you might get conflicts with the live error reporting, especially if you want to use new syntax such as literals, or pass flags for warnings that the older version does not understand.

(3)替换编译器。确保在替换之前备份任何文件。有两个文件需要被替换:Clang二进制和libclang.dylib。转到 /Applications/Xcode.app/ - >选项单击 - >显示包内容 - > / Contents / Developer / Toolchains / XcodeDefault .xctoolchain / usr 。 clang在 / bin 中,libclang.dylib在 / lib

(3) Replace the compiler. Make sure you back up any files before replacing them. There are two files that need to be replaced: the Clang binary, and libclang.dylib. Go to /Applications/Xcode.app/ -> Option-Click -> "Show Package Contents" -> /Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr. clang is in /bin, libclang.dylib is in /lib.

这两个二进制文件都可以从源码编译(当然会给你一个更新的版本),或者从最新的Xcode包复制。我遇到麻烦使用自定义版本的libclang,但我怀疑这个问题源于我的修改。如果有疑问,请使用稍后Xcode版本中的libclang。

Both binaries can either be compiled from source (which will give you an even newer version, of course) or just copied from the latest Xcode package. I ran into trouble using a customised version of libclang, but I suspect the problem originates from my modifications there. If in doubt, use libclang from a later Xcode version.

注意:我修改的libclang二进制文件使用ARC,因此与Xcode 4不兼容运行与垃圾收集。 Xcode 5本身使用ARC,所以问题已经消失。如果你编译libclang未经修改,你不应该在Xcode 4或5中遇到这个问题。

Note: My modified libclang binary used ARC and is therefore incompatible with Xcode 4 which runs with garbage collection. Xcode 5 itself uses ARC so the problem has vanished. If you compile libclang unmodified, you shouldn't come across the issue in either Xcode 4 or 5.

这篇关于是否有可能编译一个较新版本的LLVM并将其与Xcode一起使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆