summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2022-04-22 07:42:14 +0200
committerStephan Bergmann <sbergman@redhat.com>2022-04-25 13:41:15 +0200
commit02311766135700f8dd8528cc7cacda636c8f304d (patch)
treefdacbd13968628244f0fe61369c56d1b5488c379
parentcd2272874d1b1911dec6c6e7bf3d67861be4a015 (diff)
external/openldap: Don't use pthread_get/setconcurrency without declarations
At least with glibc on Linux, those two functions are only declared in <pthread.h> when _XOPEN_SOURCE is defined. And with <https://github.com/llvm/llvm-project/commit/7d644e1215b376ec5e915df9ea2eeb56e2d94626> "[C11/C2x] Change the behavior of the implicit function declaration warning" in Clang 15 trunk that now causes hard errors > thr_posix.c:93:9: error: call to undeclared function 'pthread_setconcurrency'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration] > return pthread_setconcurrency( n ); > ^ > thr_posix.c:107:9: error: call to undeclared function 'pthread_getconcurrency'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration] > return pthread_getconcurrency(); > ^ (vs. just silently ignored warnings) when building ExternalProject_openldap. (And the way the corresponding AC_CHECK_FUNCS in workdir/UnpackedTarball/openldap/configure.in works, it always set HAVE_PTHREAD_GET/SETCONCURRENCY because it effectively checks for availability of the symbols in a library, not for declarations of the C functions in an include file.) But if we explicitly define _XOPEN_SOURCE, we now also need to explicitly define _DEFAULT_SOURCE or _BSD_SOURCE (which is otherwise implicitly defined by default in glibc's features.h if no other such macros are defined). Change-Id: I148d50c82ee2efc2a54f2cf4f84dead3941a3568 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133312 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
-rw-r--r--external/openldap/ExternalProject_openldap.mk13
1 files changed, 11 insertions, 2 deletions
diff --git a/external/openldap/ExternalProject_openldap.mk b/external/openldap/ExternalProject_openldap.mk
index 79519fcd4e8b..d5e1189cdef3 100644
--- a/external/openldap/ExternalProject_openldap.mk
+++ b/external/openldap/ExternalProject_openldap.mk
@@ -15,6 +15,15 @@ $(eval $(call gb_ExternalProject_register_targets,openldap,\
build \
))
+openldap_CFLAGS =
+ifeq ($(OS),LINUX) # i.e., assuming glibc
+# glibc needs at least _XOPEN_SOURCE=500 to declare pthread_getconcurrency and
+# pthread_setconcurrency in <pthread.h> (and once that is defined, it also needs either
+# _DEFUALT_SOURCE (glibc >= 2.19) or the deprecated _BSD_SOURCE (glibc <= 2.18) to be defined
+# explicitly, so that e.g. u_char is declared in <sys/types.h>):
+openldap_CFLAGS = -D_XOPEN_SOURCE=500 -D_DEFAULT_SOURCE -D_BSD_SOURCE
+endif
+
openldap_LDFLAGS =
ifeq ($(SYSTEM_NSS),)
openldap_LDFLAGS += -L$(call gb_UnpackedTarball_get_dir,nss)/dist/out/lib \
@@ -42,10 +51,10 @@ $(call gb_ExternalProject_get_state_target,openldap,build) :
ac_cv_func_memcmp_working=yes \
) \
$(if $(SYSTEM_NSS), \
- CPPFLAGS="$(CPPFLAGS) $(NSS_CFLAGS)" CFLAGS="$(CFLAGS) $(NSS_CFLAGS) $(call gb_ExternalProject_get_build_flags,openldap)" LDFLAGS="$(LDFLAGS) $(NSS_LIBS)" \
+ CPPFLAGS="$(CPPFLAGS) $(NSS_CFLAGS)" CFLAGS="$(CFLAGS) $(openldap_CFLAGS) $(NSS_CFLAGS) $(call gb_ExternalProject_get_build_flags,openldap)" LDFLAGS="$(LDFLAGS) $(NSS_LIBS)" \
, \
CPPFLAGS="$(CPPFLAGS) -I$(call gb_UnpackedTarball_get_dir,nss)/dist/public/nss -I$(call gb_UnpackedTarball_get_dir,nss)/dist/out/include" \
- CFLAGS="$(CFLAGS) $(call gb_ExternalProject_get_build_flags,openldap) -I$(call gb_UnpackedTarball_get_dir,nss)/dist/public/nss -I$(call gb_UnpackedTarball_get_dir,nss)/dist/out/include" \
+ CFLAGS="$(CFLAGS) $(openldap_CFLAGS) $(call gb_ExternalProject_get_build_flags,openldap) -I$(call gb_UnpackedTarball_get_dir,nss)/dist/public/nss -I$(call gb_UnpackedTarball_get_dir,nss)/dist/out/include" \
) \
$(if $(openldap_LDFLAGS),LDFLAGS="$(LDFLAGS) $(openldap_LDFLAGS)") \
&& MAKEFLAGS= && $(MAKE) \