GNU Toolchain hacking
I currently have access to a Intel Core Duo system with Darwin/OSX preinstalled. Having the power of two cores and a non GNU system installed I figured it is time to hack on OpenEmbedded’s support for non GNU hosts/build systems. The last time I tried this was on a G4 system and it failed miserable. It started to fail with quilt which was full of bashism and GNUism which forced me to fix the GNUism in patcher and to use that instead. It failed on flex-native, gcc, glibc, gcc (again), ipkg-native for many different reasons.
Thanks to the power of the two cores compiling, autoreconf and configure times are nice enough for the trial and error procedure. Also quilt has progressed into using less GNUism only requiring GNU sed and GNU getopt to be installed for almost working correctly. I have taken the quilt patch from fink to fix the remaining GNUism. Having quilt available is great as I will need to manage a lot of patches in the progress.
Fixing gcc was easy as well. It only has one conceptual misusage of autotools. Autoconf checks for the presence and usability of header files using CPP. In the case of gcc when building target libraries (e.g. target-libtsdc++ for arm-angstrom-linux) using /usr/bin/cpp to check for the presence of headers is not smart. e.g. libstdc++ found that I have a sys/filio.h header available. I have patched gcc 3.3,3.4,4.0,4.1 and 4.2 snapshots to use the just built compiler (xgcc) and use that as a preprocessor by adding the -E option. The result of this little patching is: The compilation of target libraries will never fail again because autoconf thinks certain features are available. This is good for people on BSD systems creating GNU toolchains and for uclibc people having less features enabled in their library. No more failing builds because host headers were used to determine target features.
Onto glibc. glibc is really mean as configure checks fail silently leading to later trouble. One big issue was the assumption of having binutils installed on my system. The configure check checked compiled bianries using ‘readelf’ to check for vertain features. I have arm-angstrong-linux-readelf installed on my system but no readelf and I won’t ever have one. The fix is easy as well. Use AC_CHECK_TARGET_TOOL([READELF], [readelf] [readelf], [$PATH]) and it will search for arm-angstrom-linux-readelf and will define $READELF within the configure. Now I will use $READELF wherever readelf was used before. Wow and now we have a compiling glibc on OSX. That was fairly easy. On FreeBSD we have one more issue as we will need to recompile the kernel to allow a large enough Command-Line.
Now I needed to introduce an evil hack into our gmp-native.bb for darwin. Apple’s gcc has certain issues with the assembly within the GNU mp code. Using none-apple-darwin as –host will force GNU mp to not use optimized but generic implementation of their tools.
And then we just compiled a full featured version of gcc 4.1.1 and it worked. At the end of the day we have a modern GNU toolchain on a non GNU system, sent patches upstream.
For the future we will fix the remaining GNUism within OpenEmbedded, make QtE and X11 cross compile nicely on OSX and we can create complete distributions on non GNU systems.