Mongo 6.x on raspberry PI 4 compilation

Hello!

It looks like you’re on the right track. When you say you have custom compiled GCC, what do you mean by that? To build on WSL for the Pi you will need a cross-compiler toolchain - i.e. a compiler that runs on x86 but produces ARM binaries. You can use aarch64-linux-gnu-gcc for this, and it is distributed on Ubuntu 20.04’s package manager.

One point of clarification is that the Raspberry Pi 4 uses an ARMv8-A Cortex A72. I’m not aware of a Pi 4 that uses ARMv7.

In order to compile with SCons, you will need to point the build system to several necessary binaries:

  • Archiver: AR=/usr/bin/aarch64-linux-gnu-ar
  • C Compiler: CC=/usr/bin/aarch64-linux-gnu-gcc-${compiler_version}
  • C++ Compiler: CXX=/usr/bin/aarch64-linux-gnu-g++-${compiler_version}
  • C Compiler Flags: CCFLAGS="-march=armv8-a+crc -moutline-atomics -mtune=cortex-a72"

I would recommend building with GCC 9.4+ which will recognize the -moutline-atomics flag.

To cut to the chase, in my personal capacity I have compiled MongoDB from source and published the binaries on Github. I have similarly built a Docker container with these binaries here.

I hope this helps!