Error compiling / building MongoDB 6.0.15 Alpine Linux 3.19

Hello everyone, I’ve been trying to compile MongoDB 6.0.15 for Alpine Linux 3.19, and it’s been quite challenging, largely due to the use of musl instead of libc.

Among the errors faced are:

  1. In 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.

  1. Another error that has been hindering me is when compiling src/mongo/util/dns_query_posix_imp.h, I am informed that ‘res_nclose’, ‘res_ninit’, and ‘res_nstatus’ are not referenced. I have checked the file, and it contains the include for resolv.h, which I also have in my system.