From OSDev Wiki
Jump to: navigation, search

*-elf and --disable-hosted-libstdcxx are not compatible

After examining libsupc++ and attempting to build a freestanding libsupc++ for i586-elf using gcc 4.8.2, I must unfortunately announce that I have failed. It would appear that i586-elf is indeed [i]too[/i] freestanding for libsupc++, or rather the libstdc++-v3 build system. The configure script for libstdc++-v3 scans through headers such as <stdio.h> and searches for dlopen (and other things) in various system libraries, however, the configure script correctly recognizes it should not do such tests and simply decides to error out upon encountering this paradox. I was unable to work-around these issues, indeed the approach suggested by the older libstdc++ article appears to have bitrotted away. The --disable-hosted-libstdcxx configure option that was supposed to save the day only appears to work on actually hosted targets. I successfully used this --disable-hosted-libstdcxx option when targeting my native x86_64-linux-gnu platform and it actually only installed a libsupc++.a into the compiler prefix and only a small subset of freestanding C++ headers - so there's hope. After examining the libsupc++.a for x86_64-linux-gnu using nm(1), I saw a few references to libc (strcmp, malloc, free), a bunch of references to libgcc and a few problematic pthread_ calls. As a work-around you can probably use a i386 Linux libsupc++.a library in your kernel, but the pthread symbol references suggest you might be pulling in some bad Linux stuff.

Anyways, my recommendation is that you don't use libsupc++ and the provided C++ headers in a kernel built with i586-elf. You can probably get it working if you add a working libc into your system root, and you use an OS-Specific Toolchain that has a libstdc++-v3 port, and if you link your libc (a special kernel version) into your kernel. The real solution here is to get the GCC developers (or better yet - do it yourself) to fix --disable-hosted-libstdcxx not working properly on *-elf platforms. I might just look into this if I get some time, or perhaps just send a bug report to the GCC team.

I took the liberty of adding the disputed statement to this article because gcc 4.2 is ancient and the information is not reliable. Ideally, if we can get this working for i586-elf, we should merge this information into GCC Cross-Compiler. --Sortie 09:52, 4 November 2013 (CST)

Personal tools