向 XCode 3.2 添加自定义编译器
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1941494/
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
Add a custom compiler to XCode 3.2
提问by rluba
I have a working gcc 4.3.3 toolchain for an ARM Cortex-m3 and would like to integrate it into XCode.
我有一个适用于 ARM Cortex-m3 的工作 gcc 4.3.3 工具链,并希望将其集成到 XCode 中。
Is there a way to set up XCode (3.2) to use this gcc toolchain instead of the built-in GCC 4.2?
有没有办法设置 XCode (3.2) 来使用这个 gcc 工具链而不是内置的 GCC 4.2?
What I've tried so far:
I've added a modified copy of the GCC 4.2.xcplugin
and changed the name, version and executable path. It shows up in XCode but whenever I set the "C/C++ Compiler Version" to the custom compiler it fails with
到目前为止我所尝试的:我添加了一个修改过的副本GCC 4.2.xcplugin
并更改了名称、版本和可执行路径。它出现在 XCode 中,但是每当我将“C/C++ 编译器版本”设置为自定义编译器时,它都会失败
Invalid value '4.3.3' for GCC_VERSION
GCC_VERSION 的无效值“4.3.3”
It seems like the valid version numbers are hardcoded somewhere else because even when I remove the original GCC 4.2.xcplugin
, the value 4.2
remains valid (but is not visible in the "C/C++ Compiler Version" drop down anymore).
似乎有效的版本号被硬编码在其他地方,因为即使我删除了原始的GCC 4.2.xcplugin
,该值4.2
仍然有效(但在“C/C++ 编译器版本”下拉列表中不再可见)。
采纳答案by Sergey
FYI - I got gcc 4.4 integrated into latest Xcode 3.2.4 including flags - see blog at http://skurganov.blogspot.com/
仅供参考 - 我将 gcc 4.4 集成到最新的 Xcode 3.2.4 中,包括标志 - 请参阅http://skurganov.blogspot.com/ 上的博客
回答by jkyle
I'm working on this myself.
我自己也在做这件事。
Currently, it's looking like you have to inherit a built in compiler ref spec.
目前,看起来您必须继承内置的编译器引用规范。
Adding a key of:
添加一个键:
BasedOn = "com.apple.compilers.gcc.4_2";
Makes the plugin load correctly. However, there's the issue of invalid flags due to the apple specific compiler patches. I'm working on that part right now.
使插件正确加载。但是,由于苹果特定的编译器补丁,存在无效标志的问题。我现在正在处理那部分。
回答by jemisa
I've gotten the compile phase to work. To do this:
我已经让编译阶段开始工作了。去做这个:
- In /Developer/Library/Xcode/Plug-ins
- cp "GCC 4.2.xcplugin" "GCC Arm 4.4.1.xcplugin"
- cd "GCC Arm 4.4.1.xcplugin"/Contents
- Modify Info.plist (may not be strictly necessary)
- 在 /Developer/Library/Xcode/Plug-ins
- cp "GCC 4.2.xcplugin" "GCC Arm 4.4.1.xcplugin"
- cd "GCC Arm 4.4.1.xcplugin"/目录
- 修改 Info.plist(可能不是绝对必要的)
8c8 - com.apple.xcode.compilers.gcc.arm-4_4_1 --- + com.apple.xcode.compilers.gcc.4_2 12c12 - GCC Arm 4.4.1 Compiler Xcode Plug-in --- + GCC 4.2 Compiler Xcode Plug-in
- cd Resources
- mv "GCC 4.2.xcspec" "GCC Arm 4.4.1.xcspec"
- Modify "GCC Arm 4.4.1.xcspec"
- 光盘资源
- mv "GCC 4.2.xcspec" "GCC Arm 4.4.1.xcspec"
- 修改“GCC Arm 4.4.1.xcspec”
10c10 - Identifier = "com.apple.compilers.gcc.arm-4_4_1"; --- + Identifier = "com.apple.compilers.gcc.4_2"; 13,16c13,16 - Name = "GCC Arm 4.4.1"; - Description = "GNU Arm C/C++ Compiler 4.4.1"; - Version = "arm-4.4.1"; --- + Name = "GCC 4.2"; + Description = "GNU C/C++ Compiler 4.2"; + Version = "4.2"; 39c39 - "com.apple.compilers.gcc.headers.arm_4_4_1", --- + "com.apple.compilers.gcc.headers.4_2", 42c42 - ExecPath = "$(PLATFORM_DEVELOPER_BIN_DIR)/gcc-arm.4.4.1"; --- + ExecPath = "$(PLATFORM_DEVELOPER_BIN_DIR)/gcc-4.2"; 48,49c48,49 - SupportsZeroLink = No; - "SupportsPredictiveCompilation" = No; --- + SupportsZeroLink = Yes; + "SupportsPredictiveCompilation" = Yes; 52,53c52,53 - "SupportsMacOSXDeploymentTarget" = No; - "SupportsMacOSXMinVersionFlag" = No; --- + "SupportsMacOSXDeploymentTarget" = Yes; + "SupportsMacOSXMinVersionFlag" = Yes; 88a89,90 - "-arch", - "$(value)",
- Link the compiler into /Developer/usr/bin/gcc-arm.4.4.1
- 将编译器链接到 /Developer/usr/bin/gcc-arm.4.4.1
Due to wiki reformatting, the diff's above are not exact, but the relevant information is there. The critical piece that I've noted (and what you appear to have wrong above) is that the Identifier change must correspond with the version number change (with "." replaced with "_").
由于维基重新格式化,上面的差异并不准确,但相关信息在那里。我注意到的关键部分(以及您在上面似乎有错)是标识符更改必须与版本号更改相对应(用“.”替换为“_”)。
Getting rid of the -arch parameter works for compiles, but not for linking. Since my gcc won't accept this parameter I can't link at the moment. Unless I find another way to fix this, I'll probably put in a script instead of the gcc executable to yank out this option.
去掉 -arch 参数适用于编译,但不适用于链接。由于我的 gcc 不接受此参数,因此我目前无法链接。除非我找到另一种方法来解决这个问题,否则我可能会放入一个脚本而不是 gcc 可执行文件来取消这个选项。