mlx: error: "NEON intrinsics not available with the soft-float ABI. Please use -mfloat-abi=softfp or -mfloat-abi=hard"

When building the mlx project I’m getting an error in regards to : NEON intrinsics not available with the soft-float ABI Please use -mfloat-abi=softfp or -mfloat-abi=hard

ChatGPT suggests updating MakeFile with, but this doesn’t work

CFLAGS += -mfloat-abi=softfp 

or updating CMakeLists.txt (in project root) didn’t help either.

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mfloat-abi=softfp")

Steps to reproduce

git clone git@github.com:ml-explore/mlx.git mlx && cd mlx

mkdir -p build && cd build
cmake .. && make -j

throws

/Library/Developer/CommandLineTools/usr/lib/clang/15.0.0/include/arm_neon.h:28:2: error: "NEON intrinsics not available with the soft-float ABI. Please use -mfloat-abi=softfp or -mfloat-abi=hard"
#error "NEON intrinsics not available with the soft-float ABI. Please use -mfloat-abi=softfp or -mfloat-abi=hard"
 ^
/Users/stephan/projects/mlx/mlx/backend/accelerate/softmax.cpp:59:8: error: unknown type name 'float16x8_t'; did you mean 'float16_t'?
inline float16x8_t neon_fast_exp(float16x8_t x) {
       ^~~~~~~~~~~
       float16_t
/Users/stephan/projects/mlx/mlx/types/half_types.h:16:29: note: 'float16_t' declared here
typedef struct _MLX_Float16 float16_t;
                            ^
/Users/stephan/projects/mlx/mlx/backend/accelerate/softmax.cpp:59:34: error: unknown type name 'float16x8_t'; did you mean 'float16_t'?
inline float16x8_t neon_fast_exp(float16x8_t x) {
                                 ^~~~~~~~~~~
                                 float16_t
...

Apple M1 Max I’m on Sonoma 14.1.1 (23B81) cmake version 3.27.9 Python 3.10.5

About this issue

  • Original URL
  • State: open
  • Created 7 months ago
  • Comments: 17 (7 by maintainers)

Most upvoted comments

That’s probably the problem. It’s building for x86_64

-- Building METAL sources
-- Building with SDK for MacOS version 14.0

-- Building for processor x86_64
-- Accelerate found /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.0.sdk/System/Library/Frameworks/Accelerate.framework
CMake Deprecation Warning at build/_deps/doctest-src/CMakeLists.txt:1 (cmake_minimum_required):
  Compatibility with CMake < 3.5 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.


-- Configuring done (0.8s)
-- Generating done (0.0s)
-- Build files have been written to: /Users/fozziethebeat/devel/mlx/build
[  1%] Building gemv.air
[  2%] Building arange.air
[  3%] Building random.air
[  4%] Building gemm.air
[  5%] Building copy.air
[  8%] Building indexing.air
[  8%] Building unary.air
[  9%] Building softmax.air
[ 10%] Building sort.air
[ 11%] Building arg_reduce.air
[ 12%] Building binary.air
[ 13%] Building conv.air
[ 15%] Building reduce.air
[ 16%] Building scan.air
[ 17%] Building mlx.metallib
[ 17%] Built target mlx-metallib
[ 18%] Building CXX object CMakeFiles/mlx.dir/mlx/allocator.cpp.o
[ 19%] Building CXX object CMakeFiles/mlx.dir/mlx/device.cpp.o
[ 20%] Building CXX object CMakeFiles/mlx.dir/mlx/array.cpp.o
[ 22%] Building CXX object CMakeFiles/mlx.dir/mlx/fft.cpp.o
[ 23%] Building CXX object CMakeFiles/mlx.dir/mlx/random.cpp.o
[ 24%] Building CXX object CMakeFiles/mlx.dir/mlx/ops.cpp.o
[ 25%] Building CXX object CMakeFiles/mlx.dir/mlx/primitives.cpp.o
[ 26%] Building CXX object CMakeFiles/mlx.dir/mlx/dtype.cpp.o
[ 27%] Building CXX object CMakeFiles/mlx.dir/mlx/backend/common/arg_reduce.cpp.o
[ 29%] Building CXX object CMakeFiles/mlx.dir/mlx/graph_utils.cpp.o
[ 30%] Building CXX object CMakeFiles/mlx.dir/mlx/load.cpp.o
[ 31%] Building CXX object CMakeFiles/mlx.dir/mlx/scheduler.cpp.o
[ 32%] Building CXX object CMakeFiles/mlx.dir/mlx/transforms.cpp.o
[ 33%] Building CXX object CMakeFiles/mlx.dir/mlx/backend/common/erf.cpp.o
[ 34%] Building CXX object CMakeFiles/mlx.dir/mlx/utils.cpp.o
[ 36%] Building CXX object CMakeFiles/mlx.dir/mlx/backend/common/copy.cpp.o
[ 37%] Building CXX object CMakeFiles/mlx.dir/mlx/backend/common/conv.cpp.o
[ 39%] Building CXX object CMakeFiles/mlx.dir/mlx/backend/common/reduce.cpp.o
[ 40%] Building CXX object CMakeFiles/mlx.dir/mlx/backend/common/binary.cpp.o
[ 41%] Building CXX object CMakeFiles/mlx.dir/mlx/backend/common/scan.cpp.o
[ 41%] Building CXX object CMakeFiles/mlx.dir/mlx/backend/common/fft.cpp.o
[ 43%] Building CXX object CMakeFiles/mlx.dir/mlx/backend/common/indexing.cpp.o
[ 44%] Building CXX object CMakeFiles/mlx.dir/mlx/backend/common/load.cpp.o
[ 45%] Building CXX object CMakeFiles/mlx.dir/mlx/backend/common/softmax.cpp.o
[ 46%] Building CXX object CMakeFiles/mlx.dir/mlx/backend/common/primitives.cpp.o
[ 47%] Building CXX object CMakeFiles/mlx.dir/mlx/backend/common/threefry.cpp.o
[ 50%] Building CXX object CMakeFiles/mlx.dir/mlx/backend/accelerate/matmul.cpp.o
[ 48%] Building CXX object CMakeFiles/mlx.dir/mlx/backend/accelerate/conv.cpp.o
[ 51%] Building CXX object CMakeFiles/mlx.dir/mlx/backend/accelerate/primitives.cpp.o
[ 52%] Building CXX object CMakeFiles/mlx.dir/mlx/backend/common/sort.cpp.o
[ 54%] Building CXX object CMakeFiles/mlx.dir/mlx/backend/metal/conv.cpp.o
[ 55%] Building CXX object CMakeFiles/mlx.dir/mlx/backend/metal/copy.cpp.o
[ 55%] Building CXX object CMakeFiles/mlx.dir/mlx/backend/accelerate/reduce.cpp.o
[ 56%] Building CXX object CMakeFiles/mlx.dir/mlx/backend/metal/allocator.cpp.o
[ 58%] Building CXX object CMakeFiles/mlx.dir/mlx/backend/metal/fft.cpp.o
[ 59%] Building CXX object CMakeFiles/mlx.dir/mlx/backend/metal/scan.cpp.o
[ 60%] Building CXX object CMakeFiles/mlx.dir/mlx/backend/accelerate/softmax.cpp.o
[ 61%] Building CXX object CMakeFiles/mlx.dir/mlx/backend/metal/primitives.cpp.o
[ 62%] Building CXX object CMakeFiles/mlx.dir/mlx/backend/metal/reduce.cpp.o
[ 63%] Building CXX object CMakeFiles/mlx.dir/mlx/backend/metal/metal.cpp.o
[ 65%] Building CXX object CMakeFiles/mlx.dir/mlx/backend/metal/indexing.cpp.o
[ 66%] Building CXX object CMakeFiles/mlx.dir/mlx/backend/metal/matmul.cpp.o
[ 67%] Building CXX object CMakeFiles/mlx.dir/mlx/backend/metal/sort.cpp.o
[ 68%] Building CXX object CMakeFiles/mlx.dir/mlx/backend/metal/device.cpp.o
[ 69%] Building CXX object CMakeFiles/mlx.dir/mlx/backend/metal/softmax.cpp.o
In file included from /Users/fozziethebeat/devel/mlx/mlx/backend/accelerate/softmax.cpp:6:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/15.0.0/include/arm_neon.h:28:2: error: "NEON intrinsics not available with the soft-float ABI. Please use -mfloat-abi=softfp or -mfloat-abi=hard"
#error "NEON intrinsics not available with the soft-float ABI. Please use -mfloat-abi=softfp or -mfloat-abi=hard"
 ^
/Users/fozziethebeat/devel/mlx/mlx/backend/accelerate/softmax.cpp:59:8: error: unknown type name 'float16x8_t'; did you mean 'float16_t'?
inline float16x8_t neon_fast_exp(float16x8_t x) {
       ^~~~~~~~~~~
       float16_t
/Users/fozziethebeat/devel/mlx/mlx/types/half_types.h:16:29: note: 'float16_t' declared here
typedef struct _MLX_Float16 float16_t;
                            ^
/Users/fozziethebeat/devel/mlx/mlx/backend/accelerate/softmax.cpp:59:34: error: unknown type name 'float16x8_t'; did you mean 'float16_t'?
inline float16x8_t neon_fast_exp(float16x8_t x) {
                                 ^~~~~~~~~~~
                                 float16_t
/Users/fozziethebeat/devel/mlx/mlx/types/half_types.h:16:29: note: 'float16_t' declared here
typedef struct _MLX_Float16 float16_t;
                            ^
/Users/fozziethebeat/devel/mlx/mlx/backend/accelerate/softmax.cpp:60:20: error: use of undeclared identifier 'vdupq_n_f16'
  x = vmulq_f16(x, vdupq_n_f16(1.442695)); // multiply with log_2(e)
                   ^
/Users/fozziethebeat/devel/mlx/mlx/backend/accelerate/softmax.cpp:61:20: error: use of undeclared identifier 'vdupq_n_f16'
  x = vmaxq_f16(x, vdupq_n_f16(-14)); // clamp under with -14
                   ^
/Users/fozziethebeat/devel/mlx/mlx/backend/accelerate/softmax.cpp:62:20: error: use of undeclared identifier 'vdupq_n_f16'
  x = vminq_f16(x, vdupq_n_f16(14)); // clamp over with 14
                   ^
/Users/fozziethebeat/devel/mlx/mlx/backend/accelerate/softmax.cpp:64:3: error: unknown type name 'float16x8_t'; did you mean 'float16_t'?
  float16x8_t ipart = vrndmq_f16(vaddq_f16(x, vdupq_n_f16(0.5)));
  ^~~~~~~~~~~
  float16_t
/Users/fozziethebeat/devel/mlx/mlx/types/half_types.h:16:29: note: 'float16_t' declared here
typedef struct _MLX_Float16 float16_t;
                            ^
/Users/fozziethebeat/devel/mlx/mlx/backend/accelerate/softmax.cpp:64:47: error: use of undeclared identifier 'vdupq_n_f16'
  float16x8_t ipart = vrndmq_f16(vaddq_f16(x, vdupq_n_f16(0.5)));
                                              ^
/Users/fozziethebeat/devel/mlx/mlx/backend/accelerate/softmax.cpp:65:3: error: unknown type name 'float16x8_t'; did you mean 'float16_t'?
  float16x8_t fpart = vsubq_f16(x, ipart);
  ^~~~~~~~~~~
  float16_t
/Users/fozziethebeat/devel/mlx/mlx/types/half_types.h:16:29: note: 'float16_t' declared here
typedef struct _MLX_Float16 float16_t;
                            ^
/Users/fozziethebeat/devel/mlx/mlx/backend/accelerate/softmax.cpp:65:23: error: use of undeclared identifier 'vsubq_f16'
  float16x8_t fpart = vsubq_f16(x, ipart);
                      ^
/Users/fozziethebeat/devel/mlx/mlx/backend/accelerate/softmax.cpp:67:7: error: use of undeclared identifier 'vdupq_n_f16'
  x = vdupq_n_f16(1.535336188319500e-4f);
      ^
/Users/fozziethebeat/devel/mlx/mlx/backend/accelerate/softmax.cpp:68:17: error: use of undeclared identifier 'vdupq_n_f16'
  x = vfmaq_f16(vdupq_n_f16(1.339887440266574e-3f), x, fpart);
                ^
/Users/fozziethebeat/devel/mlx/mlx/backend/accelerate/softmax.cpp:69:17: error: use of undeclared identifier 'vdupq_n_f16'
  x = vfmaq_f16(vdupq_n_f16(1.339887440266574e-3f), x, fpart);
                ^
/Users/fozziethebeat/devel/mlx/mlx/backend/accelerate/softmax.cpp:70:17: error: use of undeclared identifier 'vdupq_n_f16'
  x = vfmaq_f16(vdupq_n_f16(9.618437357674640e-3f), x, fpart);
                ^
/Users/fozziethebeat/devel/mlx/mlx/backend/accelerate/softmax.cpp:71:17: error: use of undeclared identifier 'vdupq_n_f16'
  x = vfmaq_f16(vdupq_n_f16(5.550332471162809e-2f), x, fpart);
                ^
/Users/fozziethebeat/devel/mlx/mlx/backend/accelerate/softmax.cpp:72:17: error: use of undeclared identifier 'vdupq_n_f16'
  x = vfmaq_f16(vdupq_n_f16(2.402264791363012e-1f), x, fpart);
                ^
/Users/fozziethebeat/devel/mlx/mlx/backend/accelerate/softmax.cpp:73:17: error: use of undeclared identifier 'vdupq_n_f16'
  x = vfmaq_f16(vdupq_n_f16(6.931472028550421e-1f), x, fpart);
                ^
/Users/fozziethebeat/devel/mlx/mlx/backend/accelerate/softmax.cpp:74:17: error: use of undeclared identifier 'vdupq_n_f16'
  x = vfmaq_f16(vdupq_n_f16(1.000000000000000f), x, fpart);
                ^
/Users/fozziethebeat/devel/mlx/mlx/backend/accelerate/softmax.cpp:78:3: error: unknown type name 'int16x8_t'; did you mean 'int16_t'?
  int16x8_t epart = vcvtq_s16_f16(ipart);
  ^~~~~~~~~
  int16_t
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.0.sdk/usr/include/sys/_types/_int16_t.h:30:33: note: 'int16_t' declared here
typedef short                   int16_t;
                                ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
make[2]: *** [CMakeFiles/mlx.dir/mlx/backend/accelerate/softmax.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[1]: *** [CMakeFiles/mlx.dir/all] Error 2

Sorry closed this prematurely, reopened.

Please reopen if this is still unresolved.

I can confirm it’s fine to build on M1 Mac (Ventura 13.4) @jagrit06 . I built here on M1 Air with cmake version 3.27.4, Python 3.10.13 (and xcode and command line tools installed). So it’s totally possible @stephanj