Skip to content

Commit

Permalink
Fix builds on glibc >= 2.38
Browse files Browse the repository at this point in the history
`glibc` now defines `strchrnul`, so we add a check to see if `glibc` is
being used, and instead import the symbol if so.
  • Loading branch information
msepga committed Aug 4, 2023
1 parent cb3aa9e commit 543cbc9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,8 @@ $(PGDIR):
echo "#undef USE_ARMV8_CRC32C" >> $(PGDIR)/src/include/pg_config.h
echo "#undef USE_SSE42_CRC32C_WITH_RUNTIME_CHECK" >> $(PGDIR)/src/include/pg_config.h
# Ensure we don't fail on systems that have strchrnul support (FreeBSD and NetBSD)
echo "#if defined(__FreeBSD__) || defined(__NetBSD__)" >> $(PGDIR)/src/include/pg_config.h
echo "#include <features.h>" >> $(PGDIR)/src/include/pg_config.h
echo "#if defined(__FreeBSD__) || defined(__NetBSD__) || (defined(__GLIBC__) && ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 38) || __GLIBC__ > 2))" >> $(PGDIR)/src/include/pg_config.h
echo "#define HAVE_STRCHRNUL" >> $(PGDIR)/src/include/pg_config.h
echo "#endif" >> $(PGDIR)/src/include/pg_config.h

Expand Down
3 changes: 2 additions & 1 deletion src/postgres/include/pg_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -1032,6 +1032,7 @@
#undef HAVE__GET_CPUID
#undef USE_ARMV8_CRC32C
#undef USE_SSE42_CRC32C_WITH_RUNTIME_CHECK
#if defined(__FreeBSD__) || defined(__NetBSD__)
#include <features.h>
#if defined(__FreeBSD__) || defined(__NetBSD__) || (defined(__GLIBC__) && ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 38) || __GLIBC__ > 2))
#define HAVE_STRCHRNUL
#endif

0 comments on commit 543cbc9

Please sign in to comment.