On Wed, Mar 16, 2011 at 10:40 AM, Kai Ruottu <kai.ruottu@xxxxxxxxxxx> wrote: > 16.3.2011 11:15, David Paterson kirjoitti: >> >> On Wed, Mar 16, 2011 at 12:47 AM, Ian Lance Taylor<iant@xxxxxxxxxx> >> wrote: >>> >>> David Paterson<dnpaterson@xxxxxxxxx> writes: >>> >>>> Based on various examples of building cross systems around the net, I >>>> have a procedure where the compiler gets built twice, once as a basic >>>> version to allow building of Newlib, and then again as the full cross >>>> compiler version. Looking at the esamples, the first, basic, build >>>> always seems to use --without-headers (and --with-newlib). For the >>>> second build however, some sites have both of these again, while >>>> others have only --with-newlib, so I'm not sure whether I should >>>> include this option in my second stage build or not... >>>> >>>> A search turns up a few references to this option, but none of them >>>> say much beyond something along the lines of "leaving it out will >>>> disable some features". Does anybody have any thoughts on the wisdom >>>> or otherwise of using this option? >>> >>> --without-headers is the default, so it doesn't really matter whether >>> you specify it or not. >>> >>> Ian >> >> Ah, I didn't think to check the defaults... Thanks for the quick >> response Ian :-) > > Needing to build twice is of course also very weird suggestion :( > > Producing newlib-based GCCs for embedded systems from scratch has > succeeded in only one stage during the last 20 or so years, I > remember building my 1st one in early 1990's and then without any > know-how I maybe had to do more than one "iteration" :( Ah well, this is my first attempt, so I'm learning as I go :-) I found quite a few descriptions and examples on the net, but they all used a similar approach of building a basic "bootstrap" compiler, then Newlib, then the full compiler. My "configure" options choose only the C compiler in the first stage, and then both C and C++ in the second. Could I build both in the first stage, or even add others like Ada and Fortran? I thought until Newlib was built I couldn't create more than a basic C compiler... > (snip) .... Or the whole 'newlib' and 'libgloss' sources in the > main GCC source dir if wanting to build newlib at the same time > with the GCC... Then the whole GCC, C & C++ compilers, libgcc, > libstdc++ etc. will be built in only one build stage! Without or > with newlib... Ah - would I copy the Newlib sources into a specific location? Or just move the whole directory? > So I guess the instructions being written by newbies who have just > succeeded with their first crosstoolchain and want to share their > "know-how" with others. Not by people who have built 100's of > newlib-based crosstoolchains for some reasons, just-for-a-fun or > for more serious ones... There aren't actually a lot of examples or instructions around that I could find, and all of the ones I found ran a full "configure, make, install" sequence for both the bootstrap and final compiler builds. I'm sure that, as you say, there a lot of people building cross toolchains, for a lot of different systems, but the information is quite hard to find. I don't think I've seen one that does a single-stage approach as you describe. > The only thing hinting to a need to produce 'libstdc++' etc. after > having newlib built and installed is that the generic newlib headers > aren't the final ones. Here a diff made from the 'sparc-elf' case > during the newlib-1.13.0 time : > (snip) Interesting - I didn't realise this was happening. I'll spend a bit more time investigating and experimenting to see exactly what goes on during configuration and building of each of the components. > During my last 'sparc-elf' target build (just checking), I only > copied the generic newlib headers (with a single 'cp -r') and > built GCC, libgcc, libstdc++ etc. with only them... Building and > installing newlib would give the diff for the current situation > and if then rebuilding 'libgcc', 'libstdc++' again would tell > there being any difference to the "with bare generic headers" > results, maybe then there would be some idea in that 2-stage > process... > > So although the build with the generic newlib headers will work, > there is that suspect: "It cannot be this easy, something must > be wrong!". For the paranoids there are the steps : > > 1. build and install only GCC and libgcc > > 2. build and install newlib > > 3. continue the GCC build process via 'make ; make install' Hmmm, now one of the reasons I've followed the two stage approach is that I ran into a build problem doing something like this. After a bit of googling and experimenting, the solution appeared to be to delete everything in the build directory before rebuilding the compiler. (I can't remember exactly what the error was, but I can try to reproduce it if you're interested.) > But also these steps will produce the GCC only once, continuing > after a short coffee break for the paranoid's nerves... > > Of course if one puts the 'newlib' and 'libgloss' among the GCC > sources, then everything should appear during the first build > and be fully right! OK - I may try this, but as I mentioned above, which directory should I put the sources in? Thanks for the help and info Kai - very interesting stuff. My brain may melt by the end of this :-) And I'm still not sure exactly what "--without-headers" does, as I get different sized gcc.exe's with and without it, but both seem to work... David