Fixing gcc-m68h1cx

Today, I spent all the day fixing gcc-m68hc1x. It is gcc built for cross-compiling to 68HC11 and 68HC12 microcontrollers. There was a strange bug: an ICE on 64-bit hosts. Actually the bug was there for a long time, but I had decided that the version currently in testing will be enough. However, yesterday a bug was filled as a package need to build it was not available anymore in testing.

So I started to try to debug it. It was the first time I was looking at gcc’s sources. Whow! I didn’t know were to start to find the bug. I asked on IRC on #gcc, but people were no encouraging me: “aurel32, that bug is not easy to tackle for newbies”. I first reduced the file causing the ICE to a single line in a function, I added a lot of printf in gcc’s sources, and then tried to compile the same testcase both on a 32-bit host and a 64-bit host. At the end of the day I found some differences, and with that, the bug!

As the ICE was triggered by the build of libgcc2, gcc-m68hc1x was unbuildable on 64-bit hosts. Now that this bug is fixed, it means one RC bug less.

And in short for any people writing code: please don’t assume that a 64-bit number needs two int to be represented!


Leave a Reply

Your email address will not be published.