I'd like to know whether binaries use (are compiled for) special instruction sets like SSE 4.1/4.2, AVX, F16C or not. How can I find out whether a binary in a package uses certain instruction sets?

I know that I may enable such instructions using configure switches when compiling packages by hand, but when using precompiled packages from the Debian repository there must be a default.

Probably binaries are not compiled with too specific instruction sets because they could not be used on any system or, depending on the binary, they are compiled with alternative subroutines that "emulate" the processing with basic instructions to support CPUs lacking such features.

I know that I could look into the rules file of a Debian source package but I'm interested if there's an easier way to do this.

  • Are the CPU instructions a x86-64 binary uses very limited?
  • May packages use quite specific instruction sets, may they have fallbacks using more primitive instructions?

To answer your question generally, https://superuser.com/questions/726395/how-to-check-if-a-binary-requires-sse4-or-avx-on-linux gives a script which can be fed a disassembled binary (the output of objdump) and will try to figure out the minimum required instruction set. This technique is necessarily approximate, since a given binary may have different execution paths depending on the available instruction set, and such a binary would appear to require the "best" instruction set it supports, even though it can actually run without it.

Specifically regarding Debian packages, anything packaged for amd64 (the 64-bit "PC" instruction set) must be able to run on any AMD64 or x86-64-compatible CPU; this means it can use the full standard 64-bit instruction set, which includes SSE2, but it can only use other features (including those you list) if it provides fallbacks for CPUs which don't support them. There are exceptions, but the packages should indicate that in the package description (see for example rr).

The Linux kernel itself can adapt its features to those of the CPU it finds itself running on. If it's compiled for x86-64, it assumes that it can use a TSC, CMPXCHG64, CMOV (look for anything that depends on X86_64 at that link). But it can be compiled to check at run-time whether such features as AES-NI, AVX, AVX2 are available, and use them in particular to accelerate crypto calculations. This may benefit any program using these features (at the cost of context switches into the kernel though).

In some cases the dynamic linker can also help provide alternatives depending on the CPU: thus libc6-i686 provides a set of libraries for the i386 architecture which will be used automatically instead of the bare-bones equivalents on CPUs compatible with the i686 instruction set (and supporting CMOV).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.