When I build MLIR with code instrumentation with the following cmd:
cmake -G Ninja ../llvm \ -DLLVM_ENABLE_PROJECTS=mlir \ -DLLVM_BUILD_EXAMPLES=ON \ -DLLVM_TARGETS_TO_BUILD="X86;NVPTX;AMDGPU" \ -DCMAKE_BUILD_TYPE=Release \ -DLLVM_ENABLE_ASSERTIONS=ON \ -DCMAKE_C_FLAGS="-g -O0 -fprofile-arcs -ftest-coverage" \ -DCMAKE_CXX_FLAGS="-g -O0 -fprofile-arcs -ftest-coverage" \ -DCMAKE_EXE_LINKER_FLAGS="-g -fprofile-arcs -ftest-coverage -lgcov"
I found the linking takes up all of my 128G RAM and requests a large amount of swap memory. If I limit the swap space to 1G, it will report
collect2: fatal error: ld terminated with signal 9 [Killed]
Extending the swap will solve this, however, using swap space makes the build process much slower, and I couldn’t do anything else since all the RAM are occupied.
Is it normal that a build with coverage instrumentation needs so much memory? How to reduce/limit the memory used?