From 853b6a222a4d7164a22897afec196ea67c85b0b2 Mon Sep 17 00:00:00 2001 From: Mergen Nachin Date: Tue, 2 Sep 2025 11:53:26 -0400 Subject: [PATCH] Fix llama runner on MacOS Summary: Fixes two things: - There's a compilation error when building the tests due to missing header. Make sure it works via test_llama.sh - rpath isn't set correctly on MacOS Test Plan: ``` cmake --preset llm -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=cmake-out cmake --build cmake-out -j16 --target install --config Release cmake -DCMAKE_INSTALL_PREFIX=cmake-out \ -DBUILD_TESTING=OFF \ -DCMAKE_BUILD_TYPE=Release \ -Bcmake-out/examples/models/llama \ examples/models/llama cmake --build cmake-out/examples/models/llama -j16 --config Release ``` --- .ci/scripts/test_llama.sh | 2 ++ examples/models/llama/CMakeLists.txt | 3 ++- runtime/executor/test/method_test.cpp | 1 + 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/.ci/scripts/test_llama.sh b/.ci/scripts/test_llama.sh index 0422f8114bb..84278e290f6 100644 --- a/.ci/scripts/test_llama.sh +++ b/.ci/scripts/test_llama.sh @@ -154,6 +154,7 @@ cmake_install_executorch_libraries() { echo "Installing libexecutorch.a, libextension_module.so, libportable_ops_lib.a" rm -rf cmake-out retry cmake --preset llm \ + -DEXECUTORCH_BUILD_TESTS=ON \ -DBUILD_TESTING=OFF \ -DCMAKE_INSTALL_PREFIX=cmake-out \ -DCMAKE_BUILD_TYPE="$CMAKE_BUILD_TYPE" \ @@ -170,6 +171,7 @@ cmake_build_llama_runner() { popd dir="examples/models/llama" retry cmake \ + -DEXECUTORCH_BUILD_TESTS=ON \ -DBUILD_TESTING=OFF \ -DCMAKE_INSTALL_PREFIX=cmake-out \ -DCMAKE_BUILD_TYPE="$CMAKE_BUILD_TYPE" \ diff --git a/examples/models/llama/CMakeLists.txt b/examples/models/llama/CMakeLists.txt index f59252c0df2..e7c73c0cffc 100644 --- a/examples/models/llama/CMakeLists.txt +++ b/examples/models/llama/CMakeLists.txt @@ -220,7 +220,8 @@ target_include_directories(llama_main PUBLIC ${_common_include_directories}) target_link_libraries(llama_main PUBLIC llama_runner ${link_libraries}) target_compile_options(llama_main PUBLIC ${_common_compile_options}) if(APPLE) - target_link_options(llama_main PRIVATE -Wl,-rpath,@executable_path) + target_link_options(llama_main PRIVATE -Wl,-rpath,@loader_path) elseif(UNIX) set_target_properties(llama_main PROPERTIES LINK_FLAGS "-Wl,-rpath='$ORIGIN'") endif() +# Windows doesn't need rpath - DLLs are found via standard Windows search order diff --git a/runtime/executor/test/method_test.cpp b/runtime/executor/test/method_test.cpp index 60f4e096bac..c0a58793248 100644 --- a/runtime/executor/test/method_test.cpp +++ b/runtime/executor/test/method_test.cpp @@ -8,6 +8,7 @@ #include #include +#include #include #include