-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Closed
Labels
Description
Hi there! I'm attempting to build whisper.cpp for MUSL Linux for some lightweight systems, and I figured I would note the issues I ran into during the build.
- Alpine appears to not include
stdint.h, oralloca.hin its standard library when you install gcc. This results in a slew of errors:
localhost:~/whisper.cpp# make libwhisper.a
cc -O3 -std=c11 -Wall -Wextra -Wno-unused-parameter -Wno-unused-function -pthread -c ggml.c
In file included from ggml.h:7,
from ggml.c:1:
/usr/lib/gcc/aarch64-alpine-linux-musl/12.2.1/include/stdint.h:9:26: error: no include path in which to search for stdint.h
9 | # include_next <stdint.h>
| ^
ggml.h:107:5: error: unknown type name 'int64_t'
107 | int64_t perf_cycles;
| ^~~~~~~
~~snip~~
ggml.c:6:10: fatal error: alloca.h: No such file or directory
6 | #include <alloca.h>
| ^~~~~~~~~~
compilation terminated.
make: *** [Makefile:58: ggml.o] Error 1
localhost:~/whisper.cpp#
This fix is relatively simple, just install g++:
apk add g++
clock_gettimeandCLOCK_MONOTONICare seemingly undefined regardless of compiler used.
localhost:~/whisper.cpp# make libwhisper.a
cc -O3 -std=c11 -Wall -Wextra -Wno-unused-parameter -Wno-unused-function -pthread -c ggml.c
ggml.c: In function 'ggml_time_ms':
ggml.c:155:5: warning: implicit declaration of function 'clock_gettime' [-Wimplicit-function-declaration]
155 | clock_gettime(CLOCK_MONOTONIC, &ts);
| ^~~~~~~~~~~~~
ggml.c:155:19: error: 'CLOCK_MONOTONIC' undeclared (first use in this function)
155 | clock_gettime(CLOCK_MONOTONIC, &ts);
| ^~~~~~~~~~~~~~~
ggml.c:155:19: note: each undeclared identifier is reported only once for each function it appears in
ggml.c: In function 'ggml_time_us':
ggml.c:161:19: error: 'CLOCK_MONOTONIC' undeclared (first use in this function)
161 | clock_gettime(CLOCK_MONOTONIC, &ts);
| ^~~~~~~~~~~~~~~
make: *** [Makefile:58: ggml.o] Error 1
localhost:~/whisper.cpp#
Digging around the internet shows a fix for this as inserting #define _POSIX_C_SOURCE 199309L before including the time.h header. This appears to work successfully, placing it on line 10 of ggml.c. It would be nice if this issue could be fixed in some way. I would make a PR if I had sufficient knowledge to implement the required changes, which I don't.
ggerganov, trholding and alissonsleal