Skip to content

Can't build whisper.cpp on macOS m1 #50

Open
@thewh1teagle

Description

@thewh1teagle

I hope it's relevant and not an issue in whisper.cpp.

I'm trying to cross compile whisper.cpp as following:

brew tap messense/macos-cross-toolchains
brew install aarch64-unknown-linux-gnu

cd /tmp
rm -rf whisper.cpp
git clone https://github.com/ggerganov/whisper.cpp -b v1.7.3 --depth 1
cd whisper.cpp
cmake -B build -G Ninja \
  -DCMAKE_SYSTEM_NAME=Linux \
  -DCMAKE_SYSTEM_PROCESSOR=aarch64 \
  -DCMAKE_C_COMPILER=aarch64-linux-gnu-gcc \
  -DCMAKE_CXX_COMPILER=aarch64-linux-gnu-g++ \
  -DCMAKE_AR=aarch64-linux-gnu-ar \
  -DCMAKE_LINKER=aarch64-linux-gnu-gcc \
  -DCMAKE_SYSROOT=/opt/homebrew/Cellar/aarch64-unknown-linux-gnu/13.3.0/toolchain/aarch64-unknown-linux-gnu/sysroot

cmake --build build --config release --target main

But it failed with this error:

brew tap messense/macos-cross-toolchains
brew install aarch64-unknown-linux-gnu

cd /tmp
rm -rf whisper.cpp
git clone https://github.com/ggerganov/whisper.cpp -b v1.7.3 --depth 1
cd whisper.cpp
cmake -B build -G Ninja \
  -DCMAKE_SYSTEM_NAME=Linux \
  -DCMAKE_SYSTEM_PROCESSOR=aarch64 \
  -DCMAKE_C_COMPILER=aarch64-linux-gnu-gcc \
  -DCMAKE_CXX_COMPILER=aarch64-linux-gnu-g++ \
  -DCMAKE_AR=aarch64-linux-gnu-ar \
  -DCMAKE_LINKER=aarch64-linux-gnu-gcc \
  -DCARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc \  
  -DCMAKE_SYSROOT=/opt/homebrew/Cellar/aarch64-unknown-linux-gnu/13.3.0/toolchain/aarch64-unknown-linux-gnu/sysroot
  -DCMAKE_C_FLAGS="-I/opt/homebrew/Cellar/aarch64-unknown-linux-gnu/13.3.0/toolchain/aarch64-unknown-linux-gnu/sysroot/usr/include/linux"

cmake --build build --config release --target main

Warning: messense/macos-cross-toolchains/aarch64-unknown-linux-gnu 13.3.0 is already installed and up-to-date.
To reinstall 13.3.0, run:
  brew reinstall aarch64-unknown-linux-gnu
Cloning into 'whisper.cpp'...
remote: Enumerating objects: 1109, done.
remote: Counting objects: 100% (1109/1109), done.
remote: Compressing objects: 100% (783/783), done.
remote: Total 1109 (delta 251), reused 821 (delta 215), pack-reused 0 (from 0)
Receiving objects: 100% (1109/1109), 3.31 MiB | 6.68 MiB/s, done.
Resolving deltas: 100% (251/251), done.
Note: switching to '3de9deead5759eb038966990e3cb5d83984ae467'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by switching back to a branch.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -c with the switch command. Example:

  git switch -c <new-branch-name>

Or undo this operation with:

  git switch -

Turn off this advice by setting config variable advice.detachedHead to false

CMake Warning:
  Ignoring extra path from command line:

   " "


-- The C compiler identification is GNU 13.3.0
-- The CXX compiler identification is GNU 13.3.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /opt/homebrew/bin/aarch64-linux-gnu-gcc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /opt/homebrew/bin/aarch64-linux-gnu-g++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found Git: /usr/bin/git (found version "2.39.3 (Apple Git-146)")
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Check if compiler accepts -pthread
-- Check if compiler accepts -pthread - yes
-- Found Threads: TRUE
-- Warning: ccache not found - consider installing it for faster compilation or disable this warning with GGML_CCACHE=OFF
-- CMAKE_SYSTEM_PROCESSOR: aarch64
-- Including CPU backend
-- Found OpenMP_C: -fopenmp (found version "4.5")
-- Found OpenMP_CXX: -fopenmp (found version "4.5")
-- Found OpenMP: TRUE (found version "4.5")
-- ARM detected
-- Performing Test COMPILER_SUPPORTS_FP16_FORMAT_I3E
-- Performing Test COMPILER_SUPPORTS_FP16_FORMAT_I3E - Failed
-- Adding CPU backend variant ggml-cpu:  
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Configuring done (0.9s)
-- Generating done (0.0s)
CMake Warning:
  Manually-specified variables were not used by the project:

    CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER


