Brian Robert Callahan
academic, developer, with an eye towards a brighter techno-social life
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.
I had to incorporate some fixes to get it working.
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
:
#pragma GCC optimize ("O0")
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.
All I had to do was turn on building Phobos and DRuntime. No other changes were needed:
arm*-*-openbsd*) LIBPHOBOS_SUPPORTED=yes ;;
Of course, the real people to thank are the D team for having all the bits necessary for armv7 support already in-tree and ready to be used. I am just trying out what is already there and being happily suprised and then I can share packages with you to make your life easier.
If people want, I can toss a package up on GitHub. Let me know.
No one has offered me an account on a sparc64 machine, so mips64{,el} next I suppose.