§2025-04-27
- requirements
sudo apt-get install build-essential libcurl4-openssl-dev git
- git clone
(PyTorch) alexlai@AgxOrin:~/build$ pwd
/home/alexlai/build
$ git clone https://github.com/mongodb/mongo.git
- build
If I
git checkout to other branch
it seems will fail! I have to work onmaster branch
$ cd mongo
$ python buildscripts/install_bazel.py # <- at master branch
Downloading bazelisk...
Downloaded bazelisk to /home/alexlai/.local/bin/bazelisk
Symlinked bazel to /home/alexlai/.local/bin/bazel
(PyTorch) alexlai@AgxOrin:~/build/mongo$ which bazel
/home/alexlai/.local/bin/bazel
$ echo $PATH
/home/alexlai/.local/bin:/home/alexlai/.local/bin:/home/alexlai/anaconda3/envs/PyTorch/bin:/home/alexlai/anaconda3/condabin:/usr/local/cuda-12.6/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
1st trial without log and from my Mac
$ bazel build install-mongod --cxxopt='-Wno-error' --remote_executor= --remote_cache=
or,
- it's compiled OK, but binary will failed on odroid-N2 with illegal instruction
$ bazel build install-mongod --cxxopt='-Wno-error'
- still not for odrpid-n2
bazel build install-mongod \
--cxxopt='-Wno-error' \
--cxxopt='-march=armv8-a' \
--cxxopt='-mtune=cortex-a73' \
--conlyopt='-march=armv8-a' \
--conlyopt='-mtune=cortex-a73'
- odroid-N2
– Maximum CPU clock of Quad-core Cortex-A73 is increased to 2.4Ghz from 1.8Ghz.
– Maximum CPU clock of Dual-core Cortex-A53 is increased to 2.0Ghz from 1.9Ghz.
- the followings still illegal instructions on odroid-N2
bazel build //src/mongo/db/mongod:install-mongod \
--cxxopt='-march=armv8-a+crc' \
--cxxopt='-mtune=cortex-a53' \
--conlyopt='-march=armv8-a+crc' \
--conlyopt='-mtune=cortex-a53' \
--cxxopt='-g' \
--strip=never
The build system will produce an installation tree into bazel-bin/install, as well individual install target trees like bazel-bin/
bazel build install-mongod \
--cxxopt='-march=armv8.2-a+crc+crypto' \
--cxxopt='-mtune=cortex-a73' \
--conlyopt='-march=armv8.2-a+crc+crypto' \
--conlyopt='-mtune=cortex-a73' \
--cxxopt='-g' \
--strip=never
Starting in MongoDB 8.0, MongoDB uses an upgraded version of TCMalloc that uses per-CPU caches, instead of per-thread caches, to reduce memory fragmentation and make your database more resilient to high-stress workloads.
- 1: Disable tcmalloc, MongoDB can be built without tcmalloc using this flag:
- --use-system-allocator
bazel build install-mongod \
--cxxopt='-mcpu=cortex-a73' \
--conlyopt='-mcpu=cortex-a73' \
--copt='-DUSE_SYSTEM_ALLOCATOR=1' \
--define=use_system_allocator=true \
--strip=never
```
Workaround 2: Rebuild tcmalloc With Safe Flags
If you need tcmalloc (for performance), you must force Bazel to build that target with conservative flags:
Use --per_file_copt to apply stricter flags just to tcmalloc.
Example:
--per_file_copt=src/third_party/tcmalloc/.*@-mcpu=cortex-a73
```
scp Agxorin.yushei.net://home/alexlai/build/mongo//bazel-bin/install/bin/mongod ./
```
2025-04-28
```
bazel clean --expunge --async
rm -rf bazel-out/*/bin/src/third_party/tcmalloc
```
bazel build install-mongod \
--cxxopt='-mcpu=cortex-a73' \
--conlyopt='-mcpu=cortex-a73' \
--copt='-march=armv8-a' \
--copt='-DUSE_SYSTEM_ALLOCATOR=1' \
--define=use_system_allocator=true \
--define=allocator=system \
--define=tcmalloc=disabled \
--define=jemalloc=disabled \
--linkopt='-Wl,--no-as-needed' \
--strip=never
```
```
bazel build install-mongod \
--define=tcmalloc=disabled \
--define=jemalloc=disabled \
--linkopt='-Wl,--no-as-needed' \
--strip=never
```
```
bazel build install-mongod \
--cpu=arm64 \
--copt="-march=armv8-a" \
--copt="-mtune=cortex-a53" \
--define=tcmalloc=disabled \
--define=jemalloc=disabled \
--linkopt='-Wl,--no-as-needed' \
--strip=never
```
----
Ask deepSeek
```
bazel build --config=opt --define=use_tcmalloc=false //src/mongo/tools/installer:install-mongod
```
---
$para:2025-04-29
All the above failed to generate one for odroid-N2
- odroid-N2
– Maximum CPU clock of Quad-core Cortex-A73 is increased to 2.4Ghz from 1.8Ghz.
– Maximum CPU clock of Dual-core Cortex-A53 is increased to 2.0Ghz from 1.9Ghz.
(nnn/ 7,299)
```
bazel build \
--config=opt \
--define=use_tcmalloc=false \
--cpu=arm64 \
--crosstool_top=@bazel_tools//tools/cpp:toolchain \
--host_crosstool_top=@bazel_tools//tools/cpp:toolchain \
--copt=-march=armv8-a \
--copt=-mcpu=cortex-a73 \
--copt=-mno-outline-atomics \
--cxxopt=-march=armv8-a \
--cxxopt=-mcpu=cortex-a73 \
--cxxopt=-mno-outline-atomics \
--cxxopt=-Wno-error \
--linkopt=-latomic \
--disable_warnings_as_errors=True \
install-mongod
```