misc(build): improve build process

This commit is contained in:
Morgan Funtowicz 2024-11-14 09:38:13 +01:00
parent 70c90ad933
commit 23d2bcf28d
3 changed files with 12 additions and 17 deletions

View File

@ -6,7 +6,6 @@ set(CMAKE_CXX_STANDARD 23)
include(FetchContent)
set(LLAMA_CPP_TARGET_VERSION "b3837" CACHE STRING "Version of llama.cpp to build against")
set(LLAMA_BUILD_COMMON ON)
set(LLAMA_CPP_TARGET_CUDA_ARCHS "75-real;80-real;86-real;89-real;90-real" CACHE STRING "CUDA arch(s) to build")
option(LLAMA_CPP_BUILD_OFFLINE_RUNNER "Flag to build the standalone c++ backend runner")
option(LLAMA_CPP_BUILD_CUDA "Flag to build CUDA enabled inference through llama.cpp")
@ -40,8 +39,8 @@ fetchcontent_makeavailable(llama)
add_library(tgi_llamacpp_backend_impl STATIC csrc/backend.hpp csrc/backend.cpp)
target_compile_features(tgi_llamacpp_backend_impl PRIVATE cxx_std_11)
target_link_libraries(tgi_llamacpp_backend_impl PUBLIC spdlog::spdlog llama common)
install(TARGETS tgi_llamacpp_backend_impl spdlog llama common)
target_link_libraries(tgi_llamacpp_backend_impl PUBLIC spdlog::spdlog llama)
install(TARGETS tgi_llamacpp_backend_impl spdlog llama)
if (${CMAKE_BUILD_TYPE} STREQUAL "Debug")
target_compile_definitions(tgi_llamacpp_backend_impl PRIVATE TGI_LLAMACPP_BACKEND_DEBUG=1)
@ -51,7 +50,7 @@ if (${LLAMA_CPP_BUILD_OFFLINE_RUNNER})
message(STATUS "Building llama.cpp offline runner")
add_executable(tgi_llamacpp_offline_runner offline/main.cpp)
target_link_libraries(tgi_llamacpp_offline_runner PUBLIC tgi_llamacpp_backend_impl llama common spdlog::spdlog)
target_link_libraries(tgi_llamacpp_offline_runner PUBLIC tgi_llamacpp_backend_impl llama spdlog::spdlog)
endif ()

View File

@ -59,9 +59,6 @@ fn build_ffi_layer(deps_folder: &Path, install_prefix: &Path) {
cxx_build::bridge("src/lib.rs")
.static_flag(true)
.std("c++23")
.include(deps_folder.join("spdlog-src").join("include")) // Why spdlog doesnt install headers?
.include(deps_folder.join("llama-src").join("ggml").join("include")) // Why ggml doesnt install headers?
.include(deps_folder.join("llama-src").join("common").join("include")) // Why common doesnt install headers?
.include(install_prefix.join("include"))
.include("csrc")
.file("csrc/ffi.hpp")
@ -98,15 +95,8 @@ fn main() {
// Linkage info
println!("cargo:rustc-link-search=native={}", out_dir.display());
if is_debug {
// println!("cargo:rustc-link-lib=dylib=fmtd");
println!("cargo:rustc-link-lib=dylib=spdlogd");
} else {
// println!("cargo:rustc-link-lib=dylib=fmt");
println!("cargo:rustc-link-lib=dylib=spdlog");
}
println!("cargo:rustc-link-lib=static=common");
let spdlog_linkage_target = if is_debug { "spdlogd" } else { "spdlog" };
println!("cargo:rustc-link-lib=static={spdlog_linkage_target}");
println!("cargo:rustc-link-lib=dylib=ggml");
println!("cargo:rustc-link-lib=dylib=llama");

View File

@ -1,6 +1,12 @@
set(SPDLOG_USE_FMT ON)
set(SPDLOG_BUILD_SHARED ON)
set(SPDLOG_BUILD_SHARED OFF)
set(SPDLOG_FMT_EXTERNAL OFF)
set(SPDLOG_INSTALL ON)
set(SPDLOG_NO_ATOMIC_LEVELS ON) # We are not modifying log levels concurrently
if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
set(SPDLOG_CLOCK_COARSE ON)
endif ()
# Define the level at which SPDLOG_ compilation level is defined
if (CMAKE_BUILD_TYPE STREQUAL "Debug")