1From 07d66af3b0800764087c4151d4f6562d4f8cce05 Mon Sep 17 00:00:00 2001 2From: Fabrice Fontaine <fontaine.fabrice@gmail.com> 3Date: Mon, 14 Dec 2020 23:00:33 +0100 4Subject: [PATCH] Fix build without threads 5 6Build without threads is broken since version 2.29.0 and 7https://github.com/git/git/commit/15b52a44e0c92a0658e891194a5b0610d1f53afc: 8 9In file included from cache.h:4, 10 from blame.c:1: 11git-compat-util.h:1238:20: error: static declaration of 'flockfile' follows non-static declaration 12 static inline void flockfile(FILE *fh) 13 ^~~~~~~~~ 14In file included from git-compat-util.h:168, 15 from cache.h:4, 16 from blame.c:1: 17/nvme/rc-buildroot-test/scripts/instance-0/output-1/host/arm-buildroot-linux-uclibcgnueabihf/sysroot/usr/include/stdio.h:806:13: note: previous declaration of 'flockfile' was here 18 extern void flockfile (FILE *__stream) __THROW; 19 ^~~~~~~~~ 20In file included from cache.h:4, 21 from blame.c:1: 22git-compat-util.h:1242:20: error: static declaration of 'funlockfile' follows non-static declaration 23 static inline void funlockfile(FILE *fh) 24 ^~~~~~~~~~~ 25In file included from git-compat-util.h:168, 26 from cache.h:4, 27 from blame.c:1: 28/nvme/rc-buildroot-test/scripts/instance-0/output-1/host/arm-buildroot-linux-uclibcgnueabihf/sysroot/usr/include/stdio.h:813:13: note: previous declaration of 'funlockfile' was here 29 extern void funlockfile (FILE *__stream) __THROW; 30 ^~~~~~~~~~~ 31 32To avoid this build failure, check if flockfile is available before 33defining flockfile, funlockfile and getc_unlocked 34 35Fixes: 36 - http://autobuild.buildroot.org/results/d41638d1ad8e78dd6f654367c905996b838ee649 37 38Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com> 39--- 40 Makefile | 5 +++++ 41 configure.ac | 6 ++++++ 42 git-compat-util.h | 2 +- 43 3 files changed, 12 insertions(+), 1 deletion(-) 44 45diff --git a/Makefile b/Makefile 46index 6fb86c5862..58d0893a12 100644 47--- a/Makefile 48+++ b/Makefile 49@@ -232,6 +232,8 @@ all:: 50 # Define NO_STRUCT_ITIMERVAL if you don't have struct itimerval 51 # This also implies NO_SETITIMER 52 # 53+# Define NO_FLOCKFILE if you don't have flockfile() 54+# 55 # Define NO_FAST_WORKING_DIRECTORY if accessing objects in pack files is 56 # generally faster on your platform than accessing the working directory. 57 # 58@@ -1638,6 +1640,9 @@ endif 59 ifdef NO_SETITIMER 60 COMPAT_CFLAGS += -DNO_SETITIMER 61 endif 62+ifdef NO_FLOCKFILE 63+ COMPAT_CFLAGS += -DNO_FLOCKFILE 64+endif 65 ifdef NO_PREAD 66 COMPAT_CFLAGS += -DNO_PREAD 67 COMPAT_OBJS += compat/pread.o 68diff --git a/configure.ac b/configure.ac 69index 66aedb9288..d4295b5c69 100644 70--- a/configure.ac 71+++ b/configure.ac 72@@ -1132,6 +1132,12 @@ GIT_CHECK_FUNC(setitimer, 73 [NO_SETITIMER=YesPlease]) 74 GIT_CONF_SUBST([NO_SETITIMER]) 75 # 76+# Define NO_FLOCKFILE if you don't have flockfile. 77+GIT_CHECK_FUNC(flockfile, 78+[NO_FLOCKFILE=], 79+[NO_FLOCKFILE=YesPlease]) 80+GIT_CONF_SUBST([NO_FLOCKFILE]) 81+# 82 # Define NO_STRCASESTR if you don't have strcasestr. 83 GIT_CHECK_FUNC(strcasestr, 84 [NO_STRCASESTR=], 85diff --git a/git-compat-util.h b/git-compat-util.h 86index 7d509c5022..279cdd941e 100644 87--- a/git-compat-util.h 88+++ b/git-compat-util.h 89@@ -1236,7 +1236,7 @@ int warn_on_fopen_errors(const char *path); 90 # define SHELL_PATH "/bin/sh" 91 #endif 92 93-#ifndef _POSIX_THREAD_SAFE_FUNCTIONS 94+#if !defined(_POSIX_THREAD_SAFE_FUNCTIONS) && defined(NO_FLOCKFILE) 95 static inline void flockfile(FILE *fh) 96 { 97 ; /* nothing */ 98-- 992.29.2 100 101