Impossible to build MongoDB44 on FreeBSD 12.4?

From: Matthew Petach <mpetach_at_yahoo.com>
Date: Wed, 31 May 2023 00:07:47 UTC
Dear FreeBSD user community,
I'm really hoping someone here can help with a problem I've been wrestling with for two weeks now.I'm trying to build the net-mgmt/unifi7 package from the ports tree; one port it relies upon is MongoDB version 44, so I've been trying to build databases/mongodb44 with no success whatsoever.
This is on a box running 12.4-RELEASE-p2 btw:

mpetach@byakko:~ % uname -a

FreeBSD byakko.netflight.com 12.4-RELEASE-p2 FreeBSD 12.4-RELEASE-p2 NOE1000  amd64

mpetach@byakko:~ % 

Every time I try to build it, it runs for about 8 hours, and then dies with messages like this on theconsole:


Console:




FreeBSD/amd64 (byakko.netflight.com) (ttyu0)




login: 

May 29 00:30:46 byakko kernel: pid 7549 (ld.lld), jid 0, uid 0, was killed: out of swap space







FreeBSD/amd64 (byakko.netflight.com) (ttyu0)




login: 

May 29 09:27:03 byakko kernel: pid 14753 (ld.lld), jid 0, uid 0, was killed: out of swap space







FreeBSD/amd64 (byakko.netflight.com) (ttyu0)




login: May 29 23:33:18 byakko kernel: pid 22718 (ld.lld), jid 0, uid 0, was killed: out of swap space







FreeBSD/amd64 (byakko.netflight.com) (ttyu0)




login: May 30 03:31:42 byakko kernel: pid 28858 (ld.lld), jid 0, uid 0, was killed: out of swap space







FreeBSD/amd64 (byakko.netflight.com) (ttyu0)




login: 






Here's my build invocation with defines to ensure there's no parallel jobs running, to reduce stress on the memory subsytem:


root@byakko:/usr/ports/databases/mongodb44 # grep threads //tmp/tmpcc4a9nb4.lnk

root@byakko:/usr/ports/databases/mongodb44 # make -DMAKE_JOBS_UNSAFE=yes -DMAKE_JOBS_NUMBER=1

===>  Building for mongodb44-4.4.21

scons: Reading SConscript files ...

scons: running with args /usr/local/bin/python3.9 /usr/local/bin/scons-3.9 -j1 --use-system-zlib --use-system-pcre --use-system-snappy --libc++ --cxx-std=17 --runtime-hardening=on -j 1 --disable-warnings-as-errors VERBOSE=on AR=llvm-ar --lto=on --use-sasl-client --ssl CC=cc CCFLAGS=-O2 -pipe  -fstack-protector-strong -fno-strict-aliasing  CPPPATH=/usr/local/include CXX=c++ CXXFLAGS=-O2 -pipe -fstack-protector-strong -fno-strict-aliasing   LIBPATH=/usr/local/lib LINKFLAGS=  -fstack-protector-strong  PKGCONFIGDIR= PREFIX=/usr/local destdir=/usr/ports/databases/mongodb44/work/stage install-core

scons version: 4.4.0

python version: 3 9 16 'final' 0

CC is cc

cc found in $PATH at /usr/bin/cc

CXX is c++

c++ found in $PATH at /usr/bin/c++




(runs for about 8 hours, and then always dies with):







ve -Wl,--whole-archive build/59f4f0dd/third_party/libshim_allocator.a -Wl,--no-whole-archive build/59f4f0dd/mongo/util/libdebugger.a -Wl,--whole-archive build/59f4f0dd/mongo/stdx/libstdx.a -Wl,--no-whole-archive -Wl,--whole-archive build/59f4f0dd/mongo/libboost_assert_shim.a -Wl,--no-whole-archive -lcurl -lz -lsnappy -lsasl2 -lpcre -lpcrecpp -lkvm -lcrypto -lssl -lcrypto -lrt -ldl -lexecinfo

c++ @/tmp/tmpwc6osbzt.lnk

Killed

===> Compilation failed unexpectedly.

