Add a custom compiler to XCode 3.2
I have a working gcc 4.3.3 toolchain for an ARM Cortex-m3 and would like to integrate it into XCode.
Is there a way to set up XCode (3.2) to use this gcc toolchain instead of the built-in 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 b开发者_开发问答ut whenever I set the "C/C++ Compiler Version" to the custom compiler it fails with
Invalid value '4.3.3' for GCC_VERSION
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).
FYI - I got gcc 4.4 integrated into latest Xcode 3.2.4 including flags - see blog at http://skurganov.blogspot.com/
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.
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)
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"
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
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.
精彩评论