Mongo 6.x on raspberry PI 4 compilation

Good afternoon Mongo Grey Beards!

I am looking to compile the latest version of mongoDB for Raspberry pi 4 armv7.
I have custom compiled GCC 11.3 as Ubuntu 20.04 (WSL) does not meet the 11.3 minimum requirement for compilation.

I need to be able to pass the GCC binary directory to python as I opted not to overwrite my current GCC binary but install it to a different directory. However I am not sure how to do so.

I also don’t even know if 6.x support armv7 as a potential compilation target. From my google foo I have seen that 5.x is possible.

The end goal is to throw it into a docker container and use it for learning.
I am not an expert when it comes to compiling software by any means. This is a learning experience for me and I have set mongoDB in my sights as a learning experience. I am a network engineer by trade so please be gentle if I ask dumb questions.

–edit
Scrolling through the SConstruct file on github I don’t see any add_options or environment variables to specify a GCC binary location. It is looking more and more like I am going to be forced into overwriting my base GCC install which is undesired.

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!