Try to set MAKE_JOBS_UNSAFE=yes and rebuild before reporting the failure to

the maintainer.

*** Error code 1




Stop.

make[1]: stopped in /usr/ports/databases/mongodb44

*** Error code 1




Stop.

make: stopped in /usr/ports/databases/mongodb44

root@byakko:/usr/ports/databases/mongodb44 # c++: error: unable to execute command: Killed

c++: error: linker command failed due to signal (use -v to see invocation)




root@byakko:/usr/ports/databases/mongodb44 # 




And again, right as it died, the console spat out two error messages:

May 30 16:33:56 byakko kernel: pid 31161 (ld.lld), jid 0, uid 0, was killed: out of swap space

May 30 16:33:58 byakko kernel: pid 30217 (python3.9), jid 0, uid 0, was killed: out of swap space






At the time it died, I was running vmstat -hw 1 and logging the memory

usage--here's what it look like when it died:







procs  memory       page                    disks     faults         cpu

r b w  avm   fre   flt  re  pi  po    fr   sr md4 ad0   in    sy    cs us sy id

0 0 11  16G   80M  6924 7276 2688  13 25857 724593 1648 2648 3820   113 15118  4 27 69

0 0 11  16G   75M  6845 3471 2784   0 27906 15576 1726 2623 3985   593 18455  3  6 90

0 0 11  16G   83M  6242 128 2669   0 32010 14914 1697 2531 3834   133 17819  4  8 88

0 0 11  16G   82M  5599  61 2527   0 30230 12027 1776 2489 3660   107 17376  3  5 92

0 0 11  16G   81M  6726 3170 1578 1846 20013 267394 2082 4470 5660    85 21183  2 27 70

1 0 11  16G   78M  5850 9395 2460   0 32265 478998 1768 2421 3591   193 17063  5  9 86

0 0 11  16G   84M  6896 2409 2235 496 32236 724599 1766 2901 4209   255 16832  3 29 68

0 0 11  16G   84M  4211 6289 2456   0 29245 43197 1776 2416 3595   111 17140  4 11 85

0 0 11  16G   82M  4042 9805 2472  50 28031 58306 1761 2489 3710   496 17438  4 13 83

0 0 13  16G   71M  4532 16101 2482   2 25507 699406 1709 2453 3621   112 14635  3 29 68

0 0 13  16G   52M  8126 7422 1058 2892 16068 102312 2218 5583 6785    78 27939  2 13 86

0 0 13  16G   59M   840 651 519 3409 10856 7563 2113 5994 7214   248 28604  0  9 90

0 0 13  16G   60M   601 593 409 1415  9700 21138 1010 2928 3685    79 14707  1  4 95

0 0 13  16G   61M    66   1   5  40   264 1259  24  76  167   218   568  0  0 100

0 0 13  16G   61M     1   0   1   0     0 1001   0   0   86    82   149  0  2 98

0 0 13  16G   61M    36   0   0   0     0 1073   0   0   59   157   223  0  0 100

1 0 12  15G   60M   108   0   2   6    26  863   9  29  307   433   354  0 15 85

0 0 7 524M  3.0G  1056   0 497 120 767921 5228 176 690 1876   383  3119  0 47 53

0 0 6 524M  3.0G    61   0   7   0    48    4   4   8   58    86   213  0  0 100

0 0 6 524M  3.0G    24   0   1   0     8    5   1   3   64   111   174  0  1 99







I don't know why the free list is so small; the machine has 40GB of swap,

so not even half of it was used (avm 16G) when the linker job was killed:




mpetach@byakko:~/suzaku-files % swapinfo -h

Device          1K-blocks     Used    Avail Capacity

/dev/ada0p2       4194304      32M     4.0G     1%

/dev/md4         37748736      14M      36G     0%

Total            41943040      46M      40G     0%

mpetach@byakko:~/suzaku-files % 






Does anyone have any advice on how I can get my build to complete?(note that the max RAM the box supports is 4GB, so saying "add more RAM" is pointless).
Thanks for any tips or hints you might be able to give me--this is getting really frustrating.
Thanks!
Matt Petach