From 8a9eaa5dbab117e96e1fe7977c1faf6f13c5fffa Mon Sep 17 00:00:00 2001 From: luncliff Date: Wed, 27 Sep 2023 23:14:54 +0900 Subject: [PATCH 1/7] circleci: update port list --- .circleci/port-setup.txt | 2 +- .circleci/port-windows.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.circleci/port-setup.txt b/.circleci/port-setup.txt index 1fa8ea1d..d692e1ad 100644 --- a/.circleci/port-setup.txt +++ b/.circleci/port-setup.txt @@ -18,4 +18,4 @@ opencl:x64-windows egl-registry:x64-windows opengl-registry:x64-windows vulkan-headers:x64-windows -nlohmann-json:x64-windows \ No newline at end of file +nlohmann-json:x64-windows diff --git a/.circleci/port-windows.txt b/.circleci/port-windows.txt index 69c28500..d72f2d4c 100644 --- a/.circleci/port-windows.txt +++ b/.circleci/port-windows.txt @@ -1,2 +1,2 @@ grpc[codegen]:x64-windows -onnxruntime[directml,xnnpack,test]:x64-windows \ No newline at end of file +onnxruntime[directml,xnnpack,test]:x64-windows From ac3d3bc02919931284a731b7474ccfcbc80a7ef1 Mon Sep 17 00:00:00 2001 From: luncliff Date: Tue, 25 Apr 2023 22:10:30 +0900 Subject: [PATCH 2/7] [llama-cpp] create a new port" --- ports/llama-cpp/fix-openblas.patch | 67 ++++++++++++++++++++++++++++++ ports/llama-cpp/portfile.cmake | 51 +++++++++++++++++++++++ ports/llama-cpp/vcpkg.json | 26 ++++++++++++ ports/zlib-ng/portfile.cmake | 9 +++- 4 files changed, 152 insertions(+), 1 deletion(-) create mode 100644 ports/llama-cpp/fix-openblas.patch create mode 100644 ports/llama-cpp/portfile.cmake create mode 100644 ports/llama-cpp/vcpkg.json diff --git a/ports/llama-cpp/fix-openblas.patch b/ports/llama-cpp/fix-openblas.patch new file mode 100644 index 00000000..929b9194 --- /dev/null +++ b/ports/llama-cpp/fix-openblas.patch @@ -0,0 +1,67 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 11ebe9e..8516e59 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -137,8 +137,8 @@ if (LLAMA_OPENBLAS) + $ENV{OpenBLAS_HOME} + $ENV{OpenBLAS_HOME}/include + ) +- find_path(OPENBLAS_INC NAMES cblas.h PATHS ${OPENBLAS_INCLUDE_SEARCH_PATHS}) +- add_compile_options(-I${OPENBLAS_INC}) ++ find_path(OPENBLAS_INC NAMES cblas.h openblas/cblas.h PATHS ${OPENBLAS_INCLUDE_SEARCH_PATHS}) ++ include_directories(${OPENBLAS_INC}) + else() + message(WARNING "OpenBLAS not found") + endif() +diff --git a/ggml.c b/ggml.c +index 8505889..6b5344c 100644 +--- a/ggml.c ++++ b/ggml.c +@@ -146,7 +146,7 @@ inline static void* ggml_aligned_malloc(size_t size) { + #if defined(GGML_USE_ACCELERATE) + #include + #elif defined(GGML_USE_OPENBLAS) +-#include ++#include + #elif defined(GGML_USE_CUBLAS) + #include "ggml-cuda.h" + #endif +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 8516e59..cb607b2 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -139,6 +139,8 @@ if (LLAMA_OPENBLAS) + ) + find_path(OPENBLAS_INC NAMES cblas.h openblas/cblas.h PATHS ${OPENBLAS_INCLUDE_SEARCH_PATHS}) + include_directories(${OPENBLAS_INC}) ++ find_library(OPENBLAS_LIB NAMES openblas REQUIRED) ++ link_libraries(${OPENBLAS_LIB}) + else() + message(WARNING "OpenBLAS not found") + endif() +diff --git a/CMakeLists.txt b/CMakeLists.txt +index cb607b2..f4fd773 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -123,7 +123,7 @@ if (LLAMA_OPENBLAS) + + add_compile_definitions(GGML_USE_OPENBLAS) + add_link_options(${BLAS_LIBRARIES}) +- set(LLAMA_EXTRA_LIBS ${LLAMA_EXTRA_LIBS} openblas) ++ set(LLAMA_EXTRA_LIBS ${LLAMA_EXTRA_LIBS} BLAS::BLAS) + + # find header file + set(OPENBLAS_INCLUDE_SEARCH_PATHS +@@ -340,7 +340,11 @@ if (GGML_CUDA_SOURCES) + set_property(TARGET llama PROPERTY CUDA_ARCHITECTURES OFF) + endif() + +- ++install(TARGETS ggml llama ++ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} ++ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} ++ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ++) + # + # programs, examples and tests + # diff --git a/ports/llama-cpp/portfile.cmake b/ports/llama-cpp/portfile.cmake new file mode 100644 index 00000000..222ed81b --- /dev/null +++ b/ports/llama-cpp/portfile.cmake @@ -0,0 +1,51 @@ +if(VCPKG_TARGET_IS_WINDOWS) + vcpkg_check_linkage(ONLY_DYNAMIC_LIBRARY) +endif() + +vcpkg_from_github( + OUT_SOURCE_PATH SOURCE_PATH + REPO ggerganov/llama.cpp + REF 54bb60e26858be251a0eb3cb70f80322aff804a0 # 2023-04-25 + SHA512 64f14c25a8dc6dabf7a222a452f986cb2d9477ae3d44e42a7fec630663fceb30f74a7ec80d1c73c6690f572075f39e20e916aaa41a8480f8a59b9c08d81d22f6 + PATCHES + fix-openblas.patch +) + +x_vcpkg_get_python_packages( + PYTHON_VERSION 3 + PACKAGES numpy pybind11 + OUT_PYTHON_VAR PYTHON3 +) +message(STATUS "Using python3: ${PYTHON3}") + +if(VCPKG_TARGET_ARCHITECTURE STREQUAL "x64") + # list(APPEND ARCH_OPTIONS) +elseif(VCPKG_TARGET_ARCHITECTURE STREQUAL "x86") + # list(APPEND ARCH_OPTIONS) +elseif(VCPKG_TARGET_ARCHITECTURE STREQUAL "arm64") + # list(APPEND ARCH_OPTIONS) +endif() + +vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS + FEATURES + f16c LLAMA_F16C + cublas LLAMA_CUBLAS +) + +string(COMPARE EQUAL "${VCPKG_CRT_LINKAGE}" "static" USE_STATIC) + +vcpkg_cmake_configure( + SOURCE_PATH "${SOURCE_PATH}" + OPTIONS + ${ARCH_OPTIONS} ${FEATURE_OPTIONS} + -DLLAMA_ACCELERATE=${VCPKG_TARGET_IS_OSX} + -DLLAMA_STATIC=${USE_STATIC} + -DLLAMA_OPENBLAS=${VCPKG_TARGET_IS_WINDOWS} +) +vcpkg_cmake_build(TARGET "llama") +vcpkg_cmake_install() +vcpkg_copy_pdbs() + +# this internal header is required by pytorch +file(INSTALL "${SOURCE_PATH}/LICENSE" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME "copyright") +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include") diff --git a/ports/llama-cpp/vcpkg.json b/ports/llama-cpp/vcpkg.json new file mode 100644 index 00000000..2ef0b972 --- /dev/null +++ b/ports/llama-cpp/vcpkg.json @@ -0,0 +1,26 @@ +{ + "name": "llama-cpp", + "version-date": "2023-04-25", + "description": "...", + "homepage": "https://github.com/ggerganov/llama.cpp", + "supports": "windows | linux | osx", + "dependencies": [ + "openblas", + { + "name": "vcpkg-cmake", + "host": true + }, + { + "name": "vcpkg-get-python-packages", + "host": true + } + ], + "features": { + "cublas": { + "description": "Use CUBLAS", + "dependencies": [ + "cudnn" + ] + } + } +} \ No newline at end of file diff --git a/ports/zlib-ng/portfile.cmake b/ports/zlib-ng/portfile.cmake index e6c8d431..dd84ccae 100644 --- a/ports/zlib-ng/portfile.cmake +++ b/ports/zlib-ng/portfile.cmake @@ -5,6 +5,13 @@ vcpkg_from_github( SHA512 1c19a62bb00727ac49049c299fb70060da95b5fafa448144ae4133372ec8c3da15cef6c1303485290f269b23c580696554ca0383dba3e1f9609f65c332981988 HEAD_REF master ) +if(VCPKG_TARGET_ARCHITECTURE STREQUAL "x64") + # list(APPEND ARCH_OPTIONS) +elseif(VCPKG_TARGET_ARCHITECTURE STREQUAL "x86") + # list(APPEND ARCH_OPTIONS) +elseif(VCPKG_TARGET_ARCHITECTURE STREQUAL "arm64") + # list(APPEND ARCH_OPTIONS) +endif() vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS FEATURES @@ -14,7 +21,7 @@ vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS vcpkg_cmake_configure( SOURCE_PATH "${SOURCE_PATH}" OPTIONS - ${FEATURE_OPTIONS} + ${ARCH_OPTIONS} ${FEATURE_OPTIONS} -DZLIB_ENABLE_TESTS=OFF -DWITH_NEW_STRATEGIES=ON -DWITH_NATIVE_INSTRUCTIONS=OFF # `-march=native` breaks `check_c_source_compiles` From 5742be550b4525d562722099c798efa90aeaa07c Mon Sep 17 00:00:00 2001 From: luncliff Date: Tue, 12 Sep 2023 03:55:14 +0900 Subject: [PATCH 3/7] [llama-cpp] update to b1213 --- ports/llama-cpp/portfile.cmake | 76 ++++++++++++++++++++++++---------- ports/llama-cpp/vcpkg.json | 37 +++++++++++++---- 2 files changed, 83 insertions(+), 30 deletions(-) diff --git a/ports/llama-cpp/portfile.cmake b/ports/llama-cpp/portfile.cmake index 222ed81b..b9fa64cf 100644 --- a/ports/llama-cpp/portfile.cmake +++ b/ports/llama-cpp/portfile.cmake @@ -5,31 +5,32 @@ endif() vcpkg_from_github( OUT_SOURCE_PATH SOURCE_PATH REPO ggerganov/llama.cpp - REF 54bb60e26858be251a0eb3cb70f80322aff804a0 # 2023-04-25 - SHA512 64f14c25a8dc6dabf7a222a452f986cb2d9477ae3d44e42a7fec630663fceb30f74a7ec80d1c73c6690f572075f39e20e916aaa41a8480f8a59b9c08d81d22f6 - PATCHES - fix-openblas.patch + REF b1213 + SHA512 b39736ece0ee701ac355f5115b0d7cefd5a9723bb2cec6b895181a7764bd0f23b3d14cd5b1c175dccd1ad5e9219d2f7500b2c5c840a504abbd2e50ed62965c3e ) -x_vcpkg_get_python_packages( - PYTHON_VERSION 3 - PACKAGES numpy pybind11 - OUT_PYTHON_VAR PYTHON3 -) -message(STATUS "Using python3: ${PYTHON3}") +vcpkg_find_acquire_program(PKGCONFIG) +message(STATUS "Using pkgconfig: ${PKGCONFIG}") + +if(VCPKG_TARGET_IS_WINDOWS) + list(APPEND BLAS_OPTIONS -DLLAMA_BLAS_VENDOR=OpenBLAS) +endif() if(VCPKG_TARGET_ARCHITECTURE STREQUAL "x64") - # list(APPEND ARCH_OPTIONS) -elseif(VCPKG_TARGET_ARCHITECTURE STREQUAL "x86") - # list(APPEND ARCH_OPTIONS) -elseif(VCPKG_TARGET_ARCHITECTURE STREQUAL "arm64") - # list(APPEND ARCH_OPTIONS) + list(APPEND ARCH_OPTIONS + -DLLAMA_AVX512=ON -DLLAMA_AVX512_VBMI=ON -DLLAMA_AVX512_VNNI=ON + # -DLLAMA_AVX2=ON + # -DLLAMA_AVX=ON + ) endif() vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS FEATURES - f16c LLAMA_F16C - cublas LLAMA_CUBLAS + cublas LLAMA_CUBLAS + cublas LLAMA_CUDA_F16 + clblast LLAMA_CLBLAST + mpi LLAMA_MPI + test LLAMA_BUILD_TESTS ) string(COMPARE EQUAL "${VCPKG_CRT_LINKAGE}" "static" USE_STATIC) @@ -37,15 +38,46 @@ string(COMPARE EQUAL "${VCPKG_CRT_LINKAGE}" "static" USE_STATIC) vcpkg_cmake_configure( SOURCE_PATH "${SOURCE_PATH}" OPTIONS - ${ARCH_OPTIONS} ${FEATURE_OPTIONS} + ${ARCH_OPTIONS} + ${FEATURE_OPTIONS} -DLLAMA_ACCELERATE=${VCPKG_TARGET_IS_OSX} + -DLLAMA_METAL=${VCPKG_TARGET_IS_OSX} # todo: support VCPKG_TARGET_IS_IOS -DLLAMA_STATIC=${USE_STATIC} - -DLLAMA_OPENBLAS=${VCPKG_TARGET_IS_WINDOWS} + -DLLAMA_BLAS=ON + ${BLAS_OPTIONS} + -DPKG_CONFIG_EXECUTABLE:FILEPATH=${PKGCONFIG} + OPTIONS_RELEASE + -DLLAMA_METAL_NDEBUG=ON ) -vcpkg_cmake_build(TARGET "llama") +vcpkg_cmake_build(TARGET "llama" LOGFILE_BASE build-llama) vcpkg_cmake_install() vcpkg_copy_pdbs() -# this internal header is required by pytorch +vcpkg_copy_tools(TOOL_NAMES + baby-llama beam-search benchmark convert-llama2c-to-ggml embd-input-test embedding llama-bench + main perplexity quantize-stats quantize save-load-state server simple speculative train-text-from-scratch + AUTO_CLEAN +) +if("test" IN_LIST FEATURES) + vcpkg_copy_tools(TOOL_NAMES + test-grad0 test-grammar-parser test-llama-grammar test-quantize-fns test-quantize-perf + test-sampling test-tokenizer-0-falcon test-tokenizer-0-llama test-tokenizer-1 + AUTO_CLEAN + ) +endif() + +file(INSTALL "${SOURCE_PATH}/llama.h" DESTINATION "${CURRENT_PACKAGES_DIR}/include") + +file(INSTALL "${CURRENT_PACKAGES_DIR}/bin/convert.py" + "${CURRENT_PACKAGES_DIR}/bin/convert-lora-to-ggml.py" + DESTINATION "${CURRENT_PACKAGES_DIR}/tools" +) + +file(REMOVE + "${CURRENT_PACKAGES_DIR}/bin/convert.py" + "${CURRENT_PACKAGES_DIR}/debug/bin/convert.py" + "${CURRENT_PACKAGES_DIR}/bin/convert-lora-to-ggml.py" + "${CURRENT_PACKAGES_DIR}/debug/bin/convert-lora-to-ggml.py" +) + file(INSTALL "${SOURCE_PATH}/LICENSE" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME "copyright") -file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include") diff --git a/ports/llama-cpp/vcpkg.json b/ports/llama-cpp/vcpkg.json index 2ef0b972..6c5d36ea 100644 --- a/ports/llama-cpp/vcpkg.json +++ b/ports/llama-cpp/vcpkg.json @@ -1,26 +1,47 @@ { "name": "llama-cpp", - "version-date": "2023-04-25", - "description": "...", + "version-string": "b1213", + "description": "Port of Facebook's LLaMA model in C/C++", "homepage": "https://github.com/ggerganov/llama.cpp", "supports": "windows | linux | osx", "dependencies": [ - "openblas", { - "name": "vcpkg-cmake", - "host": true + "name": "openblas", + "platform": "windows" }, { - "name": "vcpkg-get-python-packages", + "name": "vcpkg-cmake", "host": true } ], "features": { + "clblast": { + "description": "Use CLBlast", + "dependencies": [ + "clblast" + ] + }, "cublas": { - "description": "Use CUBLAS", + "description": "Use CUDA", "dependencies": [ "cudnn" ] + }, + "mpi": { + "description": "Use MPI", + "dependencies": [ + { + "name": "msmpi", + "platform": "windows" + }, + { + "name": "openmpi", + "platform": "!windows" + } + ] + }, + "test": { + "description": "Build tests" } } -} \ No newline at end of file +} From 3b423bf7e2cd5c739b1f6395707c9c3106c3d94c Mon Sep 17 00:00:00 2001 From: luncliff Date: Wed, 27 Sep 2023 23:34:52 +0900 Subject: [PATCH 4/7] [llama-cpp] update to b1273 --- ports/llama-cpp/portfile.cmake | 29 +++++++++++++++++++++-------- ports/llama-cpp/vcpkg.json | 6 +++++- 2 files changed, 26 insertions(+), 9 deletions(-) diff --git a/ports/llama-cpp/portfile.cmake b/ports/llama-cpp/portfile.cmake index b9fa64cf..b8cf818c 100644 --- a/ports/llama-cpp/portfile.cmake +++ b/ports/llama-cpp/portfile.cmake @@ -5,8 +5,9 @@ endif() vcpkg_from_github( OUT_SOURCE_PATH SOURCE_PATH REPO ggerganov/llama.cpp - REF b1213 - SHA512 b39736ece0ee701ac355f5115b0d7cefd5a9723bb2cec6b895181a7764bd0f23b3d14cd5b1c175dccd1ad5e9219d2f7500b2c5c840a504abbd2e50ed62965c3e + REF b1273 # commit 99115f3fa654b593099c6719ad30e3f54ce231e1 + SHA512 2b3e8fd9673647f59a4fa96621afe2f77ab10a2bee88a96b662b493beb2b66f17c854c1077f01f8ea8998d0296f92225d3033aae0adc756810f80caf45b9a456 + HEAD_REF master ) vcpkg_find_acquire_program(PKGCONFIG) @@ -35,22 +36,31 @@ vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS string(COMPARE EQUAL "${VCPKG_CRT_LINKAGE}" "static" USE_STATIC) +if(VCPKG_TARGET_IS_OSX OR VCPKG_TARGET_IS_IOS) + set(TARGET_IS_APPLE ON) +else() + set(TARGET_IS_APPLE OFF) +endif() + vcpkg_cmake_configure( SOURCE_PATH "${SOURCE_PATH}" OPTIONS ${ARCH_OPTIONS} ${FEATURE_OPTIONS} - -DLLAMA_ACCELERATE=${VCPKG_TARGET_IS_OSX} - -DLLAMA_METAL=${VCPKG_TARGET_IS_OSX} # todo: support VCPKG_TARGET_IS_IOS + -DLLAMA_ACCELERATE=${TARGET_IS_APPLE} + -DLLAMA_METAL=${TARGET_IS_APPLE} -DLLAMA_STATIC=${USE_STATIC} -DLLAMA_BLAS=ON ${BLAS_OPTIONS} - -DPKG_CONFIG_EXECUTABLE:FILEPATH=${PKGCONFIG} + -DPKG_CONFIG_EXECUTABLE:FILEPATH="${PKGCONFIG}" + -DBUILD_COMMIT:STRING="99115f3fa654b593099c6719ad30e3f54ce231e1" + -DBUILD_NUMBER:STRING="1273" OPTIONS_RELEASE -DLLAMA_METAL_NDEBUG=ON ) vcpkg_cmake_build(TARGET "llama" LOGFILE_BASE build-llama) vcpkg_cmake_install() +vcpkg_cmake_config_fixup(CONFIG_PATH "lib/cmake/Llama" PACKAGE_NAME "Llama") vcpkg_copy_pdbs() vcpkg_copy_tools(TOOL_NAMES @@ -61,7 +71,7 @@ vcpkg_copy_tools(TOOL_NAMES if("test" IN_LIST FEATURES) vcpkg_copy_tools(TOOL_NAMES test-grad0 test-grammar-parser test-llama-grammar test-quantize-fns test-quantize-perf - test-sampling test-tokenizer-0-falcon test-tokenizer-0-llama test-tokenizer-1 + test-sampling test-tokenizer-0-falcon test-tokenizer-0-llama test-tokenizer-1-llama AUTO_CLEAN ) endif() @@ -70,9 +80,12 @@ file(INSTALL "${SOURCE_PATH}/llama.h" DESTINATION "${CURRENT_PACKAGES_DIR}/inclu file(INSTALL "${CURRENT_PACKAGES_DIR}/bin/convert.py" "${CURRENT_PACKAGES_DIR}/bin/convert-lora-to-ggml.py" - DESTINATION "${CURRENT_PACKAGES_DIR}/tools" + DESTINATION "${CURRENT_PACKAGES_DIR}/tools/${PORT}" ) +file(REMOVE_RECURSE + "${CURRENT_PACKAGES_DIR}/debug/include" +) file(REMOVE "${CURRENT_PACKAGES_DIR}/bin/convert.py" "${CURRENT_PACKAGES_DIR}/debug/bin/convert.py" @@ -80,4 +93,4 @@ file(REMOVE "${CURRENT_PACKAGES_DIR}/debug/bin/convert-lora-to-ggml.py" ) -file(INSTALL "${SOURCE_PATH}/LICENSE" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME "copyright") +vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE") diff --git a/ports/llama-cpp/vcpkg.json b/ports/llama-cpp/vcpkg.json index 6c5d36ea..41938cbf 100644 --- a/ports/llama-cpp/vcpkg.json +++ b/ports/llama-cpp/vcpkg.json @@ -1,6 +1,6 @@ { "name": "llama-cpp", - "version-string": "b1213", + "version-string": "b1273", "description": "Port of Facebook's LLaMA model in C/C++", "homepage": "https://github.com/ggerganov/llama.cpp", "supports": "windows | linux | osx", @@ -12,6 +12,10 @@ { "name": "vcpkg-cmake", "host": true + }, + { + "name": "vcpkg-cmake-config", + "host": true } ], "features": { From d1e9d491bd6f8a740c2f78ce1c91428f51ea94a1 Mon Sep 17 00:00:00 2001 From: luncliff Date: Wed, 27 Sep 2023 23:36:38 +0900 Subject: [PATCH 5/7] gh-actions: test llama-cpp --- test/vcpkg.json | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/test/vcpkg.json b/test/vcpkg.json index 512c7a47..4b2ace0e 100644 --- a/test/vcpkg.json +++ b/test/vcpkg.json @@ -9,6 +9,13 @@ "name": "vcpkg-cmake", "host": true }, - "openssl3" + "openssl3", + { + "name": "llama-cpp", + "features": [ + "test" + ], + "platform": "windows | osx" + } ] } \ No newline at end of file From 463a9a787353aed4390e4f714e5f7b3a8ce5037f Mon Sep 17 00:00:00 2001 From: luncliff Date: Fri, 29 Sep 2023 11:24:13 +0900 Subject: [PATCH 6/7] [llama-cpp] fix apple build --- ports/llama-cpp/portfile.cmake | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ports/llama-cpp/portfile.cmake b/ports/llama-cpp/portfile.cmake index b8cf818c..eb2f48bc 100644 --- a/ports/llama-cpp/portfile.cmake +++ b/ports/llama-cpp/portfile.cmake @@ -13,8 +13,14 @@ vcpkg_from_github( vcpkg_find_acquire_program(PKGCONFIG) message(STATUS "Using pkgconfig: ${PKGCONFIG}") +# check https://cmake.org/cmake/help/latest/module/FindBLAS.html#blas-lapack-vendors if(VCPKG_TARGET_IS_WINDOWS) list(APPEND BLAS_OPTIONS -DLLAMA_BLAS_VENDOR=OpenBLAS) +elseif(VCPKG_TARGET_IS_OSX OR VCPKG_TARGET_IS_IOS) + list(APPEND BLAS_OPTIONS -DLLAMA_BLAS_VENDOR=Apple) +else() + # todo: Intel MKL, ARM, ACML, etc... + list(APPEND BLAS_OPTIONS -DLLAMA_BLAS_VENDOR=Generic) endif() if(VCPKG_TARGET_ARCHITECTURE STREQUAL "x64") From fa127bc7fd9987c3e76a3da63acc40d55a713dee Mon Sep 17 00:00:00 2001 From: luncliff Date: Fri, 29 Sep 2023 12:01:08 +0900 Subject: [PATCH 7/7] [llama-cpp] correct build info --- ports/llama-cpp/fix-cmake.patch | 55 +++++++++++++++++++++++++++++++++ ports/llama-cpp/portfile.cmake | 3 ++ 2 files changed, 58 insertions(+) create mode 100644 ports/llama-cpp/fix-cmake.patch diff --git a/ports/llama-cpp/fix-cmake.patch b/ports/llama-cpp/fix-cmake.patch new file mode 100644 index 00000000..d20ec117 --- /dev/null +++ b/ports/llama-cpp/fix-cmake.patch @@ -0,0 +1,55 @@ +diff --git a/scripts/build-info.cmake b/scripts/build-info.cmake +index c86ab43..0571c20 100644 +--- a/scripts/build-info.cmake ++++ b/scripts/build-info.cmake +@@ -1,9 +1,5 @@ + set(TEMPLATE_FILE "${CMAKE_CURRENT_SOURCE_DIR}/scripts/build-info.h.in") + set(HEADER_FILE "${CMAKE_CURRENT_SOURCE_DIR}/build-info.h") +-set(BUILD_NUMBER 0) +-set(BUILD_COMMIT "unknown") +-set(BUILD_COMPILER "unknown") +-set(BUILD_TARGET "unknown") + + # Look for git + find_package(Git) +@@ -18,22 +14,7 @@ if(NOT Git_FOUND) + endif() + + # Get the commit count and hash +-if(Git_FOUND) +- execute_process( +- COMMAND ${GIT_EXECUTABLE} rev-parse --short HEAD +- WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} +- OUTPUT_VARIABLE HEAD +- OUTPUT_STRIP_TRAILING_WHITESPACE +- ) +- execute_process( +- COMMAND ${GIT_EXECUTABLE} rev-list --count HEAD +- WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} +- OUTPUT_VARIABLE COUNT +- OUTPUT_STRIP_TRAILING_WHITESPACE +- ) +- set(BUILD_COMMIT ${HEAD}) +- set(BUILD_NUMBER ${COUNT}) +-endif() ++# see portfile.cmake + + if(MSVC) + set(BUILD_COMPILER "${CMAKE_C_COMPILER_ID} ${CMAKE_C_COMPILER_VERSION}") +@@ -72,3 +53,16 @@ if(EXISTS ${HEADER_FILE}) + else() + configure_file(${TEMPLATE_FILE} ${HEADER_FILE}) + endif() ++ ++if(NOT DEFINED BUILD_NUMBER) ++ set(BUILD_NUMBER 0) ++endif() ++if(NOT DEFINED BUILD_COMMIT) ++ set(BUILD_COMMIT "unknown") ++endif() ++if(NOT DEFINED BUILD_COMPILER) ++ set(BUILD_COMPILER "unknown") ++endif() ++if(NOT DEFINED BUILD_TARGET) ++ set(BUILD_TARGET "unknown") ++endif() diff --git a/ports/llama-cpp/portfile.cmake b/ports/llama-cpp/portfile.cmake index eb2f48bc..fc60832f 100644 --- a/ports/llama-cpp/portfile.cmake +++ b/ports/llama-cpp/portfile.cmake @@ -8,6 +8,9 @@ vcpkg_from_github( REF b1273 # commit 99115f3fa654b593099c6719ad30e3f54ce231e1 SHA512 2b3e8fd9673647f59a4fa96621afe2f77ab10a2bee88a96b662b493beb2b66f17c854c1077f01f8ea8998d0296f92225d3033aae0adc756810f80caf45b9a456 HEAD_REF master + PATCHES + # fix-openblas.patch + fix-cmake.patch ) vcpkg_find_acquire_program(PKGCONFIG)