From 8ba42095c534f94c34b48d1fb6be9fa9abbc9f72 Mon Sep 17 00:00:00 2001 From: Georgi Gerganov Date: Sun, 2 Jul 2023 21:53:52 +0300 Subject: [PATCH] Revert "ggml : do not use _GNU_SOURCE gratuitously (#1027)" This reverts commit 3f7a03ebe3b65be0792849e300a122f6a050e3f8. --- Makefile | 11 +++++------ examples/command/command.cpp | 2 +- examples/stream/stream.cpp | 2 +- examples/talk-llama/llama.cpp | 8 ++++++++ examples/talk-llama/talk-llama.cpp | 2 +- examples/talk/talk.cpp | 2 +- ggml.c | 1 + 7 files changed, 18 insertions(+), 10 deletions(-) diff --git a/Makefile b/Makefile index a9ae2e7a..045f711c 100644 --- a/Makefile +++ b/Makefile @@ -36,12 +36,11 @@ CFLAGS = -I. -O3 -DNDEBUG -std=c11 -fPIC CXXFLAGS = -I. -I./examples -O3 -DNDEBUG -std=c++11 -fPIC LDFLAGS = -# clock_gettime came in POSIX.1b (1993) -# CLOCK_MONOTONIC came in POSIX.1-2001 / SUSv3 as optional -# posix_memalign came in POSIX.1-2001 / SUSv3 -# M_PI is an XSI extension since POSIX.1-2001 / SUSv3, came in XPG1 (1985) -CFLAGS += -D_XOPEN_SOURCE=600 -CXXFLAGS += -D_XOPEN_SOURCE=600 +# ref: https://github.com/ggerganov/whisper.cpp/issues/37 +ifneq ($(wildcard /usr/include/musl/*),) + CFLAGS += -D_POSIX_SOURCE -D_GNU_SOURCE + CXXFLAGS += -D_POSIX_SOURCE -D_GNU_SOURCE +endif # RLIMIT_MEMLOCK came in BSD, is not specified in POSIX.1, # and on macOS its availability depends on enabling Darwin extensions diff --git a/examples/command/command.cpp b/examples/command/command.cpp index d39af730..54e3549f 100644 --- a/examples/command/command.cpp +++ b/examples/command/command.cpp @@ -6,8 +6,8 @@ // ref: https://github.com/ggerganov/whisper.cpp/issues/171 // -#include "common-sdl.h" #include "common.h" +#include "common-sdl.h" #include "whisper.h" #include diff --git a/examples/stream/stream.cpp b/examples/stream/stream.cpp index e44c1f60..cec5a2b7 100644 --- a/examples/stream/stream.cpp +++ b/examples/stream/stream.cpp @@ -3,8 +3,8 @@ // A very quick-n-dirty implementation serving mainly as a proof of concept. // -#include "common-sdl.h" #include "common.h" +#include "common-sdl.h" #include "whisper.h" #include diff --git a/examples/talk-llama/llama.cpp b/examples/talk-llama/llama.cpp index 04d78e03..942407b8 100644 --- a/examples/talk-llama/llama.cpp +++ b/examples/talk-llama/llama.cpp @@ -1,3 +1,11 @@ +// Defines fileno on msys: +#ifndef _GNU_SOURCE +#define _GNU_SOURCE +#include +#include +#include +#endif + #include "llama-util.h" #include "llama.h" diff --git a/examples/talk-llama/talk-llama.cpp b/examples/talk-llama/talk-llama.cpp index 18658669..57a02eac 100644 --- a/examples/talk-llama/talk-llama.cpp +++ b/examples/talk-llama/talk-llama.cpp @@ -1,8 +1,8 @@ // Talk with AI // -#include "common-sdl.h" #include "common.h" +#include "common-sdl.h" #include "whisper.h" #include "llama.h" diff --git a/examples/talk/talk.cpp b/examples/talk/talk.cpp index 12d98a00..651ca200 100644 --- a/examples/talk/talk.cpp +++ b/examples/talk/talk.cpp @@ -1,8 +1,8 @@ // Talk with AI // -#include "common-sdl.h" #include "common.h" +#include "common-sdl.h" #include "whisper.h" #include "gpt-2.h" diff --git a/ggml.c b/ggml.c index b7cfcf4e..88cbed7d 100644 --- a/ggml.c +++ b/ggml.c @@ -1,3 +1,4 @@ +#define _GNU_SOURCE // Defines CLOCK_MONOTONIC on Linux #define _CRT_SECURE_NO_DEPRECATE // Disables ridiculous "unsafe" warnigns on Windows #include "ggml.h"