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