#2709·folly

Building folly on low-memory arm64 systems suffers high memory pressure due to  -g  in default Release CXX flags

Author: 1234562026Created Sep 22, 2026Updated Sep 30, 2026

Problem

Folly's default CMAKE_CXX_FLAGS_RELEASE includes -g debug symbols. This greatly increases object file size and memory consumption during compilation.

On low-memory arm64 environments such as:

  1. Termux running on mobile ARM64 phones
  2. FreeBSD arm64 package build servers

The huge memory footprint brings a high risk of OOM killer terminating compiler jobs in the middle of building. This failure case has already been observed on FreeBSD's official package builder for folly.

Reproduction

Build folly on low RAM arm64, using default CMAKE_BUILD_TYPE=Release. The generated compile command contains -O3 -DNDEBUG -g. During compilation, the peak memory usage rises sharply, and the build process gets killed by OOM once exceeding available RAM.

Suggestion

Add an optional CMake toggle (e.g. FOLLY_RELEASE_WITH_DEBUG_SYMBOLS) to control whether -g is added in Release builds. Meta's server use case can keep -g enabled by default, while embedded / low-memory users can turn it off.

Current Workaround

Override CMAKE_CXX_FLAGS_RELEASE manually when configuring: -DCMAKE_CXX_FLAGS_RELEASE="-O3 -DNDEBUG" This removes -g, shrinks object file size and lowers peak memory pressure to avoid OOM.