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

fix: add POSIX functionality for Linux compilation

Open valentynbez opened this issue 1 year ago • 7 comments

Small fix to compile binaries properly on Linux:

  • defines CLOCK_MONOTONIC in ggml.c
  • Closes #54

valentynbez avatar Mar 12 '23 14:03 valentynbez

Can you add a short comment why this is required? (I assume some functions are not recognized but not obvious which ones)

prusnak avatar Mar 12 '23 15:03 prusnak

Sure!

valentynbez avatar Mar 12 '23 18:03 valentynbez

Sure!

I meant into the source code just above the #define

Btw the issue #54 mentions _POSIX_C_SOURCE=199309L; why did you chose newer standard and thus less compatibility?

prusnak avatar Mar 12 '23 18:03 prusnak

Small fix to compile binaries properly on Linux:

Which OS and which GCC version do you use?

For me the master compiles just fine on Debian 11 with GCC 10.2.1 (even without the proposed define).

prusnak avatar Mar 13 '23 12:03 prusnak

CentOS7 with GCC 10.2.0

valentynbez avatar Mar 13 '23 14:03 valentynbez

This flags has been discussed in whisper.cpp too and I still don't know when it should be added and when not. Hopefully someone can clarify.

https://github.com/ggerganov/whisper.cpp/issues/37 https://github.com/ggerganov/whisper.cpp/pull/576

ggerganov avatar Mar 13 '23 16:03 ggerganov

Now thinking more about this, probably the cleanest option is to add compilation flags to the build system like suggested in https://github.com/ggerganov/whisper.cpp/issues/37 + https://github.com/ggerganov/whisper.cpp/pull/576

CFLAGS += -D_POSIX_SOURCE -D_GNU_SOURCE
CXXFLAGS += -D_POSIX_SOURCE -D_GNU_SOURCE

We can probably set this for all compilers on all OSes, because either a compiler understands the flag and sets the value to the supported level or the flag is ignored.

@valentynbez can you confirm this fixed the issue for you on CentOS 7?

prusnak avatar Mar 18 '23 10:03 prusnak