Skip to content

Commit

Permalink
fix workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
danemadsen committed Jun 8, 2024
1 parent 028f988 commit 9539965
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 26 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
uses: actions/upload-artifact@v4
with:
name: maid-linux
path: build/linux/x64/release/bundle
path: example/build/linux/x64/release/bundle

create-appimage:
needs: build
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@ jobs:
uses: actions/upload-artifact@v4
with:
name: maid-windows
path: build/windows/x64/bundle
path: example/build/windows/x64/bundle
65 changes: 41 additions & 24 deletions linux/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,50 +1,67 @@
# The Flutter tooling requires that developers have CMake 3.10 or later
# installed. You should not increase this version, as doing so will cause
# the plugin to fail to compile for some customers of the plugin.
cmake_minimum_required(VERSION 3.10)

# Project-level configuration.
set(PROJECT_NAME "maid_llm")
project(${PROJECT_NAME} LANGUAGES CXX)

set(MAID_LLM_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../src)
set(MAID_LLM_SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../src)
set(LLAMA_CPP_DIR ${MAID_LLM_SRC_DIR}/llama_cpp)

set(BUILD_SHARED_LIBS ON)
set(CMAKE_INSTALL_LIBDIR lib CACHE PATH "library install dir" FORCE)

# Set the linker flags for shared libraries
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--build-id=none")

set(LLAMA_NATIVE OFF CACHE BOOL "llama: disable -march=native flag" FORCE)
set(LLAMA_VULKAN ON CACHE BOOL "llama: enable vulkan" FORCE)

add_subdirectory(${MAID_LLM_DIR}/llama_cpp ${CMAKE_CURRENT_BINARY_DIR}/shared)
find_package(Vulkan)
if (Vulkan_FOUND)
add_compile_definitions(GGML_USE_VULKAN)
set(LLAMA_EXTRA_LIBS ${LLAMA_EXTRA_LIBS} Vulkan::Vulkan)
set(GGML_HEADERS_VULKAN ${LLAMA_CPP_DIR}/ggml-vulkan.h)
set(GGML_SOURCES_VULKAN ${LLAMA_CPP_DIR}/ggml-vulkan.cpp)
else()
message(WARNING "Vulkan not found, building without Vulkan support")
endif()

add_library(maid_llm SHARED
${MAID_LLM_DIR}/maid_llm.cpp
${MAID_LLM_SRC_DIR}/maid_llm.cpp
${LLAMA_CPP_DIR}/ggml.c
${LLAMA_CPP_DIR}/ggml-alloc.c
${LLAMA_CPP_DIR}/ggml-backend.c
${LLAMA_CPP_DIR}/ggml-quants.c
${LLAMA_CPP_DIR}/llama.cpp
${LLAMA_CPP_DIR}/sgemm.cpp
${LLAMA_CPP_DIR}/unicode.cpp
${LLAMA_CPP_DIR}/unicode-data.cpp
${LLAMA_CPP_DIR}/common/common.cpp
${LLAMA_CPP_DIR}/common/sampling.cpp
${LLAMA_CPP_DIR}/common/grammar-parser.cpp
${LLAMA_CPP_DIR}/common/json-schema-to-grammar.cpp
${GGML_SOURCES_VULKAN}
${GGML_HEADERS_VULKAN}
)

# Add this line to include the llama_cpp directory
target_include_directories(maid_llm PRIVATE
${MAID_LLM_DIR}
${MAID_LLM_DIR}/llama_cpp
${MAID_LLM_DIR}/llama_cpp/common
target_include_directories(maid_llm PRIVATE
${MAID_LLM_SRC_DIR}
${LLAMA_CPP_DIR}
${LLAMA_CPP_DIR}/common
)

target_link_libraries(maid_llm llama common)

set_target_properties(maid_llm PROPERTIES
PUBLIC_HEADER ${MAID_LLM_DIR}/maid_llm.h
PUBLIC_HEADER ${MAID_LLM_SRC_DIR}/maid_llm.h
OUTPUT_NAME "maid"
BUILD_WITH_INSTALL_RPATH TRUE
INSTALL_RPATH "$ORIGIN"
)

target_compile_definitions(maid_llm PUBLIC DART_SHARED_LIB)

set(maid_llm_bundled_libraries
# Defined in ../src/CMakeLists.txt.
# This can be changed to accommodate different builds.
$<TARGET_FILE:maid_llm>
PARENT_SCOPE
target_compile_options(maid_llm PRIVATE
-O3
-DNDEBUG
-ffunction-sections
-fdata-sections
)

target_link_options(maid_llm PRIVATE
-Wl,--gc-sections
-flto
)

0 comments on commit 9539965

Please sign in to comment.