llama.cpp icon indicating copy to clipboard operation
llama.cpp copied to clipboard

[build] Compilation error on build: k_quants.h:26:15: error: expected declaration specifiers or '...' before 'sizeof'

Open ya-ds-web opened this issue 1 year ago • 3 comments

Prerequisites

Check out the master branch. Run: make LLAMA_CUBLAS=1

Expected Behavior

build succeed

Current Behavior

getting compilation error like:

I llama.cpp build info: I UNAME_S: Linux I UNAME_P: unknown I UNAME_M: x86_64 I CFLAGS: -I. -O3 -std=c11 -fPIC -DNDEBUG -Wall -Wextra -Wpedantic -Wcast-qual -Wdouble-promotion -Wshadow -Wstrict-prototypes -Wpointer-arith -pthread -march=native -mtune=native -DGGML_USE_K_QUANTS -DGGML_USE_CUBLAS -I/usr/local/cuda/include -I/opt/cuda/include -I/targets/x86_64-linux/include I CXXFLAGS: -I. -I./examples -O3 -std=c++11 -fPIC -DNDEBUG -Wall -Wextra -Wpedantic -Wcast-qual -Wno-unused-function -Wno-multichar -pthread -march=native -mtune=native -DGGML_USE_CUBLAS -I/usr/local/cuda/include -I/opt/cuda/include -I/targets/x86_64-linux/include I LDFLAGS: -lcublas -lculibos -lcudart -lcublasLt -lpthread -ldl -lrt -L/usr/local/cuda/lib64 -L/opt/cuda/lib64 -L/targets/x86_64-linux/lib I CC: cc (conda-forge gcc 12.2.0-19) 12.2.0 I CXX: g++ (conda-forge gcc 12.2.0-19) 12.2.0

cc -I. -O3 -std=c11 -fPIC -DNDEBUG -Wall -Wextra -Wpedantic -Wcast-qual -Wdouble-promotion -Wshadow -Wstrict-prototypes -Wpointer-arith -pthread -march=native -mtune=native -DGGML_USE_K_QUANTS -DGGML_USE_CUBLAS -I/usr/local/cuda/include -I/opt/cuda/include -I/targets/x86_64-linux/include -c ggml.c -o ggml.o In file included from ggml.c:7: k_quants.h:26:15: error: expected declaration specifiers or '...' before 'sizeof' 26 | static_assert(sizeof(block_q2_K) == 2sizeof(ggml_fp16_t) + QK_K/16 + QK_K/4, "wrong q2_K block size/padding"); | ^~~~~~ k_quants.h:26:79: error: expected declaration specifiers or '...' before string constant 26 | static_assert(sizeof(block_q2_K) == 2sizeof(ggml_fp16_t) + QK_K/16 + QK_K/4, "wrong q2_K block size/padding"); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ k_quants.h:38:15: error: expected declaration specifiers or '...' before 'sizeof' 38 | static_assert(sizeof(block_q3_K) == sizeof(ggml_fp16_t) + QK_K / 4 + 11 * QK_K / 64, "wrong q3_K block size/padding"); | ^~~~~~ k_quants.h:38:86: error: expected declaration specifiers or '...' before string constant 38 | static_assert(sizeof(block_q3_K) == sizeof(ggml_fp16_t) + QK_K / 4 + 11 * QK_K / 64, "wrong q3_K block size/padding"); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ k_quants.h:50:15: error: expected declaration specifiers or '...' before 'sizeof' 50 | static_assert(sizeof(block_q4_K) == 2sizeof(ggml_fp16_t) + 3QK_K/64 + QK_K/2, "wrong q4_K block size/padding"); | ^~~~~~ k_quants.h:50:81: error: expected declaration specifiers or '...' before string constant 50 | static_assert(sizeof(block_q4_K) == 2sizeof(ggml_fp16_t) + 3QK_K/64 + QK_K/2, "wrong q4_K block size/padding"); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ k_quants.h:63:15: error: expected declaration specifiers or '...' before 'sizeof' 63 | static_assert(sizeof(block_q5_K) == 2sizeof(ggml_fp16_t) + 3QK_K/64 + QK_K/2 + QK_K/8, "wrong q5_K block size/padding"); | ^~~~~~ k_quants.h:63:90: error: expected declaration specifiers or '...' before string constant 63 | static_assert(sizeof(block_q5_K) == 2sizeof(ggml_fp16_t) + 3QK_K/64 + QK_K/2 + QK_K/8, "wrong q5_K block size/padding"); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ k_quants.h:75:15: error: expected declaration specifiers or '...' before 'sizeof' 75 | static_assert(sizeof(block_q6_K) == sizeof(ggml_fp16_t) + QK_K / 16 + 3QK_K/4, "wrong q6_K block size/padding"); | ^~~~~~ k_quants.h:75:81: error: expected declaration specifiers or '...' before string constant 75 | static_assert(sizeof(block_q6_K) == sizeof(ggml_fp16_t) + QK_K / 16 + 3QK_K/4, "wrong q6_K block size/padding"); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ k_quants.h:83:15: error: expected declaration specifiers or '...' before 'sizeof' 83 | static_assert(sizeof(block_q8_K) == sizeof(float) + QK_K + QK_K/16sizeof(int16_t), "wrong q8_K block size/padding"); | ^~~~~~ k_quants.h:83:85: error: expected declaration specifiers or '...' before string constant 83 | static_assert(sizeof(block_q8_K) == sizeof(float) + QK_K + QK_K/16sizeof(int16_t), "wrong q8_K block size/padding"); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ make: *** [Makefile:249: ggml.o] Error 1

Environment and Context

I am using fedora 38 (Linux 6.2.15-300.fc38.x86_64) inside an kvm vm gcc and gxx versions can be seen from the otput above I CC: cc (conda-forge gcc 12.2.0-19) 12.2.0 I CXX: g++ (conda-forge gcc 12.2.0-19) 12.2.0

ya-ds-web avatar Jun 10 '23 13:06 ya-ds-web

Replacing static_assert with _Static_assert in k_quants.h fixed the compile for me on x86_64-linux-gnu using gcc-8.1.0.

marcom avatar Jun 14 '23 13:06 marcom

thank you for the work around, I wonder how can I idetify the correct c compiler I can use to build it wthould the modification ?

ya-ds-web avatar Jun 18 '23 14:06 ya-ds-web

According to https://github.com/ggerganov/llama.cpp/actions/runs/5304488298/jobs/9600839945#step:4:14 it compiles with gcc-8.4.0 and g++-9.4.0 on ubuntu 20.04 (Focal Fossa). You can see the successful CI builds by clicking on the little 'CI' badge at the top of the README in github.

marcom avatar Jun 18 '23 19:06 marcom

Replacing static_assert with _Static_assert in k_quants.h

Confirm that this hack is still required as of 7/5/23 31cfbb1

Sciumo avatar Jul 06 '23 02:07 Sciumo

This issue was closed because it has been inactive for 14 days since being marked as stale.

github-actions[bot] avatar Apr 10 '24 01:04 github-actions[bot]