Skip to content

Commit a196ec7

Browse files
committed
Enable _GNU_SOURCE on Linux for POSIX/GNU extensions
Fixes CI failures: strdup, qsort_r, and clock_gettime are not declared under strict -std=c11 on Linux without _GNU_SOURCE.
1 parent 1f6c140 commit a196ec7

2 files changed

Lines changed: 6 additions & 4 deletions

File tree

Makefile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@ CC ?= cc
22
CFLAGS = -O2 -Wall -Wextra -std=c11 -Iinclude
33
LDFLAGS = -lm
44

5+
# On Linux, enable GNU extensions for strdup, qsort_r, clock_gettime, etc.
6+
UNAME_S := $(shell uname -s)
7+
ifeq ($(UNAME_S),Linux)
8+
CFLAGS += -D_GNU_SOURCE
9+
endif
10+
511
SRCS = src/platform.c src/gguf.c src/quant.c src/model.c \
612
src/transformer.c src/tokenizer.c src/sampler.c src/main.c
713
OBJS = $(SRCS:.c=.o)

src/platform.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
#if defined(__linux__)
2-
#define _POSIX_C_SOURCE 200112L
3-
#endif
4-
51
#include "platform.h"
62
#include <stdio.h>
73
#include <stdlib.h>

0 commit comments

Comments
 (0)