package/postgresql: fix build without BR2_TOOLCHAIN_HAS_THREADS_NPTL
PATCH 1/1 package/postgresql: fix build without BR2_TOOLCHAIN_HAS_THREADS_NPTL
Since commit: https://git.postgresql.org/gitweb/?p=postgresql.git;a=commit;h=52afe563206e753f4c45c014fee2459ad0855826
postgrsql fails to build with toolchains without threads support:
misc.c: In function 'ecpg_gettext':
misc.c:541:51: error: 'PTHREAD_MUTEX_INITIALIZER' undeclared (first use in this function)
541 | static pthread_mutex_t binddomain_mutex = PTHREAD_MUTEX_INITIALIZER;
| ^~~~~~~~~~~~~~~~~~~~~~~~~
misc.c:541:51: note: each undeclared identifier is reported only once for each function it appears in
misc.c:552:24: warning: implicit declaration of function 'pthread_mutex_lock' [-Wimplicit-function-declaration]
552 | (void) pthread_mutex_lock(&binddomain_mutex);
| ^~~~~~~~~~~~~~~~~~
misc.c:569:24: warning: implicit declaration of function 'pthread_mutex_unlock' [-Wimplicit-function-declaration]
569 | (void) pthread_mutex_unlock(&binddomain_mutex);
| ^~~~~~~~~~~~~~~~~~~~Option "--disable-thread-safety" will be dropped in PG 17, so this patch is needed only for 16.x branch.
--- .../0001-Fix-compile-without-threads.patch | 86 +++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 package/postgresql/0001-Fix-compile-without-threads.patch
package/postgresql/0001-Fix-compile-without-threads.patch new file +86 -0
@@ -0,0 +1,86 @@ +From 6c71182dde4d37fd70ee8015f61935254ae6f9a6 Mon Sep 17 00:00:00 2001 +From: Maxim Kochetkov <[email protected]> +Date: Thu, 19 Sep 2024 10:04:05 +0300 +Subject: [PATCH 1/1] Fix compile without threads + +All mutexes should be wrapped by #ifdef ENABLE_THREAD_SAFETY. + +Fixes: https://git.postgresql.org/gitweb/?p=postgresql.git;a=commit;h=52afe563206e753f4c45c014fee2459ad0855826 +Signed-off-by: Maxim Kochetkov <[email protected]> +Signed-off-by: Maxim Kochetkov <[email protected]> +--- + src/interfaces/ecpg/ecpglib/misc.c | 6 ++++++ + src/interfaces/libpq/fe-misc.c | 6 ++++++ + 2 files changed, 12 insertions(+) + +diff --git a/src/interfaces/ecpg/ecpglib/misc.c b/src/interfaces/ecpg/ecpglib/misc.c +index 4b54322926..5a4d2e847e 100644 +--- a/src/interfaces/ecpg/ecpglib/misc.c ++++ b/src/interfaces/ecpg/ecpglib/misc.c +@@ -538,7 +538,9 @@ ecpg_gettext(const char *msgid) + * might as well do it the same way everywhere. + */ + static volatile bool already_bound = false; ++#ifdef ENABLE_THREAD_SAFETY + static pthread_mutex_t binddomain_mutex = PTHREAD_MUTEX_INITIALIZER; ++#endif + + if (!already_bound) + { +@@ -549,7 +551,9 @@ ecpg_gettext(const char *msgid) + int save_errno = errno; + #endif + ++#ifdef ENABLE_THREAD_SAFETY + (void) pthread_mutex_lock(&binddomain_mutex); ++#endif + + if (!already_bound) + { +@@ -566,7 +570,9 @@ ecpg_gettext(const char *msgid) + already_bound = true; + } + ++#ifdef ENABLE_THREAD_SAFETY + (void) pthread_mutex_unlock(&binddomain_mutex); ++#endif + + #ifdef WIN32 + SetLastError(save_errno); +diff --git a/src/interfaces/libpq/fe-misc.c b/src/interfaces/libpq/fe-misc.c +index 488f7d6e55..2185e0ba7a 100644 +--- a/src/interfaces/libpq/fe-misc.c ++++ b/src/interfaces/libpq/fe-misc.c +@@ -1232,7 +1232,9 @@ libpq_binddomain(void) + * might as well do it the same way everywhere. + */ + static volatile bool already_bound = false; ++#ifdef ENABLE_THREAD_SAFETY + static pthread_mutex_t binddomain_mutex = PTHREAD_MUTEX_INITIALIZER; ++#endif + + if (!already_bound) + { +@@ -1243,7 +1245,9 @@ libpq_binddomain(void) + int save_errno = errno; + #endif + ++#ifdef ENABLE_THREAD_SAFETY + (void) pthread_mutex_lock(&binddomain_mutex); ++#endif + + if (!already_bound) + { +@@ -1260,7 +1264,9 @@ libpq_binddomain(void) + already_bound = true; + } + ++#ifdef ENABLE_THREAD_SAFETY + (void) pthread_mutex_unlock(&binddomain_mutex); ++#endif + + #ifdef WIN32 + SetLastError(save_errno); +-- +2.45.2 +
Signature · 6 lines
2.45.2 _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
Quoted 17 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Maxim" == Maxim Kochetkov via buildroot <[email protected]> writes:
Since commit: https://git.postgresql.org/gitweb/?p=postgresql.git;a=commit;h=52afe563206e753f4c45c014fee2459ad0855826
postgrsql fails to build with toolchains without threads support:
misc.c: In function 'ecpg_gettext':
misc.c:541:51: error: 'PTHREAD_MUTEX_INITIALIZER' undeclared (first use in this function)541 | static pthread_mutex_t binddomain_mutex = PTHREAD_MUTEX_INITIALIZER; | ^~~~~~~~~~~~~~~~~~~~~~~~~ misc.c:541:51: note: each undeclared identifier is reported only once for each function it appears in misc.c:552:24: warning: implicit declaration of function 'pthread_mutex_lock' [-Wimplicit-function-declaration] 552 | (void) pthread_mutex_lock(&binddomain_mutex); | ^~~~~~~~~~~~~~~~~~ misc.c:569:24: warning: implicit declaration of function 'pthread_mutex_unlock' [-Wimplicit-function-declaration] 569 | (void) pthread_mutex_unlock(&binddomain_mutex); | ^~~~~~~~~~~~~~~~~~~~
Quoted 5 lines
Option "--disable-thread-safety" will be dropped in PG 17, so this patch is needed only for 16.x branch.
Fixes 73dd1d6b9666 ("package/postgresql: security bump version to 16.3")Signed-off-by Maxim Kochetkov <[email protected]>
Committed to 2024.02.x and 2024.08.x, thanks.
Signature · 5 lines
Bye, Peter Korsgaard _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot