Lazarus

Programming => Operating Systems => iPhone/iPad => Topic started by: Daniello on October 31, 2013, 01:01:18 pm

Title: XCode 5 - Using Apple LLVM compiler
Post by: Daniello on October 31, 2013, 01:01:18 pm
So, in XCode 5, Apple removed GCC support. And now I can't compile anything with the LLVM compiler...
It gives out dozens of errors, related to unsupported instructions. Anyone knows how to fix this?

Some samples of the errors:
/Users/Mac/Library/Developer/Xcode/DerivedData/Minimon-drqjgxjvaikmvaeypuktpvwscmzt/Build/Intermediates/Minimon.build/Optimized-iphoneos/Minimon.build/DerivedSources-normal/armv7/TERRA_Vector2D.s:186:2: error: invalid instruction
 streqb r0,[r7, #-28]
 ^
/Users/Mac/Library/Developer/Xcode/DerivedData/Minimon-drqjgxjvaikmvaeypuktpvwscmzt/Build/Intermediates/Minimon.build/Optimized-iphoneos/Minimon.build/DerivedSources-normal/armv7/TERRA_Vector2D.s:460:2: error: invalid instruction
 fstmiad r12,{d8}
 ^
/Users/Mac/Library/Developer/Xcode/DerivedData/Minimon-drqjgxjvaikmvaeypuktpvwscmzt/Build/Intermediates/Minimon.build/Optimized-iphoneos/Minimon.build/DerivedSources-normal/armv7/TERRA_Vector2D.s:480:2: error: invalid instruction
 fldmiad r12,{d8}
 ^
/Users/Mac/Library/Developer/Xcode/DerivedData/Minimon-drqjgxjvaikmvaeypuktpvwscmzt/Build/Intermediates/Minimon.build/Optimized-iphoneos/Minimon.build/DerivedSources-normal/armv7/TERRA_Vector2D.s:496:2: error: invalid instruction
 fstmiad r12,{d8}
 ^
Title: Re: XCode 5 - Using Apple LLVM compiler
Post by: Laksen on October 31, 2013, 02:59:31 pm
What command line did you use to compile it with?
Title: Re: XCode 5 - Using Apple LLVM compiler
Post by: Daniello on October 31, 2013, 03:13:18 pm
What command line did you use to compile it with?

I did not use command line directly, I am compiling inside XCode.
Here is the command XCode executed for one of my files:

   /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -x assembler-with-cpp -arch armv7 -fmessage-length=0 -Wno-trigraphs -fpascal-strings -O0 -Wno-missing-field-initializers -Wno-missing-prototypes -Wreturn-type -Wformat -Wno-missing-braces -Wparentheses -Wswitch -Wno-unused-function -Wno-unused-label -Wno-unused-parameter -Wunused-variable -Wunused-value -Wno-empty-body -Wno-uninitialized -Wno-unknown-pragmas -Wno-shadow -Wno-four-char-constants -Wno-conversion -Wno-constant-conversion -Wno-int-conversion -Wno-enum-conversion -Wno-shorten-64-to-32 -Wno-newline-eof -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.1.sdk -fstrict-aliasing -Wdeprecated-declarations -g -fvisibility=hidden -Wno-sign-conversion -miphoneos-version-min=5.1 -iquote "/Users/Mac/Library/Developer/Xcode/DerivedData/Minimon-drqjgxjvaikmvaeypuktpvwscmzt/Build/Intermediates/Minimon.build/Optimized-iphoneos/Minimon.build/Minimon Quest-generated-files.hmap" "-I/Users/Mac/Library/Developer/Xcode/DerivedData/Minimon-drqjgxjvaikmvaeypuktpvwscmzt/Build/Intermediates/Minimon.build/Optimized-iphoneos/Minimon.build/Minimon Quest-own-target-headers.hmap" "-I/Users/Mac/Library/Developer/Xcode/DerivedData/Minimon-drqjgxjvaikmvaeypuktpvwscmzt/Build/Intermediates/Minimon.build/Optimized-iphoneos/Minimon.build/Minimon Quest-all-target-headers.hmap" -iquote "/Users/Mac/Library/Developer/Xcode/DerivedData/Minimon-drqjgxjvaikmvaeypuktpvwscmzt/Build/Intermediates/Minimon.build/Optimized-iphoneos/Minimon.build/Minimon Quest-project-headers.hmap" -I/Users/Mac/Library/Developer/Xcode/DerivedData/Minimon-drqjgxjvaikmvaeypuktpvwscmzt/Build/Products/Optimized-iphoneos/include -I/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include -I/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include -I/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include -I/Users/Mac/Library/Developer/Xcode/DerivedData/Minimon-drqjgxjvaikmvaeypuktpvwscmzt/Build/Intermediates/Minimon.build/Optimized-iphoneos/Minimon.build/DerivedSources/armv7 -I/Users/Mac/Library/Developer/Xcode/DerivedData/Minimon-drqjgxjvaikmvaeypuktpvwscmzt/Build/Intermediates/Minimon.build/Optimized-iphoneos/Minimon.build/DerivedSources -F/Users/Mac/Library/Developer/Xcode/DerivedData/Minimon-drqjgxjvaikmvaeypuktpvwscmzt/Build/Products/Optimized-iphoneos -MMD -MT dependencies -MF /Users/Mac/Library/Developer/Xcode/DerivedData/Minimon-drqjgxjvaikmvaeypuktpvwscmzt/Build/Intermediates/Minimon.build/Optimized-iphoneos/Minimon.build/Objects-normal/armv7/TERRA_Vector2D.d --serialize-diagnostics /Users/Mac/Library/Developer/Xcode/DerivedData/Minimon-drqjgxjvaikmvaeypuktpvwscmzt/Build/Intermediates/Minimon.build/Optimized-iphoneos/Minimon.build/Objects-normal/armv7/TERRA_Vector2D.dia -c /Users/Mac/Library/Developer/Xcode/DerivedData/Minimon-drqjgxjvaikmvaeypuktpvwscmzt/Build/Intermediates/Minimon.build/Optimized-iphoneos/Minimon.build/DerivedSources-normal/armv7/TERRA_Vector2D.s -o /Users/Mac/Library/Developer/Xcode/DerivedData/Minimon-drqjgxjvaikmvaeypuktpvwscmzt/Build/Intermediates/Minimon.build/Optimized-iphoneos/Minimon.build/Objects-normal/armv7/TERRA_Vector2D.o
Title: Re: XCode 5 - Using Apple LLVM compiler
Post by: Daniello on October 31, 2013, 03:14:36 pm
Some more errors (I am only posting two, but there are like 20 or more of each):

/Users/Mac/Library/Developer/Xcode/DerivedData/Minimon-drqjgxjvaikmvaeypuktpvwscmzt/Build/Intermediates/Minimon.build/Optimized-iphoneos/Minimon.build/DerivedSources-normal/armv7/TERRA_Vector2D.s:441:2: error: instruction 'fcvtd' can not set flags, but 's' suffix specified
 fcvtds d0,s23


/Users/Mac/Library/Developer/Xcode/DerivedData/Minimon-drqjgxjvaikmvaeypuktpvwscmzt/Build/Intermediates/Minimon.build/Optimized-iphoneos/Minimon.build/DerivedSources-normal/armv7/TERRA_Vector2D.s:954:19: error: unexpected token in '.section' directive
.section .section __TEXT,__symbol_stub4,symbol_stubs,none,12
Title: Re: XCode 5 - Using Apple LLVM compiler
Post by: Laksen on October 31, 2013, 04:27:26 pm
What architecture did you compile for with freepascal?

fcvtds is a valid instruction in pre-UAL syntax, so it's probably a bug in the assembler unless of course it defaults to UAL syntax
Title: Re: XCode 5 - Using Apple LLVM compiler
Post by: Daniello on October 31, 2013, 04:29:28 pm
I compiled for arm7 only, using FPC 2.6.2
Is there a switch in FPC to enabled/disable that UAL sintax?
Title: Re: XCode 5 - Using Apple LLVM compiler
Post by: Laksen on October 31, 2013, 04:36:18 pm
No, currently UAL is only used for Thumb2 code which is only generated for ARMv7M. And that does not work for iPhone.

But try to set the architecture to armv7a instead of armv7. I'm only guessing here...
Title: Re: XCode 5 - Using Apple LLVM compiler
Post by: Daniello on October 31, 2013, 04:42:50 pm
No, it does not work at all with arm7a.
I am willing to pay 100$ if someone can make my game compile in latest XCode/FPC.
Is there any place where I can put an ad for this or something?
Title: Re: XCode 5 - Using Apple LLVM compiler
Post by: Laksen on October 31, 2013, 04:58:29 pm
You could just write a bugreport, wait a bit, and maybe write on the mac pascal mailing list.

Converting all floating point instructions in fpc to use UAL syntax will probably take a little while. The next best bet is to get the LLVM assembler to accept the pre-UAL syntax.
Title: Re: XCode 5 - Using Apple LLVM compiler
Post by: Daniello on October 31, 2013, 05:00:20 pm
Yeah, I will write on the mailing list. This is strange, because I am sure that there are already people using Xcode 5 and FPC
Title: Re: XCode 5 - Using Apple LLVM compiler
Post by: momor on August 19, 2014, 11:05:10 pm
Hey, by chance - did you have any luck with a fix for this issue ?
Title: Re: XCode 5 - Using Apple LLVM compiler
Post by: Daniello on August 19, 2014, 11:14:49 pm
Hi Momor, actually I am using latest xcode with FPC, and thus using LLVM to compile.
But sadly I did not found an actual fix to this, rather than using a different FPC version to compile.

I am not in my Mac now, but I can later check what version I have that works (I have 3 versions installed).
Title: Re: XCode 5 - Using Apple LLVM compiler
Post by: Daniello on August 19, 2014, 11:26:46 pm
Ah, wait, sorry my memory is hazy, there is indeed a fix, Jonas from FPC told me to use clang's -no-integrated-as parameter. It fixes the problem  ;)
Title: Re: XCode 5 - Using Apple LLVM compiler
Post by: momor on August 20, 2014, 09:56:12 am
Thanks for your reply dude !

Since my memory is a bit lost in these settings - where shall I define this clang parameter ?
Title: Re: XCode 5 - Using Apple LLVM compiler
Post by: Daniello on August 20, 2014, 10:31:40 am
Read this
http://stackoverflow.com/questions/20116475/how-can-i-specify-additional-clang-options-for-xcode-project
Title: Re: XCode 5 - Using Apple LLVM compiler
Post by: momor on August 20, 2014, 10:23:00 pm
So I've tried this -no-integrated-as flag, it effectively allows the FPC code to compile ; but unfortunately this is incompatible with the Objective-C compiled code, which I'm using to wrap my FPC code.

This flag is even incompatible with the default iOS OpenGL Xcode template under Xcode 5.1, throwing a bunch of build errors like this:

:']' expected -- `vld1.64 {d12,d13},[r4:128]'
clang: error: assembler command failed with exit code 1 (use -v to see invocation)

Did I miss something, or am I screwed ?  %)
Title: Re: XCode 5 - Using Apple LLVM compiler
Post by: Daniello on August 20, 2014, 11:01:13 pm
I'm mixing pascal and objective-C code using that flag and it works, strange...

Do you know that you can specify that flag per file instead of globally though?
I dont remember now where, but google it, how to define clang flags per file, should solve your problem (I might even be using that solution, I really don't remember now)
Title: Re: XCode 5 - Using Apple LLVM compiler
Post by: momor on August 21, 2014, 07:15:14 am
Yep Jonas told me that also, and IT WORKS !!!
Thanks for your help.
TinyPortal © 2005-2018