GCC adventures

So there's been problems with gcc-4.0 on m68k for a while now, it producing segfaults and ICEs all the time, especially (though not exclusively) when compiling at -O3. I'm suspecting most of these issues (though probably not all of them) are really the same bug, which also happens to be fixed in upstream CVS. Unfortunately, since that upstream version has not been released yet, I can't just go ahead and suggest to our gcc maintainer to please package that one. Besides, I already know his answer:

sep 16 19:12:45 <doko>  Yoe: that's true, you have to package the
upstream version first. you're welcome :-)

... which doesn't sound very appealing to me; gcc is one hell of a package to maintain. All the more respect to Matthias Klose, of course.

So, I've been trying to find the fix to that bug that's been troubling us. Since I'm not very familiar with the gcc code myself, doing a diff between gcc-3.4 and gcc-4.0 (or even the gcc-4.0 source packages in Debian and the gcc upstream CVS) will not likely help me find the bug. The alternative is the reg_search script in the gcc source code, which will do a binary search through CVS versions until it finds you a small interval of two dates—one date with code that works, one with code that doesn't. In plain english: compile the compiler, test if it works; if it does, update the source to another version in one direction; if it doesn't, update in the other direction. Recompile, retest. Repeat until your interval is sufficiently small.

Since compiling one compiler on a 68040 takes, uh, "a while", I decided to do this using crosscompilers.

sigh

Turns out gcc expects you to build binutils with the same --prefix argument as the one you pass to the gcc configure script, and that the target-libc appears in that same prefix, too. Since I didn't feel like producing binutils, half a compiler, a cross-libc, and then a full compiler before being able to start this binary search, I tried to take a shortcut by using the excellent toolchain-source packages, which produces binutils and target-libc into /usr, through packages. My own gcc, then, built so that it would install into /opt/gcc-cvs, since I didn't want to pollute my /usr.

So, there. That didn't work. Took me almost all of today to track, even though I passed it /usr/m68k-linux as the position of the libc, and though the m68k cross-binutils were in my $PATH.

Morons.