Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
ollama
Commits
85129d3a
Commit
85129d3a
authored
Mar 12, 2024
by
Daniel Hiltgen
Browse files
Adapt our build for imported server.cpp
parent
9ac6440d
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
12 additions
and
24 deletions
+12
-24
llm/ext_server/CMakeLists.txt
llm/ext_server/CMakeLists.txt
+2
-6
llm/ext_server/server.cpp
llm/ext_server/server.cpp
+1
-1
llm/generate/gen_common.sh
llm/generate/gen_common.sh
+5
-8
llm/generate/gen_windows.ps1
llm/generate/gen_windows.ps1
+4
-9
No files found.
llm/ext_server/CMakeLists.txt
View file @
85129d3a
# Ollama specific CMakefile to include in llama.cpp/examples/server
set
(
TARGET ext_server
)
set
(
TARGET ext_server
)
option
(
LLAMA_SERVER_VERBOSE
"Build verbose logging option for Server"
ON
)
option
(
LLAMA_SERVER_VERBOSE
"Build verbose logging option for Server"
ON
)
if
(
WIN32
)
if
(
WIN32
)
add_library
(
${
TARGET
}
SHARED
../../../ext_server/
ext_server.cpp ../
..
/llama.cpp
)
add_library
(
${
TARGET
}
SHARED ext_server.cpp ../
llama.cpp
/llama.cpp
)
else
()
else
()
add_library
(
${
TARGET
}
STATIC
../../../ext_server/
ext_server.cpp ../
..
/llama.cpp
)
add_library
(
${
TARGET
}
STATIC ext_server.cpp ../
llama.cpp
/llama.cpp
)
endif
()
endif
()
target_include_directories
(
${
TARGET
}
PRIVATE ../../common
)
target_include_directories
(
${
TARGET
}
PRIVATE ../..
)
target_include_directories
(
${
TARGET
}
PRIVATE ../../..
)
target_compile_features
(
${
TARGET
}
PRIVATE cxx_std_11
)
target_compile_features
(
${
TARGET
}
PRIVATE cxx_std_11
)
target_compile_definitions
(
${
TARGET
}
PUBLIC LLAMA_SERVER_LIBRARY=1
)
target_compile_definitions
(
${
TARGET
}
PUBLIC LLAMA_SERVER_LIBRARY=1
)
target_link_libraries
(
${
TARGET
}
PRIVATE ggml llava common
)
target_link_libraries
(
${
TARGET
}
PRIVATE ggml llava common
)
...
...
llm/ext_server/server.cpp
View file @
85129d3a
...
@@ -2770,7 +2770,7 @@ inline void signal_handler(int signal) {
...
@@ -2770,7 +2770,7 @@ inline void signal_handler(int signal) {
shutdown_handler
(
signal
);
shutdown_handler
(
signal
);
}
}
int
main
(
int
argc
,
char
**
argv
)
int
_
main
(
int
argc
,
char
**
argv
)
{
{
#if SERVER_VERBOSE != 1
#if SERVER_VERBOSE != 1
log_disable
();
log_disable
();
...
...
llm/generate/gen_common.sh
View file @
85129d3a
...
@@ -61,8 +61,8 @@ git_module_setup() {
...
@@ -61,8 +61,8 @@ git_module_setup() {
apply_patches
()
{
apply_patches
()
{
# Wire up our CMakefile
# Wire up our CMakefile
if
!
grep
ollama
${
LLAMACPP_DIR
}
/
examples/server/
CMakeLists.txt
;
then
if
!
grep
ollama
${
LLAMACPP_DIR
}
/CMakeLists.txt
;
then
echo
'
include (../../../ext_server/CMakeLists.txt
) # ollama'
>>
${
LLAMACPP_DIR
}
/
examples/server/
CMakeLists.txt
echo
'
add_subdirectory(../ext_server ext_server
) # ollama'
>>
${
LLAMACPP_DIR
}
/CMakeLists.txt
fi
fi
if
[
-n
"
$(
ls
-A
../patches/
*
.diff
)
"
]
;
then
if
[
-n
"
$(
ls
-A
../patches/
*
.diff
)
"
]
;
then
...
@@ -76,19 +76,16 @@ apply_patches() {
...
@@ -76,19 +76,16 @@ apply_patches() {
(
cd
${
LLAMACPP_DIR
}
&&
git apply
${
patch
}
)
(
cd
${
LLAMACPP_DIR
}
&&
git apply
${
patch
}
)
done
done
fi
fi
# Avoid duplicate main symbols when we link into the cgo binary
sed
-e
's/int main(/int __main(/g'
<
${
LLAMACPP_DIR
}
/examples/server/server.cpp
>
${
LLAMACPP_DIR
}
/examples/server/server.cpp.tmp
&&
mv
${
LLAMACPP_DIR
}
/examples/server/server.cpp.tmp
${
LLAMACPP_DIR
}
/examples/server/server.cpp
}
}
build
()
{
build
()
{
cmake
-S
${
LLAMACPP_DIR
}
-B
${
BUILD_DIR
}
${
CMAKE_DEFS
}
cmake
-S
${
LLAMACPP_DIR
}
-B
${
BUILD_DIR
}
${
CMAKE_DEFS
}
cmake
--build
${
BUILD_DIR
}
${
CMAKE_TARGETS
}
-j8
cmake
--build
${
BUILD_DIR
}
${
CMAKE_TARGETS
}
-j8
mkdir
-p
${
BUILD_DIR
}
/lib/
mkdir
-p
${
BUILD_DIR
}
/lib/
ls
${
BUILD_DIR
}
g++
-fPIC
-g
-shared
-o
${
BUILD_DIR
}
/lib/libext_server.
${
LIB_EXT
}
\
g++
-fPIC
-g
-shared
-o
${
BUILD_DIR
}
/lib/libext_server.
${
LIB_EXT
}
\
${
GCC_ARCH
}
\
${
GCC_ARCH
}
\
${
WHOLE_ARCHIVE
}
${
BUILD_DIR
}
/ex
amples/
server/libext_server.a
${
NO_WHOLE_ARCHIVE
}
\
${
WHOLE_ARCHIVE
}
${
BUILD_DIR
}
/ex
t_
server/libext_server.a
${
NO_WHOLE_ARCHIVE
}
\
${
BUILD_DIR
}
/common/libcommon.a
\
${
BUILD_DIR
}
/common/libcommon.a
\
${
BUILD_DIR
}
/libllama.a
\
${
BUILD_DIR
}
/libllama.a
\
-Wl
,-rpath,
\$
ORIGIN
\
-Wl
,-rpath,
\$
ORIGIN
\
...
@@ -113,7 +110,7 @@ compress_libs() {
...
@@ -113,7 +110,7 @@ compress_libs() {
# Keep the local tree clean after we're done with the build
# Keep the local tree clean after we're done with the build
cleanup
()
{
cleanup
()
{
(
cd
${
LLAMACPP_DIR
}
/
examples/server/
&&
git checkout CMakeLists.txt
server.cpp
)
(
cd
${
LLAMACPP_DIR
}
/
&&
git checkout CMakeLists.txt
)
if
[
-n
"
$(
ls
-A
../patches/
*
.diff
)
"
]
;
then
if
[
-n
"
$(
ls
-A
../patches/
*
.diff
)
"
]
;
then
for
patch
in
../patches/
*
.diff
;
do
for
patch
in
../patches/
*
.diff
;
do
...
...
llm/generate/gen_windows.ps1
View file @
85129d3a
...
@@ -82,8 +82,8 @@ function git_module_setup {
...
@@ -82,8 +82,8 @@ function git_module_setup {
function
apply_patches
{
function
apply_patches
{
# Wire up our CMakefile
# Wire up our CMakefile
if
(
!
(
Select-String
-Path
"
${script:llamacppDir}
/
examples/server/
CMakeLists.txt"
-Pattern
'ollama'
))
{
if
(
!
(
Select-String
-Path
"
${script:llamacppDir}
/CMakeLists.txt"
-Pattern
'ollama'
))
{
Add-Content
-Path
"
${script:llamacppDir}
/
examples/server/
CMakeLists.txt"
-Value
'
include (../../../ext_server/CMakeLists.txt
) # ollama'
Add-Content
-Path
"
${script:llamacppDir}
/CMakeLists.txt"
-Value
'
add_subdirectory(../ext_server ext_server
) # ollama'
}
}
# Apply temporary patches until fix is upstream
# Apply temporary patches until fix is upstream
...
@@ -107,11 +107,6 @@ function apply_patches {
...
@@ -107,11 +107,6 @@ function apply_patches {
Set-Location
-Path
${script:llamacppDir}
Set-Location
-Path
${script:llamacppDir}
git
apply
$patch
.
FullName
git
apply
$patch
.
FullName
}
}
# Avoid duplicate main symbols when we link into the cgo binary
$content
=
Get-Content
-Path
"
${script:llamacppDir}
/examples/server/server.cpp"
$content
=
$content
-replace
'int main\('
,
'int __main('
Set-Content
-Path
"
${script:llamacppDir}
/examples/server/server.cpp"
-Value
$content
}
}
function
build
{
function
build
{
...
@@ -173,8 +168,8 @@ function cleanup {
...
@@ -173,8 +168,8 @@ function cleanup {
git
checkout
$file
git
checkout
$file
}
}
}
}
Set-Location
"
${script:llamacppDir}
/
examples/server
"
Set-Location
"
${script:llamacppDir}
/"
git
checkout
CMakeLists.txt
server.cpp
git
checkout
CMakeLists.txt
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment