Author Topic: LLVM/Clang  (Read 1366 times)

C0deH4cker

  • Hero Member
  • *****
  • Posts: 2849
  • Reputation: 129
  • I am leaving iNinjas. Contact me via email.
  • Badges:
  • iDevices: iPhone 4S 16gb Black (5.1.1), iPad 2 32gb White (5.0.1), iPod Touch 2G 8gb (4.2.1)
LLVM/Clang
« on: March 19, 2012, 06:16:33 pm »
What is LLVM (Low-Level Virtual Machine)?

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies. Despite its name, LLVM has little to do with traditional virtual machines, though it does provide helpful libraries that can be used to build them.

LLVM began as a research project at the University of Illinois, with the goal of providing a modern, SSA-based compilation strategy capable of supporting both static and dynamic compilation of arbitrary programming languages. Since then, LLVM has grown to be an umbrella project consisting of a number of different subprojects, many of which are being used in production by a wide variety of commercial and open source projects as well as being widely used in academic research. Code in the LLVM project is licensed under the "UIUC" BSD-Style license.


What is Clang?

Clang is an LLVM front end for the C, C++, and Objective-C languages. Clang aims to provide a better user experience through expressive diagnostics, a high level of conformance to language standards, fast compilation, and low memory use. Like LLVM, Clang provides a modular, library-based architecture that makes it suitable for creating or integrating with other development tools. Clang is considered a production-quality compiler for C, Objective-C, C++ and Objective-C++ on x86 (32- and 64-bit), and for Darwin/ARM targets.




Now that you know what I ported, here is a little info about this project:

About 6-8 months ago, I tried to port LLVM and Clang to iOS using my iPod Touch 2g.  That failed horribly, because my iPod didn't have nearly enough RAM required to port this.  So, since I got my iPad 2 in December, I've decided to give it another go.  This time, I was successful :).  I have been working on this project on and off for a few weeks now, and it was the most difficult port for me so far, requiring changes in many things, from the configure script to Makefiles to source/header files in different languages and even other files that took a LOT of Googling to figure out.  But the important thing is that we can now use the LLVM virtual machine and the Clang compiler on our devices :D :D :D :D :D :D :D!

I have packaged this up and have uploaded it to the beta repo for now, located at https://ininjas.com/beta/

I do not expect you to run into many problems (if any), but if you do, please let me know so that I can fix them.

I have done some basic testing with Clang so far, and it seems to me like it is working properly.  for those of you who are interested, here are the results of make check:

  Expected Passes    : 5430
  Expected Failures  : 62
  Unsupported Tests  : 365
  Unexpected Failures: 21


As you can see, this isn't perfect, but it is close enough for now.  Only failing 21 tests out of a total of 5451 isn't shabby at all.  It is probably due to me dropping support for a few of the architectures.  Speaking of that, here are the supported architectures for this build of LLVM/Clang:

    arm     - ARM
    ppc32   - PowerPC 32
    ppc64   - PowerPC 64
    sparc   - Sparc
    sparcv9 - Sparc V9
    thumb   - Thumb
    x86     - 32-bit X86: Pentium-Pro and above
    x86-64  - 64-bit X86: EM64T and AMD64

Once again, if you notice any problems/bugs while using either LLVM or Clang, PLEASE let me know about it so I may remedy the situation.

Trcx528

  • Haxor
  • Hero Member
  • *****
  • Posts: 4502
  • Reputation: 166
  • Google it!
    • iNinjas
  • Badges:
  • Computers: 13" 2011 Macbook Pro, 120 GB SSD and 16 GB of Ram
  • iDevices: None
Re: LLVM/Clang
« Reply #1 on: March 19, 2012, 11:10:25 pm »
This is pretty epic! Awesome work dude!  I'm going to be debugging libdnet this next week, which likely will start with a clean port, maybe I'll give this a go and see how well it work.  Awesome job man. :D

Divinite

  • Sr. Member
  • ****
  • Posts: 329
  • Reputation: 15
  • Sarah... Sarah Lasonia. Enchantee.
    • Get help here!
  • Badges:
  • iDevices: Jailbroken iPod touch 4g and Xcode with iOS sdk 4.3+
Re: LLVM/Clang
« Reply #2 on: March 20, 2012, 05:59:34 am »
OH MY GOD I LOVE YOU!!!!!!!! :D :D :D :D

Thanks SO MUCH!!!!
I am the developer of Danaus.
I am a iHacker, iDevice hacker, whatever you want to call it!

C0deH4cker

  • Hero Member
  • *****
  • Posts: 2849
  • Reputation: 129
  • I am leaving iNinjas. Contact me via email.
  • Badges:
  • iDevices: iPhone 4S 16gb Black (5.1.1), iPad 2 32gb White (5.0.1), iPod Touch 2G 8gb (4.2.1)
Re: LLVM/Clang
« Reply #3 on: March 20, 2012, 02:55:57 pm »
No prob. To use clang instead of gcc, do this:
CC=clang ../configure ...
Instead of just ../configure.

LeoTh3o

  • Full Member
  • ***
  • Posts: 231
  • Reputation: 43
    • ET&C
  • Computers: MacBook Pro 15', half 2009, OS X 10.8.1
  • iDevices: iPod 3G iOS 5.1.1; iPad 2 WiFi iOS 5.1.1 jb
Re: LLVM/Clang
« Reply #4 on: May 13, 2012, 04:59:31 am »
Thanks. I had a problem with "official" gcc, as it hang on a file. When I switched to clang, it build it. I was stuck there for days.
0xEB        0xFE
jmp short -2

Don't like seeing ads? Click here to register!

C0deH4cker

  • Hero Member
  • *****
  • Posts: 2849
  • Reputation: 129
  • I am leaving iNinjas. Contact me via email.
  • Badges:
  • iDevices: iPhone 4S 16gb Black (5.1.1), iPad 2 32gb White (5.0.1), iPod Touch 2G 8gb (4.2.1)
Re: LLVM/Clang
« Reply #5 on: May 13, 2012, 03:55:17 pm »
Lol nice! Glad to see that it has helped someone other than myself.

H4CK3R

  • Haxor
  • Sr. Member
  • *****
  • Posts: 407
  • Reputation: 42
  • I try and write cool tweaks!
    • Kyle Howells
  • Badges:
  • Computers: MacBook Pro
  • iDevices: iPod 1G, iPod 2G, iPod 4G, iPhone 4S, iPad 2, iPad mini
Re: LLVM/Clang
« Reply #6 on: May 14, 2012, 09:17:05 am »
Wow, fantastic work! This must be one of the biggest projects to be ported so far, on here!!!

Little point: have you used clang to compile itself yet?

C0deH4cker

  • Hero Member
  • *****
  • Posts: 2849
  • Reputation: 129
  • I am leaving iNinjas. Contact me via email.
  • Badges:
  • iDevices: iPhone 4S 16gb Black (5.1.1), iPad 2 32gb White (5.0.1), iPod Touch 2G 8gb (4.2.1)
Re: LLVM/Clang
« Reply #7 on: May 14, 2012, 12:46:34 pm »
Haven't tried yet. I will try that later.