Cant compile for an arm
Consolidate compiler generated dependencies of target utils [ 8%] Building CXX object CMakeFiles/utils.dir/utils.cpp.o clang++: error: the clang compiler does not support '-mcpu=native' make[2]: *** [CMakeFiles/utils.dir/build.make:76: CMakeFiles/utils.dir/utils.cpp.o] Error 1 make[1]: *** [CMakeFiles/Makefile2:110: CMakeFiles/utils.dir/all] Error 2 make: *** [Makefile:101: all] Error 2
if i will intentionally delete all -mcpu=native flags, then
[ 8%] Built target utils Consolidate compiler generated dependencies of target ggml [ 8%] Built target ggml [ 8%] Building CXX object CMakeFiles/llama.dir/llama.cpp.o /home/gh228df/llama.cpp/llama.cpp:1447:33: warning: cast from 'const char *' to 'char *' drops const qualifier [-Wcast-qual] finp.read ((char *) word.data(), len); ^ /home/gh228df/llama.cpp/llama.cpp:1448:33: warning: cast from 'const char *' to 'char *' drops const qualifier [-Wcast-qual] fout.write((char *) word.data(), len); ^ 2 warnings generated. [ 8%] Linking CXX static library libllama.a [ 8%] Built target llama [ 8%] Building CXX object CMakeFiles/main.dir/main.cpp.o /home/gh228df/llama.cpp/main.cpp:356:20: warning: unused variable 'embeddings' [-Wunused-variable] const auto embeddings = llama_get_embeddings(ctx); ^ /home/gh228df/llama.cpp/main.cpp:481:28: error: format string is not a string literal (potentially insecure) [-Werror,-Wformat-security] printf(buffer.c_str()); ^~~~~~~~~~~~~~ /home/gh228df/llama.cpp/main.cpp:481:28: note: treat the string as an argument to avoid this printf(buffer.c_str()); ^ "%s", 1 warning and 1 error generated. make[2]: *** [CMakeFiles/main.dir/build.make:76: CMakeFiles/main.dir/main.cpp.o] Error 1 make[1]: *** [CMakeFiles/Makefile2:191: CMakeFiles/main.dir/all] Error 2 make: *** [Makefile:101: all] Error 2
git pull and try again - you are on some old commit since main.cpp does not exist in the repo anymore.
git pulland try again - you are on some old commit sincemain.cppdoes not exist in the repo anymore.
nah it is the newest commit. i have clang 10 which is the newest for my linux mint and i still cant compile.
i think clang 10 just doesnt support mcpu. Is there a way to compile this for an arm?
I have the same issue when I try to build for Android from Manjaro Linux using the instructions in the README. I am on commit 5a5f8b1501fbb34367225544010ddfc306d6d2fe (latest as of right now). The full error message:
.../llama.cpp/build-android (master)> make
[ 6%] Building C object CMakeFiles/ggml.dir/ggml.c.o
clang: error: the clang compiler does not support '-mcpu=native'
make[2]: *** [CMakeFiles/ggml.dir/build.make:76: CMakeFiles/ggml.dir/ggml.c.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:193: CMakeFiles/ggml.dir/all] Error 2
make: *** [Makefile:101: all] Error 2
okay so there is a way to compile it directly on an android in termux. I think mcpu would work ONLY on arm64 machines while compiling(so basically on an arm macbook it would compile perfectly). but i get the same error described in this issue: https://github.com/ggerganov/llama.cpp/issues/402
However, on mysd865 powered device it just works, but i cant generate anything cuz it overflows memory pretty quick
@GH228 You can literally see clang-11 in the terminal screenshot you posted. You just aborted its installation. Can you try this version of clang?
nah, it wouldn't, cuz i tried clang 12 before and just typed out of curiosity if there is clang 11 but on my phone i have clang 16 available
I was able to compile llama cpp for android on a Intel CPU using linux after applying this patch to the CMakeList.txt:
@@ -196,7 +196,9 @@ # TODO: arm msvc? else() if (${CMAKE_SYSTEM_PROCESSOR} MATCHES "aarch64") + if (LLAMA_NATIVE) add_compile_options(-mcpu=native) + endif() endif() # TODO: armv6,7,8 version specific flags endif()