Hello,This is great news. However, I'm a bit concerned about the fact that you only talk about GCC2 and GCC4. What if the GCC boys decide to change name mangling again in, say 2 years from now? Will you add yet another directory with copies of the libraries? The same applies for other compilers. I have no problem with GCC, but I don't think it's a good idea to limit developers to one compiler.
Perhaps we can come up with a more general solution to this problem? It might take a larger effort, but it can probably save us a lot of trouble in the future.
I'm anything but an expert on compilers or OS design, but here's my view. I suppose GCC uses a function to mangle C++ names. Is it possible to have Haiku to do a 'translation' of mangled names between compiler naming schemes (is as much information in a GCC2 executable as there is in a GCC4 executable?)? An executable could include an indication of which name mangling scheme is used. The loader can then use this to translate the names.
Now I'm sure there are plenty of holes in this reasoning which I'm not aware of. But please do look at the larger picture.
Regards, BrechtPS. I bumped into the following a couple of days ago: http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/binary-formats.html. I thought this might be useful.
Michael Lotz wrote:
Hi everyoneThe 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. 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. So after all I came to the conclusion that there is no problem:http://haiku.mlotz.ch/gcc2and4.pngThis 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. So the logo problem was solved too and I could for example use both GCC2 and GCC4 compiled ShowImage to load some pictures.In the screenshot you can see various things to ensure that I didn't mess up the whole thing and accidently used the same compiler for both versions. First there are two AboutSystem apps open. One shows r22028 as it is the one compiled on Linux some time ago and the other shows r22046. So these two are definitely different applications. Then, knowing that gcc has the habit of embedding version information into application it compiles, I used DiskProbe to check each binary. You can see the lower DiskProbe showing the GCC 4.1.2 version and the upper one the (not completely up to date) GCC 2.95.3 of the actually installed image. Then there is BeBounce running with a binary compiled for R5 some years ago directly from unmodified sample code. In the background there is also a Terminal showing the "ps" output to proove that two versions of AboutSystem are running ("/boot/gcc4/AboutSystem" and "/ boot/beos/apps/AboutSystem" below). The only thing that is not true about the screenshot is the update of 2 hours, but I guess this comes from the QEMU emulation.Conclusion: there is no problem with using GCC2 and GCC4 compiled applications on the same system at the same time. You simply have to provide the libraries and add-ons for both versions. I have successfully tested all the GUI apps, the only thing that obviously does not work is using ProcessController, NetworkStatus and PowerStatus in replicant mode in the Deskbar, as the GCC2 compiled Deskbar cannot load the GCC4 binaries.Just as a heads up on that topic Michael