Haiku Finally Gets a Native GCC4 - full story inside!

News posted by umccullough on Sun, 2009-02-01 04:25
Michael's Quad-core compiling GCC4.3.3Michael's Quad-core compiling GCC4.3.3

As many Haiku community members know, one major hurdle that has been making it difficult to port new software to Haiku has been the lack of an up-to-date GCC4 compiler. While a GCC 4.1.2 cross-compiler has been available now for some time, cross-compiling software for a GCC4-built Haiku can be painful and frustrating. What Haiku really needed was a native GCC4 toolchain to run on a GCC4-built Haiku install.

That time is now! A native Haiku GCC4.3.3 is now a reality.

Michael Lotz set out to tackle this task and the fruits of his labor have finally been committed to the Haiku repository for all to benefit from.

Michael Lotz details the process he used

To demonstrate what process was necessary to perform this task, he has written a detailed blog post recounting his experience. It's a long read, and certainly lists some confusing concepts. If you were at all curious what it would take, going from a GCC2-built Haiku to a GCC4-built Haiku with its own native compiler, the steps are all there.

During the process, Michael was even "fortunate" to find and submit a patch for a bug in libiberty. You will read about the strange behavior that led to the discovery in his blog post.

Dogfooding is important... Yummy!

If you're paying attention while reading his blog, you'll note that Michael is "dogfooding" during his Haiku development. Not only does he use Haiku for development purposes, but it's also the only operating system he uses currently. This suggests a couple of important points: a) Haiku is stable enough to use daily and develop in and b) Haiku developers are serious about Haiku, intending to use it as their daily OS. I know of several developers who use Haiku daily for various tasks, including development. This demonstrates a dedication to the quality they are pursuing, and increases the likelihood that even little annoying things about Haiku are going to get fixed eventually.

What does all this mean? What's next?

Freshly-built Haiku running GCC4Freshly-built Haiku running GCC4

So, what should we expect from Haiku now that it has a native GCC4 toolchain?

I'm not sure - and that's the exciting part actually! This opens the door for easier porting of modern software, and more easily moves Haiku out of the "dark" GCC2 cloud that BeOS had lived under.

Several existing Haiku porting projects already require GCC4 to proceed and/or update to latest versions: Firefox 3, Webkit, VLC, and more.

Haiku already supports a "hybrid" environment where it is built with GCC2 for backward compatibility but also providing GCC4 libraries for future software support - or even more interesting: a GCC4-built Haiku with GCC2 libraries for backward compatibility. I think we'll see the latter becoming more common now with the availability of a native GCC4.

There are still some minor loose ends to tie up - such as providing the remaining development tools for a GCC4 Haiku (the GCC2-built ones will work, but they are not yet automatically installed with the "Development" optional package). Additionally, those who wish to build a GCC4 Haiku from within an existing GCC2-built Haiku might find it a little bit challenging. If you'd like to experiment, you may want to compile your own GCC4 Haiku from Linux, BSD, etc., or even wait for the availability of pre-built GCC4 images to appear.

These are very interesting developments, I hope you're as excited as I am at what the future holds :)

Comments

Re: Haiku Finally Gets a Native GCC4 - full story inside!

Don't forget about Boost ( used for Gnash ) :-)

Urias wrote:
"a GCC4-built Haiku with GCC2 libraries for backward compatibility."

I would prefer this too but the reason Haiku has stayed with gcc 2.95.3 was to avoid creating another set of libraries by going to gcc 4 for R1 because R2 will change the API.

gcc 4 R2 may require a 3rd set of libraries ( R1-gcc-4-compatible ) if R1 also uses gcc 4. Only reason why Haiku is still stuck using gcc 2.95. Kinda disappointing to be held back using a legacy compiler because of this.

At least now developers will have access to a gcc 4 development environment to make porting over their applications or games easier. This certainly will help getting new programs onto Haiku. Will still require building gcc 4 libraries though.

gcc 2.95 works pretty well for C programs but different story when it comes to newer/recent C++.

Re: Haiku Finally Gets a Native GCC4 - full story inside!

Not being a developer, I may be missing the finer points here...
Since there are hybrid builds containing both gcc2 and gcc4 libs, where's the problem? Devs can work in a gcc4-Haiku if they want/need to and won't have to care if R1 is gcc2 with additional gcc4 libs or vice versa. Or even gcc4-only.

Oh, yeah, and: Fantastic work, Michael!

Re: Haiku Finally Gets a Native GCC4 - full story inside!

***Awesome stuff!*** Great work, Michael!

This will really be a big help, imo. The 2.95 version of gcc has done sterling service, but let's face it - it is ancient now.

It is indeed time to leave it behind, so this is excellent news!
- latte

Re: Haiku Finally Gets a Native GCC4 - full story inside!

