building the toolchain in Gentoo
Up to Development Discussion
While the following instruction will only be of interest to gentoo or other users who have portage based build systems, some of the details here might help others building their toolchains from scratch.
Two issues:
1) the current version of gcc does not have proper thumb and interworking support
2) there is a circular dependency between gcc and newlib
#1) in order to get interworking and thumb support working on *any* gcc build, the t-arm-elf configuration file has to be updated. Fortunately the folks at gnuarm.org has one available for download (http://www.gnuarm.org/t-arm-elf). This has to update the one in the gcc source at build time.
#2) to build gcc your need the newlib headers, but to build newlib you need arm=elf-gcc... The trick is to first build gcc "--without-headers", build newlib, and then rebuild gcc. The first stage builds gcc without the newlib headers, building newlib will build from the bootstrapped gcc, and then the gcc rebuild builds in all the headers which apparently they think you need.
Now moving onto the Gentoo or portage/ebuild goodies.
there is a toolchains project called crossdev which will build if you do a little magic to first build the bootstrapped gcc and then rebuild:
first emerge crossdev
crossdev -t arm-elf --without-headers # build without newlibheaders
crossdev -s4 -t arm-elf # (re)build with newlib headers
Now you have a working arm-elf-gcc compiler! But wait -- because of the incorrect t-arm-elf configuration, this builds *without* thumb or interworking support. The current state of the firmware Makefiles *require* them. So, still no joy without seriously munging the Makefiles. this is why I would REALLY like Liam and Dave to integrate my changes to the Makefiles to support WITHOUT_THUMB, so broken compilers can run out of the box, but when you have thumb support you use it...
So how you can add thumb support.
First create a portage overlay for gcc. First add the t-arm-elf file mentiond above to the "files" directory. Now create a new gcc-*.ebuild whit the following three line addition at the bottom of the gcc-*.ebuild:
[[ ${CTARGET} == arm-* ]] && \
einfo "Patching t-arm-elf"; \
cp "${FILESDIR}/t-arm-elf" "${WORKDIR}/gcc-${PV}/gcc/config/arm/t-arm-elf";
Now run "ebuild gcc-*.ebuild digest" in the conventional manner.
rerun the crossdev commands above.
Ok... what just happened is that when crossdev builds the toolchain it will find the versions of gcc-*.ebuild you just added. It will then build an "arm-elf" compiler. As long as the the target compiler version is one that you just made a overload patch for, emerge will match the CTARGET and overwrite the t-arm-elf specification. After wating for maybe an hour for all the tools to build, you then have whatever version of arm-elf-gcc built with thumb and interworking support (at least on gentoo and other portage based systems). milage on other platforms will vary, but I bothered to explain what is going on so that people trying to build the toolchains on other distributions might get a leg-up on working around these issues.
enjoy!
EBo --
Just as a note, it's not just our Makefiles specifically that require Thumb code - the processor requires some code to be built as ARM and some as Thumb, so it's a baseline requirement to be able to use both.
Also, thanks for sharing your notes - might make a nice addition to the how-to section to be more easily found 

Powered by
Ploneboard

