Skip to content

[User] Android build fails with "ld.lld: error: undefined symbol: clGetPlatformIDs" #3525

Closed
@Mabbs

Description

@Mabbs

Prerequisites

Please answer the following questions for yourself before submitting an issue.

  • I am running the latest code. Development is very rapid so there are no tagged versions as of now.
  • I carefully followed the README.md.
  • I searched using keywords relevant to my issue to make sure that I am creating a new issue that is not already open (or closed).
  • I reviewed the Discussions, and have a new bug or useful enhancement to share.

Expected Behavior

I am trying to use this tutorial to compile llama.cpp.

Current Behavior

Compilation failed.

Environment and Context

Please provide detailed information about your computer setup. This is important in case the issue is not reproducible except for under certain specific conditions.

  • Physical (or virtual) hardware you are using, e.g. for Linux:

Architecture: aarch64
CPU op-mode(s): 32-bit, 64-bit
Byte Order: Little Endian
CPU(s): 8
On-line CPU(s) list: 0-7
Vendor ID: Qualcomm
Model name: Kryo-V2
Model: 4
Thread(s) per core: 1
Core(s) per socket: 4
Socket(s): 1
Stepping: 0xa
CPU(s) scaling MHz: 100%
CPU max MHz: 1900.8000
CPU min MHz: 300.0000
BogoMIPS: 38.00
Flags: fp asimd evtstrm aes pmull sha1 sha2 crc32
Model name: Falkor-V1/Kryo
Model: 1
Thread(s) per core: 1
Core(s) per socket: 4
Socket(s): 1
Stepping: 0xa
CPU(s) scaling MHz: 96%
CPU max MHz: 2457.6001
CPU min MHz: 300.0000
BogoMIPS: 38.00
Flags: fp asimd evtstrm aes pmull sha1 sha2 crc32
Caches (sum of all):
L1d: 384 KiB (8 instances)
L1i: 384 KiB (8 instances)
L2: 3 MiB (2 instances)

  • Operating System, e.g. for Linux:

Linux localhost 4.4.207-perf-g4f4b497d7bf8 #1 SMP PREEMPT Wed Dec 25 02:26:18 CST 2019 aarch64 Android

  • SDK version, e.g. for Linux:

GNU Make 4.4.1
Built for aarch64-unknown-linux-android
Copyright (C) 1988-2023 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later https://gnu.org/licenses/gpl.html
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
clang version 17.0.2
Target: aarch64-unknown-linux-android24
Thread model: posix
InstalledDir: /data/data/com.termux/files/usr/bin

Steps to Reproduce

Follow the tutorial step by step.

Failure Logs

