Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

whisper-cpp: make compatible with --HEAD install #202270

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mislav
Copy link
Contributor

@mislav mislav commented Dec 23, 2024

This is to accommodate the build system changes in the upcoming v1.7.4 release.

  • Have you followed the guidelines for contributing?
  • Have you ensured that your commits follow the commit style guide?
  • Have you checked that there aren't other open pull requests for the same formula update/change?
  • Have you built your formula locally with HOMEBREW_NO_INSTALL_FROM_API=1 brew install --build-from-source <formula>, where <formula> is the name of the formula you're submitting?
  • Is your test running fine brew test <formula>, where <formula> is the name of the formula you're submitting?
  • Does your build pass brew audit --strict <formula> (after doing HOMEBREW_NO_INSTALL_FROM_API=1 brew install --build-from-source <formula>)? If this is a new formula, does it pass brew audit --new <formula>?

In --HEAD mode, the main changes are that dylibs are now enabled and that the main binary is now called whisper-cli.

Libraries and header files currently unfortunately conflict with the llama.cpp formula, so in this installation we rename the "lib" folder and omit the header files to avoid the conflict. ggerganov/ggml#1050 (comment)

This is to accommodate the build system changes in the upcoming v1.7.4
@@ -24,7 +24,7 @@ class WhisperCpp < Formula

def install
args = %W[
-DBUILD_SHARED_LIBS=OFF
-DBUILD_SHARED_LIBS=#{head? ? "ON" : "OFF"}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
-DBUILD_SHARED_LIBS=#{head? ? "ON" : "OFF"}
-DBUILD_SHARED_LIBS=#{build.head? ? "ON" : "OFF"}

@@ -33,11 +33,27 @@ def install
-DWHISPER_BUILD_SERVER=OFF
]
args << "-DLLAMA_METAL_MACOSX_VERSION_MIN=#{MacOS.version}" if OS.mac?
args << "-DCMAKE_INSTALL_RPATH=#{OS.mac? ? "@loader_path/../libinternal" : "'$ORIGIN/../libinternal'"}" if head?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use the rpath helper (and build.head?) instead:

Suggested change
args << "-DCMAKE_INSTALL_RPATH=#{OS.mac? ? "@loader_path/../libinternal" : "'$ORIGIN/../libinternal'"}" if head?
args << "-DCMAKE_INSTALL_RPATH=#{rpath(target: prefix/"libinternal")}" if build.head?

system "cmake", "--build", "build", "--target", "main"
bin.install "build/bin/main" => "whisper-cpp"
# avoid installing libggml libraries to "lib" since they would conflict with llama.cpp
system "cmake", "-S", ".", "-B", "build", *args, *std_cmake_args(install_libdir: "libinternal")
Copy link
Member

@carlocab carlocab Dec 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
system "cmake", "-S", ".", "-B", "build", *args, *std_cmake_args(install_libdir: "libinternal")
system "cmake", "-S", ".", "-B", "build", *args, *std_cmake_args(install_libdir: "lib/ggml")

Maybe? You'll need to adjust the argument to #rpath from my suggestion above if you apply this. (to rpath(target: lib/"ggml")).

Though, ideally we should be using libggml from llama.cpp instead (or vice-versa).

bin.install "build/bin/main" => "whisper-cpp"
# avoid installing libggml libraries to "lib" since they would conflict with llama.cpp
system "cmake", "-S", ".", "-B", "build", *args, *std_cmake_args(install_libdir: "libinternal")
if head?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if head?
if build.head?

Comment on lines +43 to +49
(bin/"whisper-cpp").write <<~EOS
#!/bin/bash
here="${BASH_SOURCE[0]}"
echo "${BASH_SOURCE[0]}: warning: whisper-cpp is deprecated. Use whisper-cli instead." >&2
exec "$(dirname "$here")/whisper-cli" "$@"
EOS
(bin/"whisper-cpp").chmod 0755
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably do this unconditionally?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants