The instructions for v4.4 would be very similar, so I’m just manually making adjustments here and apologies in advance for any errors, but the cross build would look like:
sudo apt-get install gcc-8-aarch64-linux-gnu g++-8-aarch64-linux-gnu
$ sudo dpkg --add-architecture arm64
$ sudo apt-get update
$ sudo apt-get install libssl-dev:arm64 libcurl4-openssl-dev:arm64
$ git clone -b r4.4.0 https://github.com/mongodb/mongo.git
$ cd mongo
# Consider using a virtualenv for this
$ python3 -m pip install --user -r etc/pip/compile-requirements.txt
$ python3 buildscripts/scons.py --ssl CC=/usr/bin/aarch64-linux-gnu-gcc-8 CXX=/usr/bin/aarch64-linux-gnu-g++-8 CCFLAGS="-march=armv8-a+crc -mtune=cortex-a72" --install-mode=hygienic --install-action=hardlink --separate-debug archive-core{,-debug}
And the native build would look like:
sudo apt-get install gcc-8 g++-8
$ sudo apt-get install libssl-dev libcurl4-openssl-dev
$ git clone -b r4.4.0 https://github.com/mongodb/mongo.git
$ cd mongo
# Consider using a virtualenv for this
$ python3 -m pip install --user -r etc/pip/compile-requirements.txt
$ python3 buildscripts/scons.py --ssl CC=gcc-8 CXX=g++-8 CCFLAGS="-march=armv8-a+crc -mtune=cortex-a72" --install-mode=hygienic --install-action=hardlink --separate-debug archive-core{,-debug}
The only real changes here in, in both cases, are to the build system flags on the last step. The new flags are as follows:
-
--install-mode=hygienic
: Uses an autoconf like layout. You can control where files are installed to with theDESTDIR
andPREFIX
arguments to SCons. Soscons ... DESTDIR=$HOME/tmp PREFIX=/usr/local ...
would do what you expect. -
--install-action=hardlink
: Uses hardlinks when installing files toDESTDIR/PREFIX
to avoid extra time spent copying. -
--separate-debug
: Enables automatically stripping debug information out into separate.debug
files and packaging them into-debug
tarballs.
Then the new target names archive-core
and archive-core-debug
will produce tgz
files under the build
directory containing the server and shell binaries and .debug
files respectively. There are several different targets depending on what you want to build. Generally, they look like [install|archive]-x[-debug]
for x
in shell
(the mongo shell), mongod
(just the mongod
server), mongos
(just the mongos
server), servers
(both mongod
and mongos
), and core
(servers
and shell
).
Regarding binary size, the binary packages probably aren’t that large, but the debug info packages can be several gigabytes. So you are going to need some space, probably 10-20 GB for the whole build. This is one of the reasons I’m suggesting a cross build might be a good idea.
You could also experiment with the --link-model=dynamic
flag which might result in a somewhat smaller footprint. Note that builds made with this flag are not production quality - they are primarily used for testing. But Debian 10 ARM / RPi4 isn’t a supported platform anyway.