~/llama.cpp $ make LLAMA_CLBLAST=1
Package clblast was not found in the pkg-config search path.
Perhaps you should add the directory containing `clblast.pc'
to the PKG_CONFIG_PATH environment variable
No package 'clblast' found
Package clblast was not found in the pkg-config search path.
Perhaps you should add the directory containing `clblast.pc'
to the PKG_CONFIG_PATH environment variable
No package 'clblast' found
Package clblast was not found in the pkg-config search path.
Perhaps you should add the directory containing `clblast.pc'
to the PKG_CONFIG_PATH environment variable
No package 'clblast' found
Package clblast was not found in the pkg-config search path.
Perhaps you should add the directory containing `clblast.pc'
to the PKG_CONFIG_PATH environment variable
No package 'clblast' found
Package clblast was not found in the pkg-config search path.
Perhaps you should add the directory containing `clblast.pc'
to the PKG_CONFIG_PATH environment variable
No package 'clblast' found
I llama.cpp build info: 
I UNAME_S:   Linux
I UNAME_P:   unknown
I UNAME_M:   aarch64
I CFLAGS:    -I. -Icommon -D_XOPEN_SOURCE=600 -D_GNU_SOURCE -DNDEBUG -DGGML_USE_K_QUANTS -DGGML_USE_CLBLAST   -std=c11   -fPIC -O3 -Wall -Wextra -Wpedantic -Wcast-qual -Wno-unused-function -Wshadow -Wstrict-prototypes -Wpointer-arith -Wmissing-prototypes -Werror=implicit-int -Werror=implicit-function-declaration -Wunreachable-code-break -Wunreachable-code-return -Wdouble-promotion -pthread -mcpu=native  
I CXXFLAGS:  -I. -Icommon -D_XOPEN_SOURCE=600 -D_GNU_SOURCE -DNDEBUG -DGGML_USE_K_QUANTS -DGGML_USE_CLBLAST   -std=c++11 -fPIC -O3 -Wall -Wextra -Wpedantic -Wcast-qual -Wno-unused-function -Wmissing-declarations -Wmissing-noreturn -pthread -mcpu=native   -Wunreachable-code-break -Wunreachable-code-return -Wmissing-prototypes -Wextra-semi 
I NVCCFLAGS:  -I. -Icommon -D_XOPEN_SOURCE=600 -D_GNU_SOURCE -DNDEBUG -DGGML_USE_K_QUANTS -DGGML_USE_CLBLAST   -std=c++11 -fPIC -O3 -Wall -Wextra -Wpedantic -Wcast-qual -Wno-unused-function -Wmissing-declarations -Wmissing-noreturn -pthread -mcpu=native     -Wno-pedantic -Xcompiler "-Wunreachable-code-break -Wunreachable-code-return -Wmissing-prototypes -Wextra-semi "
I LDFLAGS:    
I CC:        clang version 17.0.2
I CXX:       clang version 17.0.2

cc  -I. -Icommon -D_XOPEN_SOURCE=600 -D_GNU_SOURCE -DNDEBUG -DGGML_USE_K_QUANTS -DGGML_USE_CLBLAST   -std=c11   -fPIC -O3 -Wall -Wextra -Wpedantic -Wcast-qual -Wno-unused-function -Wshadow -Wstrict-prototypes -Wpointer-arith -Wmissing-prototypes -Werror=implicit-int -Werror=implicit-function-declaration -Wunreachable-code-break -Wunreachable-code-return -Wdouble-promotion -pthread -mcpu=native     -c ggml.c -o ggml.o
ggml.c:2456:5: warning: implicit conversion increases floating-point precision: 'float32_t' (aka 'float') to 'ggml_float' (aka 'double') [-Wdouble-promotion]
 2456 |     GGML_F16_VEC_REDUCE(sumf, sum);
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ggml.c:1983:41: note: expanded from macro 'GGML_F16_VEC_REDUCE'
 1983 |     #define GGML_F16_VEC_REDUCE         GGML_F32Cx4_REDUCE
      |                                         ^
ggml.c:1973:38: note: expanded from macro 'GGML_F32Cx4_REDUCE'
 1973 |     #define GGML_F32Cx4_REDUCE       GGML_F32x4_REDUCE
      |                                      ^
ggml.c:1903:11: note: expanded from macro 'GGML_F32x4_REDUCE'
 1903 |     res = GGML_F32x4_REDUCE_ONE(x[0]);         \
      |         ~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~
ggml.c:1888:34: note: expanded from macro 'GGML_F32x4_REDUCE_ONE'
 1888 | #define GGML_F32x4_REDUCE_ONE(x) vaddvq_f32(x)
      |                                  ^~~~~~~~~~~~~
ggml.c:3716:9: warning: implicit conversion increases floating-point precision: 'float32_t' (aka 'float') to 'ggml_float' (aka 'double') [-Wdouble-promotion]
 3716 |         GGML_F16_VEC_REDUCE(sumf[k], sum[k]);
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ggml.c:1983:41: note: expanded from macro 'GGML_F16_VEC_REDUCE'
 1983 |     #define GGML_F16_VEC_REDUCE         GGML_F32Cx4_REDUCE
      |                                         ^
ggml.c:1973:38: note: expanded from macro 'GGML_F32Cx4_REDUCE'
 1973 |     #define GGML_F32Cx4_REDUCE       GGML_F32x4_REDUCE
      |                                      ^
ggml.c:1903:11: note: expanded from macro 'GGML_F32x4_REDUCE'
 1903 |     res = GGML_F32x4_REDUCE_ONE(x[0]);         \
      |         ~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~
ggml.c:1888:34: note: expanded from macro 'GGML_F32x4_REDUCE_ONE'
 1888 | #define GGML_F32x4_REDUCE_ONE(x) vaddvq_f32(x)
      |                                  ^~~~~~~~~~~~~
2 warnings generated.
aarch64-linux-android-clang++ -I. -Icommon -D_XOPEN_SOURCE=600 -D_GNU_SOURCE -DNDEBUG -DGGML_USE_K_QUANTS -DGGML_USE_CLBLAST   -std=c++11 -fPIC -O3 -Wall -Wextra -Wpedantic -Wcast-qual -Wno-unused-function -Wmissing-declarations -Wmissing-noreturn -pthread -mcpu=native   -Wunreachable-code-break -Wunreachable-code-return -Wmissing-prototypes -Wextra-semi  -c llama.cpp -o llama.o
aarch64-linux-android-clang++ -I. -Icommon -D_XOPEN_SOURCE=600 -D_GNU_SOURCE -DNDEBUG -DGGML_USE_K_QUANTS -DGGML_USE_CLBLAST   -std=c++11 -fPIC -O3 -Wall -Wextra -Wpedantic -Wcast-qual -Wno-unused-function -Wmissing-declarations -Wmissing-noreturn -pthread -mcpu=native   -Wunreachable-code-break -Wunreachable-code-return -Wmissing-prototypes -Wextra-semi  -c common/common.cpp -o common.o
aarch64-linux-android-clang++ -I. -Icommon -D_XOPEN_SOURCE=600 -D_GNU_SOURCE -DNDEBUG -DGGML_USE_K_QUANTS -DGGML_USE_CLBLAST   -std=c++11 -fPIC -O3 -Wall -Wextra -Wpedantic -Wcast-qual -Wno-unused-function -Wmissing-declarations -Wmissing-noreturn -pthread -mcpu=native   -Wunreachable-code-break -Wunreachable-code-return -Wmissing-prototypes -Wextra-semi  -c common/console.cpp -o console.o
aarch64-linux-android-clang++ -I. -Icommon -D_XOPEN_SOURCE=600 -D_GNU_SOURCE -DNDEBUG -DGGML_USE_K_QUANTS -DGGML_USE_CLBLAST   -std=c++11 -fPIC -O3 -Wall -Wextra -Wpedantic -Wcast-qual -Wno-unused-function -Wmissing-declarations -Wmissing-noreturn -pthread -mcpu=native   -Wunreachable-code-break -Wunreachable-code-return -Wmissing-prototypes -Wextra-semi  -c common/grammar-parser.cpp -o grammar-parser.o
cc -I. -Icommon -D_XOPEN_SOURCE=600 -D_GNU_SOURCE -DNDEBUG -DGGML_USE_K_QUANTS -DGGML_USE_CLBLAST   -std=c11   -fPIC -O3 -Wall -Wextra -Wpedantic -Wcast-qual -Wno-unused-function -Wshadow -Wstrict-prototypes -Wpointer-arith -Wmissing-prototypes -Werror=implicit-int -Werror=implicit-function-declaration -Wunreachable-code-break -Wunreachable-code-return -Wdouble-promotion -pthread -mcpu=native   -c k_quants.c -o k_quants.o
aarch64-linux-android-clang++ -I. -Icommon -D_XOPEN_SOURCE=600 -D_GNU_SOURCE -DNDEBUG -DGGML_USE_K_QUANTS -DGGML_USE_CLBLAST   -std=c++11 -fPIC -O3 -Wall -Wextra -Wpedantic -Wcast-qual -Wno-unused-function -Wmissing-declarations -Wmissing-noreturn -pthread -mcpu=native   -Wunreachable-code-break -Wunreachable-code-return -Wmissing-prototypes -Wextra-semi  -c ggml-opencl.cpp -o ggml-opencl.o
cc  -I. -Icommon -D_XOPEN_SOURCE=600 -D_GNU_SOURCE -DNDEBUG -DGGML_USE_K_QUANTS -DGGML_USE_CLBLAST   -std=c11   -fPIC -O3 -Wall -Wextra -Wpedantic -Wcast-qual -Wno-unused-function -Wshadow -Wstrict-prototypes -Wpointer-arith -Wmissing-prototypes -Werror=implicit-int -Werror=implicit-function-declaration -Wunreachable-code-break -Wunreachable-code-return -Wdouble-promotion -pthread -mcpu=native     -c ggml-alloc.c -o ggml-alloc.o
aarch64-linux-android-clang++ -I. -Icommon -D_XOPEN_SOURCE=600 -D_GNU_SOURCE -DNDEBUG -DGGML_USE_K_QUANTS -DGGML_USE_CLBLAST   -std=c++11 -fPIC -O3 -Wall -Wextra -Wpedantic -Wcast-qual -Wno-unused-function -Wmissing-declarations -Wmissing-noreturn -pthread -mcpu=native   -Wunreachable-code-break -Wunreachable-code-return -Wmissing-prototypes -Wextra-semi  examples/main/main.cpp ggml.o llama.o common.o console.o grammar-parser.o k_quants.o ggml-opencl.o ggml-alloc.o -o main  
ld.lld: error: undefined symbol: clGetPlatformIDs
>>> referenced by ggml-opencl.cpp
>>>               ggml-opencl.o:(ggml_cl_init)

ld.lld: error: undefined symbol: clGetPlatformInfo
>>> referenced by ggml-opencl.cpp
>>>               ggml-opencl.o:(ggml_cl_init)
>>> referenced by ggml-opencl.cpp
>>>               ggml-opencl.o:(ggml_cl_init)

ld.lld: error: undefined symbol: clGetDeviceIDs
>>> referenced by ggml-opencl.cpp
>>>               ggml-opencl.o:(ggml_cl_init)

ld.lld: error: undefined symbol: clGetDeviceInfo
>>> referenced by ggml-opencl.cpp
>>>               ggml-opencl.o:(ggml_cl_init)
>>> referenced by ggml-opencl.cpp
>>>               ggml-opencl.o:(ggml_cl_init)
>>> referenced by ggml-opencl.cpp
>>>               ggml-opencl.o:(ggml_cl_init)
>>> referenced 1 more times

ld.lld: error: undefined symbol: clCreateContext
>>> referenced by ggml-opencl.cpp
>>>               ggml-opencl.o:(ggml_cl_init)

ld.lld: error: undefined symbol: clCreateCommandQueue
>>> referenced by ggml-opencl.cpp
>>>               ggml-opencl.o:(ggml_cl_init)
>>> referenced by ggml-opencl.cpp
>>>               ggml-opencl.o:(ggml_cl_init)

ld.lld: error: undefined symbol: clCreateProgramWithSource
>>> referenced by ggml-opencl.cpp
>>>               ggml-opencl.o:(ggml_cl_init)

ld.lld: error: undefined symbol: clBuildProgram
>>> referenced by ggml-opencl.cpp
>>>               ggml-opencl.o:(ggml_cl_init)

ld.lld: error: undefined symbol: clCreateKernel
>>> referenced by ggml-opencl.cpp
>>>               ggml-opencl.o:(ggml_cl_init)
>>> referenced by ggml-opencl.cpp
>>>               ggml-opencl.o:(ggml_cl_init)
>>> referenced by ggml-opencl.cpp
>>>               ggml-opencl.o:(ggml_cl_init)
>>> referenced 21 more times

ld.lld: error: undefined symbol: clGetProgramBuildInfo
>>> referenced by ggml-opencl.cpp
>>>               ggml-opencl.o:(ggml_cl_init)
>>> referenced by ggml-opencl.cpp
>>>               ggml-opencl.o:(ggml_cl_init)

ld.lld: error: undefined symbol: clReleaseMemObject
>>> referenced by ggml-opencl.cpp
>>>               ggml-opencl.o:(ggml_cl_free_data)
>>> referenced by ggml-opencl.cpp
>>>               ggml-opencl.o:(ggml_cl_mul)
>>> referenced by ggml-opencl.cpp
>>>               ggml-opencl.o:(ggml_cl_mul)
>>> referenced 11 more times

ld.lld: error: undefined symbol: clSetKernelArg
>>> referenced by ggml-opencl.cpp
>>>               ggml-opencl.o:(ggml_cl_mul)
>>> referenced by ggml-opencl.cpp
>>>               ggml-opencl.o:(ggml_cl_mul)
>>> referenced by ggml-opencl.cpp
>>>               ggml-opencl.o:(ggml_cl_mul)
>>> referenced 18 more times

ld.lld: error: undefined symbol: clEnqueueNDRangeKernel
>>> referenced by ggml-opencl.cpp
>>>               ggml-opencl.o:(ggml_cl_mul)
>>> referenced by ggml-opencl.cpp
>>>               ggml-opencl.o:(ggml_cl_mul)
>>> referenced by ggml-opencl.cpp
>>>               ggml-opencl.o:(ggml_cl_mul_mat_q_f32(ggml_tensor const*, ggml_tensor const*, ggml_tensor*))
>>> referenced 1 more times

ld.lld: error: undefined symbol: clReleaseEvent
>>> referenced by ggml-opencl.cpp
>>>               ggml-opencl.o:(ggml_cl_mul)
>>> referenced by ggml-opencl.cpp
>>>               ggml-opencl.o:(ggml_cl_mul)
>>> referenced by ggml-opencl.cpp
>>>               ggml-opencl.o:(ggml_cl_mul)
>>> referenced 3 more times

ld.lld: error: undefined symbol: clFinish
>>> referenced by ggml-opencl.cpp
>>>               ggml-opencl.o:(ggml_cl_mul)
>>> referenced by ggml-opencl.cpp
>>>               ggml-opencl.o:(ggml_cl_mul)
>>> referenced by ggml-opencl.cpp
>>>               ggml-opencl.o:(ggml_cl_mul)
>>> referenced 4 more times

ld.lld: error: undefined symbol: clEnqueueReadBuffer
>>> referenced by ggml-opencl.cpp
>>>               ggml-opencl.o:(ggml_cl_mul)
>>> referenced by ggml-opencl.cpp
>>>               ggml-opencl.o:(ggml_cl_mul)
>>> referenced by ggml-opencl.cpp
>>>               ggml-opencl.o:(ggml_cl_mul)
>>> referenced 3 more times

ld.lld: error: undefined symbol: clblast::StatusCode clblast::Gemm<float>(clblast::Layout, clblast::Transpose, clblast::Transpose, unsigned long, unsigned long, unsigned long, float, _cl_mem*, unsigned long, unsigned long, _cl_mem*, unsigned long, unsigned long, float, _cl_mem*, unsigned long, unsigned long, _cl_command_queue**, _cl_event**, _cl_mem*)
>>> referenced by ggml-opencl.cpp
>>>               ggml-opencl.o:(ggml_cl_mul_mat)
>>> referenced by ggml-opencl.cpp
>>>               ggml-opencl.o:(ggml_cl_mul_mat_q_f32(ggml_tensor const*, ggml_tensor const*, ggml_tensor*))

ld.lld: error: undefined symbol: clEnqueueWriteBuffer
>>> referenced by ggml-opencl.cpp
>>>               ggml-opencl.o:(ggml_cl_mul_mat)
>>> referenced by ggml-opencl.cpp
>>>               ggml-opencl.o:(ggml_cl_h2d_tensor_2d(_cl_command_queue*, _cl_mem*, unsigned long, ggml_tensor const*, unsigned long, unsigned long, _cl_event**))

ld.lld: error: undefined symbol: clblast::StatusCode clblast::Gemm<unsigned short>(clblast::Layout, clblast::Transpose, clblast::Transpose, unsigned long, unsigned long, unsigned long, unsigned short, _cl_mem*, unsigned long, unsigned long, _cl_mem*, unsigned long, unsigned long, unsigned short, _cl_mem*, unsigned long, unsigned long, _cl_command_queue**, _cl_event**, _cl_mem*)
>>> referenced by ggml-opencl.cpp
>>>               ggml-opencl.o:(ggml_cl_mul_mat)

ld.lld: error: undefined symbol: clCreateBuffer
>>> referenced by ggml-opencl.cpp
>>>               ggml-opencl.o:(ggml_cl_pool_malloc(unsigned long, unsigned long*))

ld.lld: error: too many errors emitted, stopping now (use --error-limit=0 to see all errors)
aarch64-linux-android-clang++: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [Makefile:543: main] Error 1

Metadata

Metadata

Assignees

No one assigned

    Labels

    androidIssues specific to AndroidbuildCompilation issues

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions