问题
I always hesitate to add a brand new question to the killer forums here, but I haven't seen anything close to this bug.
Seems clang has crashed on my while compiling one of my .m files. If anyone has seen or knows of any solution for the below I'd be immensely obliged.
This error occurs when I build for armv6 in a release configuration using XCode 4.4.1
But does not occur when I build for armv6 in a debug configuration, or release for armv7, armv7s or i386.
The specific error is "ObjC ARC contraction":
1. <eof> parser at end of file
2. Code generation
3. Running pass 'Function Pass Manager' on module '/Users/Me/Documents/ThisProject/iOS/..../ClassFoo.m'.
4. Running pass 'ObjC ARC contraction' on function '@"\01-[ClassFoo evalJS:]"'
clang: error: unable to execute command: Segmentation fault: 11
clang: error: clang frontend command failed due to signal (use -v to see invocation)
clang: note: diagnostic msg: Please submit a bug report to http://developer.apple.com/bugreporter/ and include command line arguments and all diagnostic information.
In the ../Intermediaries/Project.build/armv6/ folder I see:
ClassFoo.dia
and I should see (like all of its surrounding files)
ClassFoo.d
ClassFoo.dia
ClassFoo.o
Here are the top 4 of the clang stack, in case someone recognizes something in it:
0 clang 0x00000001010536f2 main + 17107682
1 clang 0x0000000101053b79 main + 17108841
2 libsystem_c.dylib 0x00007fff93c428ea _sigtramp + 26
3 libsystem_c.dylib 0x00007fff93c7a54e tiny_malloc_from_free_list + 1078
edit: I also noticed when trying again recently that I'm getting complaints about the -fno-objc-arc flag -- perhaps the compiler sym-links are pointing at the wrong binaries?
Thanks in advance,
Miles
回答1:
Thanks for all your interest, and I'm sorry to have to answer this question myself but no other solution I've tried has resulted in anything successful. I've done my best to document my adventure here as a how-to-guide to hopefully help a few others.
The short version:
- Xcode 4.5+ does not support building to armv6 (iphone 3g).
- With fresh installs of 4.5 & 4.4.1 I experienced various versions of the original error.
The reason is two-fold:
- xcspec files Xcode uses do not include entries for this architecture.
- 4 needed libclang_rt*.a files have had their armv6 slices stripped.
There is a solution! (see long version below)
The long version:
Amongst the many many frustrating attempts I made to sort this issue out, such as searching SO forums, searching apple dev forums, googling, endlessly fiddling with project settings, copying earlier SDKs into the Xcode.app packages, posting this question, filing a bug report with Apple, etc. ad infinitum <-- means, "and so in into infinity" each seemed to have either nothing pertinent to reveal or only a tiny tidbit of information.
The recipe for this solution finally took one frustrated and determined developer and the culmination of everything in one very long night.
So where's the how-to?
( Right here, bro )
There are about 12 steps, so don't forget the final ones below the images!
Disclaimer: This is my own solution and it works great for me, but if you're not sure about what's going on or what you're doing please be very careful and realize that I will assume no responsibility for any damages you may incurr by trying to follow these steps. That said, here you go!
- If you don't already have a copy, download Xcode 4.4.1 from http://connect.apple.com
- Extract
/PATH_TO_YOUR_Xcode_4.4.1.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.1.sdk - Copy it to
/PATH_TO_YOUR_Xcode_4.5.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/ Now you'll edit 4 Xcode
.xcspecfiles in your Xcode 4.5:- Navigate here:
/PATH_TO_YOUR_Xcode_4.5.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/Specifications Select these files:
- iPhoneXcode4Options.xcspec
- iPhoneOSArchitectures.xcspec
- iPhoneCompilerOptions.xcspec
- iPhoneClangOptions.xcspec
Right-click and select "Open with Xcode"
- Navigate here:
- Repeat for Xcode 4.4.1, and stick the two windows side-by-side (just makes this easier).
You're going to add
armv6to several entries as below:
Here again:

And here:

Here you cut & paste an entry from Xcode 4.4.1 to Xcode 4.5:

Alright you completed that tediousness, yay! Save the edited files and close them all. Next you have to create new
libclang_rt*.afiles to handle compiling these arches. This step is more easily done in Terminal. Enter these commands:
Make sure the backups copy and there isn't some error in paths or typing!
cd /PATH_TO_YOUR_Xcode_4.4.1.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/4.2/lib/darwin
sudo mkdir armv6_extractions
lipo -extract armv6 -output armv6_extractions/libclang_rt.ios.armv6.a libclang_rt.ios.a
lipo -extract armv6 -output armv6_extractions/libclang_rt.profile_ios.armv6.a libclang_rt.profile_ios.a
lipo -extract armv6 -output armv6_extractions/libclang_rt.cc_kext.armv6.a libclang_rt.cc_kext.a
sudo cp -R armv6_extractions /PATH_TO_YOUR_Xcode_4.5.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/4.2/lib/darwin
cd /PATH_TO_YOUR_Xcode_4.5.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/4.2/lib/darwin
sudo mkdir originals
sudo cp libclang_rt.ios.a originals/
sudo cp libclang_rt.cc_kext_ios5.a originals/
sudo cp libclang_rt.profile_ios.a originals/
lipo -create -output libclang_rt.ios.a armv6_extractions/libclang_rt.ios.armv6.a originals/libclang_rt.ios.a
lipo -create -output libclang_rt.cc_kext_ios5.a armv6_extractions/libclang_rt.cc_kext.armv6.a originals/libclang_rt.cc_kext_ios5.a
lipo -create -output libclang_rt.profile_ios.a armv6_extractions/libclang_rt.cc_kext.armv6.a originals/libclang_rt.profile_ios.a
Restart Xcode 4.5
^...I wrote "11" here...why's it showing as "1"?
Open your project and edit your settings accordingly. I recommend that you create a separate configuration just for building to armv6, and lipo everything together when you're done.
- Add
armv6toValid Architectures - Add
armv6toArchitectures - For your specific armv6 configuration, set
Base SDKtoiOS 5.x(whatever is now listed in the drop-down menu) - Set your deployment target as needed ( I have built as low as iOS4.1 so far, and I believe the iOS5.x sdk you installed in the beginning can deploy as low as 4.x )
- Add
Okay, I think that's all.
If anyone sees any edits that need to be made PLEASE do so, and I welcome any feedback that anyone has to give here.
If something goes wrong, fingers crossed you can always reinstall your Xcode and try again (or not).
Best of luck.
回答2:
I have had this problem before.... did you initialize your .m more than once? or import it? the only time this issue has occurred for me is when I tried to initialize or import a .m file somewhere other than where its native environment was.
回答3:
A compiler should not crash. If it does then the vendor needs to fix it. Unfortunately I don't think you will be able to get any useful response via a Radar from Apple because they have moved on: there is a newer version of Clang in Xcode 4.5 and they don't support armv6 any more.
Having said that you should open a Technical Support Incident, because likely they can provide you with a workaround.
回答4:
The error message indicates an internal error in the compiler while processing the function @"\01-[ClassFoo evalJS:]". You might be able to get around the error by rearranging the code in that function and/or adding volatile to local variables in that function.
来源:https://stackoverflow.com/questions/13410172/objc-arc-contraction-clang-crash



