Disable SIMD When Building Libopus from Source

This article provides a straightforward guide on how to forcefully disable all SIMD (Single Instruction, Multiple Data) optimizations—such as SSE, AVX, and ARM NEON—when compiling the libopus audio codec from source. Disabling these optimizations is often necessary for debugging, profiling baseline performance, or cross-compiling for legacy architectures that lack modern vector instructions. This guide covers how to achieve this using Autotools, CMake, and Meson build systems.


Why Disable SIMD in Libopus?

By default, the libopus build system automatically detects the host CPU capabilities and enables hardware-specific optimizations (like SSE/AVX on x86 or NEON on ARM) to speed up audio encoding and decoding. However, developers may need to disable these intrinsics to: * Debug compiler-related optimization bugs. * Compare pure C performance against vector-optimized assembly. * Create a highly compatible, generic binary that runs on any CPU within an architecture class.

Depending on the build system you are using to compile libopus, follow the respective instructions below.


Method 1: Using Autotools (./configure)

If you are using the traditional Autotools build system, you must pass specific flags to the configure script to disable compiler intrinsics and Run-Time CPU Detection (RTCD).

Run the following command in the root directory of the libopus source:

./configure --disable-intrinsics --disable-rtcd

After configuring, build and install as usual:

make
sudo make install

Method 2: Using CMake

For projects integrated with CMake, you can disable SIMD by passing defined variables to the configuration step. The key variable in libopus is OPUS_DISABLE_INTRINSICS.

To configure the build, run:

mkdir build && cd build
cmake -DOPUS_DISABLE_INTRINSICS=ON ..

This flag forces the CMake build configuration to completely bypass the detection and inclusion of any SIMD source files or compiler flags.

To build the project:

cmake --build .

Method 3: Using Meson

Modern versions of libopus support the Meson build system. To forcefully disable intrinsics and RTCD in Meson, use the -Dintrinsics and -Drtcd options.

Run the following commands:

meson setup builddir -Dintrinsics=disabled -Drtcd=disabled
ninja -C builddir

Setting intrinsics=disabled instructs Meson to compile using only standard, portable C code.