2
1

0001-Fix-build-without-threads.patch 3.4 KB

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