[haiku-development] Re: GCC2 and GCC4 on same System

  • From: Ingo Weinhold <bonefish@xxxxxxxxxxxxxxx>
  • To: haiku-development@xxxxxxxxxxxxx
  • Date: Sun, 26 Aug 2007 14:53:55 +0200

On 2007-08-26 at 13:18:01 [+0200], Michael Lotz <mmlr@xxxxxxxx> wrote:
> 
> The recent discussion about providing a "hybrid" system where GCC2 and
> GCC4 compiled apps life side by side has made me think a bit. I looked
> at the "problem", but really didn't see it. I have thought about the
> app to kernel connection -> syscalls with a defined interface. I have
> thought about the app to app_server connection -> communication via
> ports with a defined protocol. I have thought about inter app
> communication -> messaging through ports and in defined BMessage
> format. Also the interface for sharing memory using areas is defined
> and should not depend on the compiler version.

The syscall and area interfaces wouldn't make a difference, the issue might 
be the structures you pass/share, e.g. alignment of members. While at least 
theoretically the C ABI should not have changed, I wouldn't bet important 
body parts on it. This is just something that has to be verified.

> I thought about the
> runtime_loader, but we use the same code for both, the GCC2 and the
> GCC4 compiled Haiku. So it actually has to understand both versions.

Sure, but the additional task for the runtime loader is what you have done 
manually by preparing a lib subdirectory for your gcc4 apps. It has to find 
out the compiler version of an executable to load and determine the 
respective library directories for it. We probably would create 
subdirectories like /boot/beos/system/lib/{gcc2,gcc4}, 
/boot/home/config/{gcc2,gcc4}, etc. Then we'd have to decide what to do 
about LIBRARY_PATH.

> So
> after all I came to the conclusion that there is no problem:
> 
> http://haiku.mlotz.ch/gcc2and4.png

Nice!

> This is a shot made from a QEMU instance running my nativly installed
> gcc 2.95.3 compiled Haiku. Additionally I have a Linux box where I
> compiled with the gcc 4.1.2 from the buildtools (btw. building gcc 4
> for BeOS and building a working image is possible with very few
> patches, but that's a different story). I have created a directory "/
> boot/gcc4" and put in the binaries from the GCC4 image in there. I have
> also added a "lib" dir there and moved all the GCC4 system libraries to
> that directory. Then I ran the AboutSystem application from this
> directory - it worked just the logo was not shown. So I've put in the
> GCC4 compiled translators to "/boot/home/config/add-ons/Translators".
> The runtime_loader now tries to load each of the translators in both
> the system and the config directory. Depending on which application you
> run (GCC2 or GCC4), one of both will generate errors, but it will still
> load everything that is necessary.

This is of course no solution for a production system. Not only is it quite 
ugly, but it might also happen that an add-on built with the wrong compiler 
might actually load and crash the app.

CU, Ingo

Other related posts: