Cross compile Linux/x86 to iOS/ARM

397 views
Skip to first unread message

Roger Keays

unread,
Apr 2, 2015, 5:08:39 PM4/2/15
to rob...@googlegroups.com
Hi,

I have built the iOS toolchain (clang/llvm) on my linux machine and can build and deploy Objective-C applications for iPhone with this with no problems. But who wants to develop in Objective-C?

AFAICT RoboVM uses llvm so I should be able to use it to generate machine code from my Java sources and then use my toolchain to assemble a binary. I'm just not sure of the magic incarnation to do this.

Has anybody has success doing this? If not, what pieces are missing?

Thanks in advance,

Roger

Niklas Therning

unread,
Apr 3, 2015, 2:48:18 AM4/3/15
to Roger Keays, rob...@googlegroups.com
Hi Roger,

Cool! Don't think anyone else has tried this yet. Do you use [1] or something else? The clang/llvm part is the easy bit since it's cross-platform. Deploying to a device should also be quite easy thanks to libimobiledevice. Those pieces are already in RoboVM and it would be trivial to make that work on Linux. The hard part is the linking and codesigning I would say. Would be interesting to know more of your process:

How does the toolchain you are using link the binaries? A port of Apple's ld or something else like LLVM's lld [2]?
How do you codesign or do you deploy on a jailbroken device without codesigning?
Which iOS SDK are you building against? iOS 8.x or older?
How do you download the iOS SDK to your Linux or do you use a Mac to get it and then copy to Linux?

In robovm/compiler there's a class called org.robovm.compiler.util.ToolchainUtil that handles most of the command line tools discovery so that's a good place to start patching to make it run the linker and other external tools correctly.

The LLVM binaries we include for Linux are already capable of targeting iOS ARM32/64 and produce proper Mach-O object files so no patches should be necessary there.

We used to include libimobiledevice binaries for Linux but we stopped since it was a bit hard to get it to compile with the latest version. But it should definitely be doable to get that working again. The code for the libimobiledevice Java wrapper is in robovm/libimobiledevice.

For codesigning [3] could be of interest.


/Niklas


--
You received this message because you are subscribed to the Google Groups "RoboVM" group.
To unsubscribe from this group and stop receiving emails from it, send an email to robovm+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Roger Keays

unread,
Apr 6, 2015, 6:09:20 PM4/6/15
to rob...@googlegroups.com
[reposting to the mailing list]

Hi Niklas,

Cool! Don't think anyone else has tried this yet. Do you use [1] or something else? The clang/llvm part is the easy bit since it's cross-platform. Deploying to a device should also be quite easy thanks to libimobiledevice. Those pieces are already in RoboVM and it would be trivial to make that work on Linux. The hard part is the linking and codesigning I would say. Would be interesting to know more of your process:
Yes, I used the 'iOS Clang Toolchain' you referenced. I've posted my build process online:

http://www.ninthavenue.com.au/how-to-build-an-ios-toolchain-for-linux-debian-7

How does the toolchain you are using link the binaries? A port of Apple's ld or something else like LLVM's lld [2]?
It is a port of Apple's ld.

There is also an ld for iOS in the Cydia repositories but I haven't tried using it to link code compiled on linux. Have you ever considered building with RoboVM on the iOS device itself?

How do you codesign or do you deploy on a jailbroken device without codesigning?
Jailbroken.

Which iOS SDK are you building against? iOS 8.x or older?
How do you download the iOS SDK to your Linux or do you use a Mac to get it and then copy to Linux?
In robovm/compiler there's a class called org.robovm.compiler.util.ToolchainUtil that handles most of the command line tools discovery so that's a good place to start patching to make it run the linker and other external tools correctly.

The LLVM binaries we include for Linux are already capable of targeting iOS ARM32/64 and produce proper Mach-O object files so no patches should be necessary there.

We used to include libimobiledevice binaries for Linux but we stopped since it was a bit hard to get it to compile with the latest version. But it should definitely be doable to get that working again. The code for the libimobiledevice Java wrapper is in robovm/libimobiledevice.
I'll check out the RoboVM source code and give it a shot. I have libimobiledevice from the Debian repositories, but I'm just deploying with SSH at the moment.

Cheers,

Roger

Niklas Therning

unread,
Apr 7, 2015, 4:06:46 AM4/7/15
to Roger Keays, rob...@googlegroups.com
So you're able to build against the iOS 8.1 SDK? The RoboVM compiler uses "xcrun -f " to locate all command line tools so providing a compatible script in the path should take you a long way without patching any code.

Please give it a try and keep us updated.
Reply all
Reply to author
Forward
0 new messages