We reached a similar milestone today with our work to replace the backend of our compiler with LLVM. First, a quick summary of how our compiler works and how LLVM will be an important part of the future of our compiler:
When your choose Run or Build in Real Studio, all of the code you wrote is passed to the Real Studio compiler which is represented by the items in grey in this diagram. The front end is the part of the compiler that understands the Realbasic syntax. It converts your code to a sort of meta-assembly language. That meta-code is then passed to the compiler backend which turns it into x86 assembler which your computer can understand. All this compiled code is then passed to the linker which puts it all together and produces the actual application you can distribute. Of course all of this is hidden behind the scenes but it's helpful (or at least mildly interesting) to understand how it works.
We have written two different backends for the compiler: one that produces x86 assembler and the other that produces PowerPC assembler. The latter is no longer supported since Apple has stopped making Macs using PowerPC processors.
LLVM is an open-source compiler backend that has a lot of advantages over the ones we have written:
- It's an optimizing compiler which means it can make your code run faster.
- It does dead-code stripping which means it can leave out the parts of the Realbasic framework that your project isn't using resulting in a smaller application.
- It may enable us to return to a single-file executable on Windows.
- It supports the ARM processor used in mobile devices such as iPhone/iPad.
Last year we took the first step of making RBScript compile with LLVM. The next step is to replace it for building entire applications. We have spent a bit of time on this next step recently. Today we were able to compile and run a "Hello World" console app and a desktop app as well. This is a significant milestone but it's only the first of many.
There is still a lot of work to do before you will be building your projects with LLVM but reaching this important "Hello World" milestone is an important one.
EDIT: For the sake of clarity, it's possible that some issue might prevent us from achieving single-file executables for Windows. So I have changed "will" to "may" in item #3 above. Also, I have removed mention of Android from item #4 because LLVM doesn't help (or hinder) us when it comes to supporting Android.