The PokéCommunity Forums  

Go Back   The PokéCommunity Forums > ROM Hacking > Tools, Tutorials & Resources
Sign Up Rules/FAQ Live Battle Blogs Mark Forums Read

Notices

Tools, Tutorials & Resources Various tools to help you develop your hacks can be found here.
New threads in this forum are to be approved by a moderator before they are displayed.


Advertise here

Reply
 
Thread Tools
  #1    
Old February 12th, 2011, 06:49 AM
knizz's Avatar
knizz
 
Join Date: Aug 2007

Advertise here
There is a compiler framework called LLVM. It's faster than GCC and opimizes code more aggresively and the llvm-frontend 'clang' has much better error-messages. I chose it to get rid of the devkit-dependency. (Which I didn't manage but ... at least I have fast code now.)

My clang version doesn't support arm (not because it can't but because the pre-compiled version doesn't include it.)
Fortunately the LLVM-Output is platform/cpu/os-independent. So I compile for x86 first and the override the cpu-type (i think clang ignores -march=thumb) when using llc.

http://llvm.org/docs/Passes.html lists all options for optimizations. They are supposed to be used with clang when it performs *all* actions. When you do linking, etc. yourself you probably have to give the optimization options to llvm-ld too.

Code:
clang -O4 -S -emit-llvm -march=thumb file1.c file2.cpp
llvm-as-2.8 file1.s
llvm-as-2.8 file2.s
llvm-ld-2.8 -o rom file1.s.bc file2.s.bc
llc-2.8 -O=3 -march=thumb -mcpu=arm7tdmi rom.bc
arm-thumb-elf-as -mthumb-interwork -o crt0.o crt0.S
arm-thumb-elf-as -mthumb-interwork -o rom.o rom.s
arm-thumb-elf-ld -q -Ttext=0x8000000 -Tbss=0x3000000 -o rom.elf crt0.o rom.o
arm-thumb-elf-strip -s rom.elf
arm-thumb-elf-objcopy -O binary rom.elf rom.gba
gbafix rom.gba
I use the crt0.S from http://velvetfr.ath.cx/gba/tutorial/gba-tutorial1.html
__________________
Firered IDA 6.1 DB: https://www.dropbox.com/s/hvvmxxoo1dkmdzc/firered.idb
VBA-M with lua scripting support (no longer in development)

Last edited by knizz; February 13th, 2011 at 06:12 AM. Reason: Wrong instruction caused 210% bigger output. Fixed now.
Reply With Quote
  #2    
Old February 12th, 2011, 02:13 PM
IIMarckus's Avatar
IIMarckus
J946@5488AA97464
 
Join Date: Oct 2007
Gender:
Quote:
Originally Posted by knizz View Post
Fortunately the LLVM-Output is platform/cpu/os-independent.
This is not correct. But it may (or may not) be close enough for your purposes; I don’t know enough about LLVM to comment.

I do like LLVM. It’s nice to finally see some competition to GCC, which is a bloated mess and a nightmare to build.
__________________
iimarck.us / hax.iimarck.us

If you want me, please contact me by email. [email protected]

If you want to hack Pokémon RBY or GSC, read, read, and read some more. This has tons of valuable information.

Pokémon Red disassembly project

Rules that should be rethought: 25charlimit, bumping.
Bad posts are bad posts, regardless of how many words are in them or how old the thread is.
Good posts are good posts, regardless of how old the thread is—and brevity is underrated.
Reply With Quote
  #3    
Old February 12th, 2011, 02:30 PM
knizz's Avatar
knizz
 
Join Date: Aug 2007
Quote:
Originally Posted by IIMarckus View Post
This is not correct. But it may (or may not) be close enough for your purposes; I don’t know enough about LLVM to comment.

I do like LLVM. It’s nice to finally see some competition to GCC, which is a bloated mess and a nightmare to build.
It simply means that the only platform-limitation is in your own code and not the compiler or llvm-representation. In other words: Your code will only work on the GBA when you write for GBA.

Platform-independent enough for my purposes.
__________________
Firered IDA 6.1 DB: https://www.dropbox.com/s/hvvmxxoo1dkmdzc/firered.idb
VBA-M with lua scripting support (no longer in development)
Reply With Quote
  #4    
Old March 1st, 2011, 05:36 PM
Full Metal's Avatar
Full Metal
C(++) Developer.
Community Supporter
 
Join Date: Jan 2008
Location: In my mind.
Age: 19
Gender: Male
Nature: Timid
Send a message via Windows Live Messenger to Full Metal
ohai how did I not see this thread?
nifty nifty, but does it have things like malloc and new built in (for C/C++ respectively)?
I mean, making my own malloc in asm would be as simple as using my FS code and making it into code that...works on a GBA, but you know, it's nice to avoid that. haha. I sound like I don't know what I'm talking about, but I do! ... yea! XD
__________________

★ full metal.

I like to push it,
and push it,
until my luck is over.
Reply With Quote
  #5    
Old March 4th, 2011, 06:32 PM
Silent Crest
Celestial Shine
 
Join Date: Dec 2010
Nature: Calm
Okay. So LLVM is a compiler. So what?!?

There's a lot of C/ C++ compilers. When I used to write c/ c++ I used Bloodshed Dev. My question is (since I don't know a lot about rom hacking) what does the LLVM have to do with Rom Hacking?
Reply With Quote
  #6    
Old June 12th, 2011, 05:09 PM
Full Metal's Avatar
Full Metal
C(++) Developer.
Community Supporter
 
Join Date: Jan 2008
Location: In my mind.
Age: 19
Gender: Male
Nature: Timid
Send a message via Windows Live Messenger to Full Metal
It takes C or C++ code...and compiles it.
You see, if you actually knew what you were talking about, you would know that devkitpro/advance generates HUGE and very terrible code ( as far as assembly and instructions go atleast ). Even optimizations don't do that much for it.
What this thing does is makes actual optimized code. IDK if it does anything about file-size compared to devkitpro ( I haven't used this thing just yet -- still -- ), but it definitely increases over-all performance of the .elf files generated. That's my comprehension anyways.
__________________

★ full metal.

I like to push it,
and push it,
until my luck is over.
Reply With Quote
Reply
Quick Reply

Sponsored Links


Advertise here
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Minimum Characters Per Post: 25



All times are UTC -8. The time now is 12:04 AM.


Style by Nymphadora, artwork by Sa-Dui.
Like our Facebook Page Follow us on Twitter © 2002 - 2014 The PokéCommunity™, pokecommunity.com.
Pokémon characters and images belong to The Pokémon Company International and Nintendo. This website is in no way affiliated with or endorsed by Nintendo, Creatures, GAMEFREAK, The Pokémon Company or The Pokémon Company International. We just love Pokémon.
All forum styles, their images (unless noted otherwise) and site designs are © 2002 - 2014 The PokéCommunity / PokéCommunity.com.
PokéCommunity™ is a trademark of The PokéCommunity. All rights reserved. Sponsor advertisements do not imply our endorsement of that product or service. User generated content remains the property of its creator.