4

I have successfully compiled gcc 7.2 from source on an x86_64. Native to native, so the resulting compiler is an x86_64 binary which works fine.

I would also like to have a working compiler for aarch64 (so, not a cross compiler. An aarch64 compiler binary producing aarch64 results.) This is where I'm stuck.

There's two options, a native-to-native compilation of gcc on the aarch64 host. This causes problems, and on top, is slow as mollasses, or a cross compilation of gcc on x86_64, resulting in an aarch64 compiler binary able to produce other aarch64 binaries.

I downloaded and unpacked gcc 7.2, and did the download_prerequisites step. Then I used the following configure:

../gcc-7.2.0/configure -v --build=x86_64-linux-gnu --host=x86_64-linux-gnu \
--target=x86_64-linux-gnu --prefix=/usr/local/gcc-7.2 \
--enable-checking=release --enable-languages=c,c++ --disable-multilib \
--program-suffix=-7.2

I suspect the --build, --host and --target are overkill in the native case, though. My question is now, what should I set these three to if I want to end up with the aarch64 compiler?

Down the line, I would also like an armv7l version. What would be the options for this?

bolind
  • 512
  • 3
  • 15
  • 1
    What you want to build (build=x86_64, host=aarch64, target=aarch64) is known as a Canadian Cross Compiler, and is notoriously tricky to put together. A full native (build=aarch64, host=aarch64, target=aarch64) compiler is much easier. You say this causes many problems, but I haven't encountered these. – James Greenhalgh Sep 18 '17 at 13:20
  • Thanks for your answer! Didn't know about the Canadian Cross Compiler. The reason why the native aarch64 build causes problems for me is a combination of permissions and execution speed/storage on the aarch64 machines, but I'll give that path another go. – bolind Sep 18 '17 at 18:00
  • You can set the prefix to any directory (outside of the source tree), which should help with your permissions problems. i.e. `--prefix=/path/you/can/write/to` . There's nothing I can do to boost the execution speed of your platform, but depending on how well-checked you need your compiler to be, you can skip bootstrap by configuring with `--disable-bootstrap` - that will cut the build time significantly. – James Greenhalgh Sep 19 '17 at 08:09
  • I'm now trying to build directly on the arm machine (a DragonBoard running Debian 9) and I'm encountering what looks to me like memory exhaustion. – bolind Sep 20 '17 at 07:08
  • That sounds a bit like this GCC bug https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81818 which has caused trouble for others trying to build on platforms with 1GB system memory. – James Greenhalgh Sep 20 '17 at 08:31
  • Just add some more swap, I built GCC 7.2 on a Raspberry Pi Zero (512MB), never a problem. The configure line for aarch64 (obviously for a cortex-a53 target) is ."./configure --enable-languages=c,c++ --with-cpu=cortex-a53" which works perfectly - built on the SBC itself. – Jeremy Nov 05 '17 at 10:20

0 Answers0