Speed boost for apps from GCC 4 portBy Chris Williams. Published: 18th Mar 2005, 15:07:39 | Permalink | Printable
Native RISC OS binaries run on x86 LinuxThe forthcoming port of GCC 4 could bring a welcome speed up to software written in C++ and possibly other languages.
The release manager for the mainstream GCC project, Mark Mitchell, told C|Net earlier, "The primary purpose of [GCC] 4.0 was to build an optimization infrastructure that would allow the compiler to generate much better code."
Nick Burrett, project leader for the RISC OS GCCSDK team, says he's begun porting GCC 4.1 to our platform and has working C, C++ and Fortran compilers, whilst the Ada compiler will require further bug fixing. GCC is a popular open source compiler package that is used to build applications using source code written by developers.
Nick commented: "Applications written in C++ will be noticably faster and smaller. Part of this will come from a different exception handling model that I use in 4.0. We have switched from setjmp/longjmp, where the exception framework is generated at run-time which extra code overheads in each function, to framework that is generated at compile time with virtually no code overheads."
Although he's yet to perform formal benchmarking, Nick added: "The tree optimisers really start to demonstrate their worth on C++ code. I've seen code size drop by 30% in some cases."
To benefit from the latest GCC version, an application must be recompiled by the compiler package, meaning that its source code must be available for the original author or others to rebuild it. Large projects are often written in C++ code and will therefore benefit immensely by being built with GCC 4. For example, the Firefox web browser is mostly written in C++. However, the majority of RISC OS applications that require GCC tend to be written in C and according to Nick, a performance increase for C based software won't be noticeable, initially.
"For applications written in C, I wouldn't expect a noticable difference
at this time," said Nick.
"The tree-based optimisers have been written to replace the old RTL-based optimisers but with the initial target of producing code that is similar, or better in performance. I would expect that we will see more noticeable performance improvements in later releases, such as 4.1, or 4.2."
Developing the GCC 4 port
GCC is used around the world by countless developers on various platforms, with RISC OS being just one of them. Nick admitted, "The work on GCC 4 has been very involved and slow-going".
For GCC 4, Nick's using the mainstream GCC source tree and applying patches to it, rather than using the custom GCCSDK source tree used in previous GCC ports. Nick argues that this will simplify the job of keeping RISC OS GCC up to date and will increase the chances of getting the RISC OS specific patches accepted into the mainstream GCC source code. A downside to this is that the GCC version that Nick is working on will only produce software in ELF format, whereas RISC OS executes programs in AIF format - there's further discussion on ELF vs. AIF/AOF here. Nick is currently pondering whether or not ELF will be adopted by the RISC OS world (either natively in the OS or with a suitable ELF-loader), and therefore if he has to back-port AIF and AOF support to GCC 4.
Another headache is that when building GCC itself, the compiler assumes it's being compiled on the operating system and computer architecture that it will produce software for - for example, by building intermediary programs and then executing them as part of the build process. However in Nick's case, he's chosen to cross-compile the GCC 4 port on an Intel powered PC running GNU/Linux due to the speed offered by this faster architecture. He therefore needs to coax the package into building on x86 GNU/Linux, and yet produce software for ARM RISC OS.
Nick explained: "I found an emulator called QEMU that can dynamically recompile ARM into native x86. I've extended it to trap on RISC OS SWIs and have written a set of functions to emulate them, allowing me to run native RISC OS binaries under x86-Linux, similar in concept to WINE.
"The benefits of the QEMU/RISC OS simulator have been amazing. Proper GCC regression testing can now be achieved as we have the ability to run the GCC test suites as originally intended, rather than having to bastardize the environment to work with GCCSDK. Autoconf will properly configure libraries and applications against pre-installed RISC OS applications, simplifing the porting process."
The fruits of Nick's work on QEMU could be very interesting for projects such as ArcEm.
RISC OS GCCSDK website
Previous: Web browser offerings compared
Next: DVD writing to become reality on RISC OS
DiscussionViewing threaded comments | View comments unthreaded, listed by date | Skip to the end
Please login before posting a comment. Use the form on the right to do so or create a free account.
Search the archives
Today's featured article
Jan Vibe: The interview
The man, the myth, the BASIC graphics master
9 comments, latest by harmsy on 17/8/07 3:50PM. Published: 11 Aug 2007
Viewfinder supports Radeon graphics chipset
7500 and 7000 cards dealt and played
17 comments, latest by imj on 5/9/03 3:50PM. Published: 3 Sep 2003
News and media:
RISCOS Ltd •
RISC OS Open •
MW Software •
Advantage Six •
CJE Micros •
Liquid Silicon •
Chris Why's Acorn/RISC OS collection •
The Register •
The Inquirer •
Apple Insider •
BBC News •
Sky News •
Google News •