Search code examples
c++xcodex86-64simdintrinsics

Xcode in release mode fails to compile <immintrin.h> - complains about __builtin_ia32_emms()


I'm very new to Xcode, and developing SIMD(SSE/AVX) codes for macOS with Xcode 12.4 (12D4e) on macOS Catalina 10.15.7.
This very simple code can be compiled in Debug scheme:

#include <immintrin.h>

int main(int argc, const char * argv[]) {
    return 0;
}

But in Release Scheme, the header makes error: "Too few arguments to function call, expected 2, have 0" for this line of "mmintrin.h".

    __builtin_ia32_emms();

What can I do to compile it in Release scheme?


Solution

  • If you have any Intel-specific code (such as Intel intrinsics) then you need to make sure that your Release build is set for x86-64 architecture only. In Xcode 12 the default is to build for both x86-64 and Apple Silicon in the Release build, which results in spurious error messages when Intel intrinsics are encountered in the Apple Silicon part of the build.