The --dbg flag enables additional runtime checks within the server build, usually those deemed too expensive to be retained in a production build. It also enables the debugallocation subsystem of gperftools if you are building with the builtin version of that (which you are, by default), which catches some classes of memory use errors. One some platforms it may opt you into a debugging enabled C++ runtime. A build made with --dbg on is definitely not suitable for production use.
The --dbg flag does not, as is often and incorrectly assumed, have anything to do with whether we build with debugging symbols (e.g. the -g switch to GCC). We always build with debug symbols, and there is no switch to disable it. As a result, the binaries can be quite large. If you would like the binaries to be “production” sized like what you would get from our prebuilt packages, you can retain the debugging information as separated files by building with the --separate-debug flag. On non-windows paltforms, adding that flag will enable new installation and archiving targets with a -debug suffix which will install and archive just the debug symbols, respectively.
will get you two tgz files: one of debuginfo stripped server binaries, and another of the separated debug info for those binaries. Note that on windows, debug information is always separated into PDB files, so you don’t need to use the flag or the extra package name.
Oh, one more fun fact about the --dbg flag: when specified, it changes the build system default so as to disable compiler optimization in the interest of providing a better experience under debuggers. So if you are using the --dbg flag and you still want compiler optimization enabled, you need to explicitly opt in with --opt.
Basically, don’t use --dbg unless you are doing server development.
Thank you very much for the insight @Andrew_Morrow ! I was dealing with missing user stacks while doing off-CPU analysis on mongodb, I’ll see if the dbg flag will help me with that
MongoDB 6.0 is already compiling for FreeBSD, but it is segfaulting, maybe this will be also related to OpenBSD.
Maybe have a look here how mongodb 6.0 is build for FreeBSD: https://cgit.freebsd.org/ports/tree/databases/mongodb60