llama.cpp: Compilation failed on macOS 10.7-8-9: 'clock_gettime' produce warnings and errors
PREREQUISITES
- I am running the latest code: 5a8c4f6
- I carefully followed the README.md.
- I have created a relevant issue in alpaca.cpp.
- I reviewed the Discussions, and have a new bug or useful enhancement to share.
EXPECTED BEHAVIOR
- Attempted to compile the binary for macOS 10.7, 10.8 and 10.9.
- Expected to run the chat app on an old macOS, that will be isolated from Internet.
ACTUAL BEHAVIOR
- Compilation is terminated with warnings and errors.
ENVIRONMENT AND CONTEXT
- Macbook pro 15 2012: macOS 10.8 Mountain Lion on Core i7 + 512 SDD + 16Gb RAM
- Parallels Virtual Machine: macOS 10.7 Lion on 20Gb HDD + 4Gb RAM
- X-Code 4.6.3
- Command Line Tools OS X Lion Nov2012
- MacPorts 2.8.1 10.7 (Lion)
- git --version 2.40.0
- clang --version 11.1.0
- port select --set clang mp-clang-11
- gcc --version 12.2.0
- port select --set gcc mp-gcc12
- export CC=gcc (in another re-try: export CC=clang)
- export CXX=gcc (in another re-try: export CXX=clang)
- Parallels Virtual Machine: macOS 10.7 Lion on 20Gb HDD + 4Gb RAM
FAILURE INFORMATION
- Same issue is reproduced on macOS 10.8 on VM and macOS 10.9 on real machine.
- Same issue is reproduced with gcc6 installed through Tigerbrew on macOS 10.9 real machine.
- Same issue is reproduced for ‘alpaca.cpp’: ‘clock_gettime’ produce mostly the same warnings and errors on this environment.
- ‘stdatomic.h’ issue is reproduced if latest gcc and clang versions are not set in ports and also CC and CXX vars are not set
- ‘-gnu11’, ‘-lrt’ and ‘-D_POSIX_C_SOURCE=199309L’ flags doesn’t help, ‘-gnu99’ gives more errors
- Compilation successful on macOS 10.14 (Mojave) VM with Command Line Tools for Xcode 11.3.1. Chat + 7b is working.
- Fix on this issue states that older OSX versions don’t implement ‘clock_gettime ()’ and author seem to find solution
STEPS TO REPRODUCE
- Clone the repo (or download the latest build and un-tar gz using tar -xvzf)
- cd the llama.cpp dir (or rename the latest build dir to ‘llama.cpp’ and cd there)
- make
FAILURE LOGS
CC=gcc and CXX=gcc env vars set:
I llama.cpp build info:
I UNAME_S: Darwin
I UNAME_P: i386
I UNAME_M: x86_64
I CFLAGS: -I. -O3 -DNDEBUG -std=c11 -fPIC -Wall -Wextra -Wpedantic -Wcast-qual -Wdouble-promotion -Wshadow -Wstrict-prototypes -Wpointer-arith -Wno-unused-function -pthread -march=native -mtune=native -DGGML_USE_ACCELERATE
I CXXFLAGS: -I. -I./examples -O3 -DNDEBUG -std=c++11 -fPIC -Wall -Wextra -Wpedantic -Wcast-qual -Wno-unused-function -pthread -march=native -mtune=native
I LDFLAGS: -framework Accelerate
I CC: gcc (MacPorts gcc12 12.2.0_2+stdlib_flag) 12.2.0
I CXX: gcc (MacPorts gcc12 12.2.0_2+stdlib_flag) 12.2.0
gcc -I. -O3 -DNDEBUG -std=c11 -fPIC -Wall -Wextra -Wpedantic -Wcast-qual -Wdouble-promotion -Wshadow -Wstrict-prototypes -Wpointer-arith -Wno-unused-function -pthread -march=native -mtune=native -DGGML_USE_ACCELERATE -c ggml.c -o ggml.o
ggml.c: In function 'ggml_time_ms':
ggml.c:376:5: warning: implicit declaration of function 'clock_gettime' [-Wimplicit-function-declaration]
376 | clock_gettime(CLOCK_MONOTONIC, &ts);
| ^~~~~~~~~~~~~
ggml.c:376:19: error: 'CLOCK_MONOTONIC' undeclared (first use in this function)
376 | clock_gettime(CLOCK_MONOTONIC, &ts);
| ^~~~~~~~~~~~~~~
ggml.c:376:19: note: each undeclared identifier is reported only once for each function it appears in
ggml.c: In function 'ggml_time_us':
ggml.c:382:19: error: 'CLOCK_MONOTONIC' undeclared (first use in this function)
382 | clock_gettime(CLOCK_MONOTONIC, &ts);
| ^~~~~~~~~~~~~~~
ggml.c: In function 'quantize_row_q4_1':
ggml.c:856:27: warning: unused variable 'y' [-Wunused-variable]
856 | block_q4_1 * restrict y = vy;
| ^
ggml.c:854:15: warning: unused variable 'nb' [-Wunused-variable]
854 | const int nb = k / QK;
| ^~
ggml.c: In function 'ggml_vec_sum_f32':
ggml.c:2531:14: warning: passing argument 1 of 'vDSP_sve' discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
2531 | vDSP_sve(x, 1, s, n);
| ^
In file included from /System/Library/Frameworks/vecLib.framework/Headers/vecLib.h:41,
from /System/Library/Frameworks/Accelerate.framework/Headers/Accelerate.h:20,
from ggml.c:143:
/System/Library/Frameworks/vecLib.framework/Headers/vDSP.h:4191:17: note: expected 'float *' but argument is of type 'const float *'
4191 | float * __vDSP_A,
| ~~~~~~~~~~~~~~^~~~~~~~
ggml.c: In function 'ggml_vec_max_f32':
ggml.c:2543:15: warning: passing argument 1 of 'vDSP_maxv' discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
2543 | vDSP_maxv(x, 1, s, n);
| ^
/System/Library/Frameworks/vecLib.framework/Headers/vDSP.h:3625:17: note: expected 'float *' but argument is of type 'const float *'
3625 | float * __vDSP_A,
| ~~~~~~~~~~~~~~^~~~~~~~
make: *** [ggml.o] Error 1
CC=clang and CXX=clang env vars set:
I llama.cpp build info:
I UNAME_S: Darwin
I UNAME_P: i386
I UNAME_M: x86_64
I CFLAGS: -I. -O3 -DNDEBUG -std=c11 -fPIC -Wall -Wextra -Wpedantic -Wcast-qual -Wdouble-promotion -Wshadow -Wstrict-prototypes -Wpointer-arith -Wno-unused-function -pthread -march=native -mtune=native -DGGML_USE_ACCELERATE
I CXXFLAGS: -I. -I./examples -O3 -DNDEBUG -std=c++11 -fPIC -Wall -Wextra -Wpedantic -Wcast-qual -Wno-unused-function -pthread -march=native -mtune=native
I LDFLAGS: -framework Accelerate
I CC: clang version 11.1.0
I CXX: clang version 11.1.0
clang -I. -O3 -DNDEBUG -std=c11 -fPIC -Wall -Wextra -Wpedantic -Wcast-qual -Wdouble-promotion -Wshadow -Wstrict-prototypes -Wpointer-arith -Wno-unused-function -pthread -march=native -mtune=native -DGGML_USE_ACCELERATE -c ggml.c -o ggml.o
ggml.c:376:5: warning: implicit declaration of function 'clock_gettime' is invalid in C99 [-Wimplicit-function-declaration]
clock_gettime(CLOCK_MONOTONIC, &ts);
^
ggml.c:376:19: error: use of undeclared identifier 'CLOCK_MONOTONIC'
clock_gettime(CLOCK_MONOTONIC, &ts);
^
ggml.c:382:5: warning: implicit declaration of function 'clock_gettime' is invalid in C99 [-Wimplicit-function-declaration]
clock_gettime(CLOCK_MONOTONIC, &ts);
^
ggml.c:382:19: error: use of undeclared identifier 'CLOCK_MONOTONIC'
clock_gettime(CLOCK_MONOTONIC, &ts);
^
ggml.c:854:15: warning: unused variable 'nb' [-Wunused-variable]
const int nb = k / QK;
^
ggml.c:856:27: warning: unused variable 'y' [-Wunused-variable]
block_q4_1 * restrict y = vy;
^
ggml.c:1813:5: warning: implicit conversion increases floating-point precision: 'float' to 'ggml_float' (aka 'double') [-Wdouble-promotion]
GGML_F16_VEC_REDUCE(sumf, sum);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ggml.c:1427:37: note: expanded from macro 'GGML_F16_VEC_REDUCE'
#define GGML_F16_VEC_REDUCE GGML_F32Cx8_REDUCE
^
ggml.c:1417:33: note: expanded from macro 'GGML_F32Cx8_REDUCE'
#define GGML_F32Cx8_REDUCE GGML_F32x8_REDUCE
^
ggml.c:1364:11: note: expanded from macro 'GGML_F32x8_REDUCE'
res = _mm_cvtss_f32(_mm_hadd_ps(t1, t1)); \
~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ggml.c:2372:9: warning: implicit conversion increases floating-point precision: 'float' to 'ggml_float' (aka 'double') [-Wdouble-promotion]
GGML_F16_VEC_REDUCE(sumf[k], sum[k]);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ggml.c:1427:37: note: expanded from macro 'GGML_F16_VEC_REDUCE'
#define GGML_F16_VEC_REDUCE GGML_F32Cx8_REDUCE
^
ggml.c:1417:33: note: expanded from macro 'GGML_F32Cx8_REDUCE'
#define GGML_F32Cx8_REDUCE GGML_F32x8_REDUCE
^
ggml.c:1364:11: note: expanded from macro 'GGML_F32x8_REDUCE'
res = _mm_cvtss_f32(_mm_hadd_ps(t1, t1)); \
~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ggml.c:2531:14: warning: passing 'const float *' to parameter of type 'float *' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers]
vDSP_sve(x, 1, s, n);
^
/System/Library/Frameworks/vecLib.framework/Headers/vDSP.h:4191:17: note: passing argument to parameter '__vDSP_A' here
float * __vDSP_A,
^
ggml.c:2543:15: warning: passing 'const float *' to parameter of type 'float *' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers]
vDSP_maxv(x, 1, s, n);
^
/System/Library/Frameworks/vecLib.framework/Headers/vDSP.h:3625:17: note: passing argument to parameter '__vDSP_A' here
float * __vDSP_A,
^
8 warnings and 2 errors generated.
make: *** [ggml.o] Error 1
About this issue
- Original URL
- State: closed
- Created a year ago
- Comments: 20 (3 by maintainers)
I have also compiled alpaca.cpp for macOS 10.7 and looks like it is working on real machine with macOS 10.8:
…I love this ‘We are’ 😃
Haven’t tried configuring it yet, but at least - it is compiled successfully and running. Now I’m planning to investigate the whole environment setup and find the minimum configuration to compile on these old OS. Let me know if it will be useful to share this info.
Thank you all very much for helping me out!
I wouldn’t worry too much about those if it works ok!
As far as I can tell, the only consequence will be that the time values that will be printed out will all be 0. Feel free to open a PR adding an alternate timing mechanism that can be used if the more accurate one is unavailable?