Skip to content

Commit 72b8aa2

Browse files
committed
fix: linking issue on Linux
1 parent 020f9d3 commit 72b8aa2

File tree

2 files changed

+14
-12
lines changed

2 files changed

+14
-12
lines changed

llama/CMakeLists.txt

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,16 @@ if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "Ap
2828
add_compile_options(-Wno-c++17-extensions)
2929
endif()
3030

31+
if(APPLE)
32+
set(CMAKE_SKIP_BUILD_RPATH FALSE)
33+
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH FALSE)
34+
set(CMAKE_BUILD_RPATH "@loader_path")
35+
set(CMAKE_INSTALL_RPATH "@loader_path")
36+
set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
37+
else()
38+
set(CMAKE_BUILD_RPATH_USE_ORIGIN ON)
39+
endif()
40+
3141
include_directories(${NODE_ADDON_API_DIR} ${CMAKE_JS_INC})
3242

3343
add_subdirectory("llama.cpp")
@@ -65,16 +75,6 @@ list(REMOVE_DUPLICATES GPU_INFO_EXTRA_LIBS)
6575

6676
file(GLOB SOURCE_FILES "addon/*.cpp" "addon/**/*.cpp" ${GPU_INFO_SOURCES})
6777

68-
if(APPLE)
69-
set(CMAKE_SKIP_BUILD_RPATH FALSE)
70-
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH FALSE)
71-
set(CMAKE_BUILD_RPATH "@loader_path")
72-
set(CMAKE_INSTALL_RPATH "@loader_path")
73-
set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
74-
else()
75-
set(CMAKE_BUILD_RPATH_USE_ORIGIN ON)
76-
endif()
77-
7878
add_library(${PROJECT_NAME} SHARED ${SOURCE_FILES} ${CMAKE_JS_SRC} ${GPU_INFO_HEADERS})
7979
set_target_properties(${PROJECT_NAME} PROPERTIES PREFIX "" SUFFIX ".node")
8080
target_link_libraries(${PROJECT_NAME} ${CMAKE_JS_LIB})

src/bindings/utils/compileLLamaCpp.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,8 +252,10 @@ export async function compileLlamaCpp(buildOptions: BuildOptions, compileOptions
252252
(!ignoreWorkarounds.includes("reduceParallelBuildThreads") || !ignoreWorkarounds.includes("singleBuildThread")) &&
253253
(platform === "win" || platform === "linux") &&
254254
err instanceof SpawnError &&
255-
reduceParallelBuildThreads(parallelBuildThreads) !== parallelBuildThreads &&
256-
err.combinedStd.toLowerCase().includes("compiler is out of heap space".toLowerCase())
255+
reduceParallelBuildThreads(parallelBuildThreads) !== parallelBuildThreads && (
256+
err.combinedStd.toLowerCase().includes("LLVM error : out of memory".toLowerCase()) ||
257+
err.combinedStd.toLowerCase().includes("compiler is out of heap space".toLowerCase())
258+
)
257259
) {
258260
if (buildOptions.progressLogs) {
259261
if (ignoreWorkarounds.includes("reduceParallelBuildThreads"))

0 commit comments

Comments
 (0)