我一直在尝试为 Alpine Linux 3.19 编译 MongoDB 6.0.15,这非常具有挑战性,很大程度上是因为使用了 musl 而不是 libc。
面临的错误包括:
在 src/mongo/util/aligned.h 中: 代码
src/mongo/util/aligned.h:135:77: warning: use of 'std::hardware_destructive_interference_size' [-Winterference-size]
135 | using CacheAligned = Aligned<T, stdx::hardware_destructive_interference_size>;
Even when trying to pass the flags -mtune, -mcpu, or --param hardware_destructive_interference_size=64, the error still persists.
另一个阻碍我的错误是在编译 src/mongo/util/dns_query_posix_imp.h 时,我被告知没有引用 ‘res_nclose’、‘res_ninit’ 和 ‘res_nstatus’。我已经检查了该文件,它包含 resolv.h 的包含文件,我的系统中也有该文件。
我试过了
python3 buildscripts/scons.py DESTDIR=/usr/bin/mongod/ install-mongod CXXFLAGS="--param hardware_destructive_interference_size=64"
但是
(mongodb-src-r6.0.15) mongodb:~/mongodb-src-r6.0.15# python3 buildscripts/scons.py DESTDIR=/usr/bin/mongod/ install-mongod CXXFLAGS="--param hardware_destructive_interference_size=64"
Checking required python packages...
Requirements list:
Cheetah3<=3.2.6.post1
PyYAML==5.3.1
cryptography==2.3; platform_machine == "s390x" or platform_machine == "ppc64le"
cryptography==36.0.2; platform_machine != "s390x" and platform_machine != "ppc64le"
ninja>=1.10.0
packaging<=21.3
psutil<=5.8.0
pymongo<4.0,>=3.9
pypiwin32>=223; sys_platform == "win32" and python_version > "3"
pywin32>=225; sys_platform == "win32" and python_version > "3"
regex<=2021.11.10
requests<=2.26.0,>=2.0.0
requirements_parser<=0.3.1
setuptools
types-PyYAML~=6.0.5
Resolved to these distributions:
certifi 2024.2.2
cffi 1.16.0
charset-normalizer 2.0.12
cheetah3 3.2.6.post1
cryptography 36.0.2
idna 3.7
ninja 1.11.1.1
packaging 21.3
psutil 5.8.0
pycparser 2.22
pymongo 3.13.0
pyparsing 3.1.2
pyyaml 5.3.1
regex 2021.11.10
requests 2.26.0
requirements-parser 0.3.1
setuptools 65.5.0
types-pyyaml 6.0.12.20240311
types-setuptools 57.4.18
urllib3 1.26.18
scons: Reading SConscript files ...
scons: running with args /root/mongodb-src-r6.0.15/bin/python3 buildscripts/scons.py DESTDIR=/usr/bin/mongod/ install-mongod CXXFLAGS=--param hardware_destructive_interference_size=64
scons version: 3.1.2
python version: 3 10 14 'final' 0
CC is gcc
gcc found in $PATH at /usr/bin/gcc
CXX is g++
g++ found in $PATH at /usr/bin/g++
Checking if C++ compiler "g++" is GCC... no
Checking if C++ compiler "g++" is clang... no
Couldn't identify the C++ compiler
See /root/mongodb-src-r6.0.15/build/scons/config.log for details
您需要深入研究 SConstruct 和您的环境,以了解脱节是什么。构建系统无法使用 gcc 编译“简单文本文件”。从这里开始。 如果最终导致您的环境出现问题,您可以通过在 scons 调用中设置
CXX
来显式设置编译器路径。