#2716·folly

macOS x86_64 build fails in MathOperation_Simple.cpp because -mno-sse2 conflicts with SDK _Float16 declarations

Author: kupsonCreated Sep 30, 2026Updated Sep 30, 2026

Environment

  • macOS 26.7 x86_64
  • Apple clang 21.0.0 (clang-2100.1.1.101), target x86_64-apple-darwin25.6.0
  • Xcode 26.6 (build 17F113)
  • macOS SDK 26.5

Problem

The build fails while compiling MathOperation_Simple.cpp.

Clang does not support _Float16 on x86 when SSE2 is disabled. This conflicts with the _Float16 declarations in the macOS SDK headers when this compilation unit is built with -mno-sse2.

/Library/Developer/CommandLineTools/SDKs/MacOSX26.sdk/usr/include/math.h:652:8: error: _Float16 is not supported on this target
  652 | extern _Float16 __truncf16(_Float16) __API_AVAILABLE(macos(15.0), ios(18.0), watchos(11.0), tvos(18.0));
      |        ^

Minimal repro

Without disabling SSE2:

$ printf '#include <math.h>\nint main(void){return 0;}\n' |
  xcrun clang -arch x86_64 -x c -c -o /dev/null - ; echo $?
0

Error when SSE2 is disabled:

$ printf '#include <math.h>\nint main(void){return 0;}\n' |
  xcrun clang -arch x86_64 -mno-sse2 -ferror-limit=1 -x c -c -o /dev/null - ; echo $?
In file included from <stdin>:1:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/math.h:645:27: error: _Float16 is not supported on this target
  645 | extern _Float16 __fabsf16(_Float16) __API_AVAILABLE(macos(15.0), ios(18.0), watchos(11.0), tvos(18.0));
      |                           ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
2 errors generated.
1

Possible fix

On Intel macOS, replacing -mno-sse2 with:

-fno-vectorize -fno-slp-vectorize

while retaining the existing -mno-avx -mno-avx2 flags makes the build succeed for me.

I am not sure whether this preserves the exact invariant intended by -mno-sse2, since I do not know whether this compilation unit merely needs to avoid auto-vectorization or must contain no SSE2 instructions at all.