tonestone57 wrote:

I would prefer this too but the reason Haiku has stayed with gcc 2.95.3 was to avoid creating another set of libraries by going to gcc 4 for R1 because R2 will change the API.

gcc 4 R2 may require a 3rd set of libraries ( R1-gcc-4-compatible ) if R1 also uses gcc 4. Only reason why Haiku is still stuck using gcc 2.95. Kinda disappointing to be held back using a legacy compiler because of this.

Before this mis-informs people or causes any type of flames, this is the email thread from which nickos gathered his information : http://www.freelists.org/post/haiku-development/GCC-2-x-GCC-4

In it, Axel D states:

Quote:

Well, but that's exactly what we'll do for R2. Of course, while both
changes appear on the release, it doesn't mean we'll do it internally
at the same time.
The idea behind all this is not to break compatibility: GCC2 apps
compiled for Haiku R1 will run on Haiku R2. GCC4 apps for R2 will
instead use an updated API, because we can just introduce it this one
time without having to worry for any compatibility issues.
Only apps that used GCC4 for under R1 won't run under R2 - and since we
are telling this everyone, it shouldn't surprise anyone either. So only
apps that really require GCC4 should actually use it.

At some distant point in the future, we'll drop the R1 compatibility
libraries.

I implore people to read that email thread before coming to false conclusions.

Thanks

Re: Haiku Finally Gets a Native GCC4 - full story inside!

I decided not to list any reasons. Don't want this to turn into a flame discussion. Unofficial access to gcc4 development environment is good enough.

Axel may have made the right choice but doesn't mean everyone is going to be happy about it.

I'm glad to see Michael put the work into this and hopefully it gets more people involved. Maybe now we'll see some newer programs making it to Haiku. Not having gcc4 was scaring off developers and making it impossible to port over certain programs.

Re: Haiku Finally Gets a Native GCC4 - full story inside!

tonestone57 wrote:

gcc 4 R2 may require a 3rd set of libraries ( R1-gcc-4-compatible ) if R1 also uses gcc 4.

This is the center of your original comment that I feared to cause mis-information and I fear that you still do not understand this.

Here is a later email, specifically stating that Haiku R2 will not support GCC4 apps built in R1:
http://www.freelists.org/post/haiku-development/GCC-2-x-GCC-4,41

Quote:

For R2, the gcc2 libraries will just stay the same (but will of course
talk the current app_server/whatever protocol), while the gcc4
libraries will not only become the default, but will also break
compatibility with previous gcc4 libs.

While Axel is not the end-all-be-all to Haiku, his comments, suggestions, and ideas carry significantly more weight due to the sheer amount of time and effort he has placed into this project.

Re: Haiku Finally Gets a Native GCC4 - full story inside!

One thing I was wondering about was - are the nightly Haiku images built using gcc4 yet?

I'm very keen to try out a gcc4-built Haiku image, mainly to see how it compares performance-wise (Haiku is already very fast anyway!).
- latte

Re: Haiku Finally Gets a Native GCC4 - full story inside!

latte wrote:

One thing I was wondering about was - are the nightly Haiku images built using gcc4 yet?

Not yet, no. You'll either need to wait and see if these start appearing, or build your own :)

Re: Haiku Finally Gets a Native GCC4 - full story inside!

Ok - that's fine! Keep up the *great work!*
- latte

Re: Haiku Finally Gets a Native GCC4 - full story inside!

You guys are AWESOME! I am starting to drool at the thought of being able to use Haiku as my primary OS for daily use. When I can MPPE tunnel into a Microsoft network and attach to shares, I can ditch Windows and OS X forever. :)

Re: Haiku Finally Gets a Native GCC4 - full story inside!

Building your own image is really easy (at least under Linux). Have a look at the step-by-step guides.

About R2 breaking compatibility with gcc4 compiled R1 apps, I don't see a problem. It'll be a simple recompile. Also, I can imagine R2 breaking compatibility with R1 on a deeper level than compilation.

Re: Haiku Finally Gets a Native GCC4 - full story inside!

wow. this is absolutely paramount, and i am so glad to hear it! after all this time, a bunch of us wandering souls can return to haiku for our day-to-day development.

*hugs everybody in the room*

Re: Haiku Finally Gets a Native GCC4 - full story inside!

how hard would it be to port the stack overflow protection from BSD to haiku's GCC?

also I was reading about dragonfly BSD and they have implemented a scheduler that ties a thread to is processor so it is less likley to get interupted and switched to the other processor thus negating caching on the CPUs benefits not to mention the other overhead... seems like an ideal idea for haiku

Re: Haiku Finally Gets a Native GCC4 - full story inside!

These technical questions have a better chance to be answered on the main development mailing list.

André Braga supposedly has been working on a scheduler for the