-- Build files have been written to: /tmp/whisper.cpp/build
zsh: no such file or directory: -DCMAKE_SYSROOT=/opt/homebrew/Cellar/aarch64-unknown-linux-gnu/13.3.0/toolchain/aarch64-unknown-linux-gnu/sysroot
zsh: no such file or directory: -DCMAKE_C_FLAGS=-I/opt/homebrew/Cellar/aarch64-unknown-linux-gnu/13.3.0/toolchain/aarch64-unknown-linux-gnu/sysroot/usr/include/linux
[3/27] Building C object ggml/src/CMakeFiles/ggml-cpu.dir/ggml-cpu/ggml-cpu.c.o
FAILED: ggml/src/CMakeFiles/ggml-cpu.dir/ggml-cpu/ggml-cpu.c.o 
/opt/homebrew/bin/aarch64-linux-gnu-gcc -DGGML_BACKEND_BUILD -DGGML_BACKEND_SHARED -DGGML_SCHED_MAX_COPIES=4 -DGGML_SHARED -DGGML_USE_CPU_AARCH64 -DGGML_USE_OPENMP -D_GNU_SOURCE -D_XOPEN_SOURCE=600 -Dggml_cpu_EXPORTS -I/tmp/whisper.cpp/ggml/src/.. -I/tmp/whisper.cpp/ggml/src/. -I/tmp/whisper.cpp/ggml/src/ggml-cpu -I/tmp/whisper.cpp/ggml/src/../include -O3 -DNDEBUG -std=gnu11 -fPIC -Wshadow -Wstrict-prototypes -Wpointer-arith -Wmissing-prototypes -Werror=implicit-int -Werror=implicit-function-declaration -Wall -Wextra -Wpedantic -Wcast-qual -Wno-unused-function -Wdouble-promotion -fopenmp -MD -MT ggml/src/CMakeFiles/ggml-cpu.dir/ggml-cpu/ggml-cpu.c.o -MF ggml/src/CMakeFiles/ggml-cpu.dir/ggml-cpu/ggml-cpu.c.o.d -o ggml/src/CMakeFiles/ggml-cpu.dir/ggml-cpu/ggml-cpu.c.o -c /tmp/whisper.cpp/ggml/src/ggml-cpu/ggml-cpu.c
/tmp/whisper.cpp/ggml/src/ggml-cpu/ggml-cpu.c: In function 'ggml_init_arm_arch_features':
/tmp/whisper.cpp/ggml/src/ggml-cpu/ggml-cpu.c:2395:33: error: 'AT_HWCAP2' undeclared (first use in this function); did you mean 'AT_HWCAP'?
 2395 |     uint32_t hwcap2 = getauxval(AT_HWCAP2);
      |                                 ^~~~~~~~~
      |                                 AT_HWCAP
/tmp/whisper.cpp/ggml/src/ggml-cpu/ggml-cpu.c:2395:33: note: each undeclared identifier is reported only once for each function it appears in
[12/27] Building C object ggml/src/CMakeFiles/ggml-base.dir/ggml-quants.c.o
ninja: build stopped: subcommand failed.

I can see the definition:

cat /opt/homebrew/Cellar/aarch64-unknown-linux-gnu/13.3.0/toolchain/aarch64-unknown-linux-gnu/sysroot/usr/include/linux/auxvec.h | grep AT_HWCAP
#define AT_HWCAP  16    /* arch dependent hints at CPU capabilities */
#define AT_HWCAP2 26    /* extension of AT_HWCAP */

Not sure why it failed. Is it issue in the compiler or in whisper?
Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions