Brian Robert Callahan

submited by
Style Pass
2021-05-23 07:00:02

Following from our previous blog post, I ran a build of GDC on my BeagleBone Black, an OpenBSD/armv7 machine. Let's record the issues I had so that we can replicate things.

I began with my GDC for arm64. See this patch for my changes on top of a vanilla gcc git clone. Much like arm64, I also installed the g++ package to get access to gcc-8.4.0, which I used as my bootstrap compiler.

I used the same build script as arm64 that you can find in the previous blog post, with the exception of removing -j6 from the GMake invocation.

Like AArch64 support, ARM support for OpenBSD has not yet been upstreamed, so I needed to pull the analogous patches for armv7 from the ports tree. This was straightforward.

Unfortunately, gcc-8.4.0 crashed when trying to compile gimple-match.c. In my experience, this is the most difficult file during the build. It appears to be a bug in the optimizer on armv7 that is the culprit. I was able to work around this issue by leveraging a GCC extension. I added this line to the very top of gimple-match.c:

According to the GCC documentation, this #pragma "allows you to set global optimization options for functions defined later in the source file." I hear it is not quite the same as specifying -O0 on the command line but it is enough to not have GCC error out with the optimizer bug, so it is good enough for me. If I wanted to be a little better, I would find the function that was causing the optimizer bug and wrap only that function in this #pragma. Additionally, another page in the GCC documentation says about optimize: "The optimize attribute should be used for debugging purposes only. It is not suitable in production code." I very much do not care about this admonition. Do whatever works and makes you happy. This worked and I am happy.

Leave a Comment