Bug 272163 - net/openldap26-server: Compiler error: incompatible function pointer types assigning
Summary: net/openldap26-server: Compiler error: incompatible function pointer types as...
Status: Open
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Many People
Assignee: Xin LI
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-06-23 12:43 UTC by O. Hartmann
Modified: 2023-06-27 04:16 UTC (History)
1 user (show)

See Also:
bugzilla: maintainer-feedback? (delphij)


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description O. Hartmann 2023-06-23 12:43:09 UTC
Ports tree up to date, host is a most recen CURRENT with just slipped in LLVM 16: FreeBSD 14.0-CURRENT #0 main-n263767-764464af4968: Fri Jun 23 10:30:09 CEST 2023 amd64

openldap26-server fails to compile with standard config.


[...]
libevent_support.c:155:31: error: incompatible function pointer types passing 'ldap_pvt_thread_t (void)' (aka 'struct pthread *(void)') to parameter of type 'unsigned long (*)(void)' [-Wincompatible-function-pointer-types]
    evthread_set_id_callback( ldap_pvt_thread_self );
                              ^~~~~~~~~~~~~~~~~~~~
/usr/local/include/event2/thread.h:193:21: note: passing argument to parameter 'id_fn' here
    unsigned long (*id_fn)(void));
                    ^
1 error generated.
/bin/sh ../../libtool --tag=disable-static --mode=compile cc -O2 -pipe  -fstack-protector-strong -isystem /usr/local/include -fno-strict-aliasing  -I../../include -I. -I./../slapd -I../../include   -I/usr/local/include -isystem /usr/local/include   -DSLAPD_IMPORT -DBALANCER_MODULE -c monitor.c
gmake[4]: *** [Makefile:363: libevent_support.lo] Error 1
gmake[4]: *** Waiting for unfinished jobs....
libtool: compile:  cc -O2 -pipe -fstack-protector-strong -isystem /usr/local/include -fno-strict-aliasing -I../../include -I. -I./../slapd -I../../include -I/usr/local/include -isystem /usr/local/include -DSLAPD_IMPORT -DBALANCER_MODULE -c monitor.c  -fPIC -DPIC -o .libs/monitor.o
module_init.c:154:19: error: incompatible function pointer types assigning to 'BI_config *' (aka 'int (*)(struct BackendInfo *, const char *, int, int, char **)') from 'int (Backend *, const char *, int, int, char **)' (aka 'int (struct BackendDB *, const char *, int, int, char **)') [-Wincompatible-function-pointer-types]
    bi->bi_config = config_generic_wrapper;
                  ^ ~~~~~~~~~~~~~~~~~~~~~~
3 warnings and 1 error generated.
gmake[4]: *** [Makefile:363: module_init.lo] Error 1
Comment 1 O. Hartmann 2023-06-23 12:55:33 UTC
Workaround: Disabling option load balancer seems to make the problem disappear:

LLOADD=off: Enable load balancer
Comment 2 Xin LI freebsd_committer freebsd_triage 2023-06-27 04:16:16 UTC
Filed upstream bug https://bugs.openldap.org/show_bug.cgi?id=10074 .

Preliminary fix would be:

From 1ea3c90988bfab8cb08475ad35f7891854bdeeb1 Mon Sep 17 00:00:00 2001
From: Xin LI <delphij@FreeBSD.org>
Date: Mon, 26 Jun 2023 19:51:58 -0700
Subject: [PATCH 1/2] net/openldap26-server: Fix build on CURRENT.

---
 net/openldap26-server/Makefile                |  2 +-
 .../patch-servers_lloadd_libevent__support.c  | 32 +++++++++++++++++++
 .../files/patch-servers_lloadd_module__init.c | 18 +++++++++++
 3 files changed, 51 insertions(+), 1 deletion(-)
 create mode 100644 net/openldap26-server/files/patch-servers_lloadd_libevent__support.c
 create mode 100644 net/openldap26-server/files/patch-servers_lloadd_module__init.c

diff --git a/net/openldap26-server/Makefile b/net/openldap26-server/Makefile
index 35b4f603ec2c..1158d3442b53 100644
--- a/net/openldap26-server/Makefile
+++ b/net/openldap26-server/Makefile
@@ -46,7 +46,7 @@ CONFLICTS_INSTALL=    ${PORTNAME}2[0-57-9]-server ${PORTNAME}-server
 GNU_CONFIGURE=         yes
 
 PORTREVISION_CLIENT=   0
-PORTREVISION_SERVER=   0
+PORTREVISION_SERVER=   1
 OPENLDAP_SHLIB_MAJOR=  2
 OPENLDAP_SHLIB_MINOR=  0.200
 
diff --git a/net/openldap26-server/files/patch-servers_lloadd_libevent__support.c b/net/openldap26-server/files/patch-servers_lloadd_libevent__support.c
new file mode 100644
index 000000000000..bfa2da3912e8
--- /dev/null
+++ b/net/openldap26-server/files/patch-servers_lloadd_libevent__support.c
@@ -0,0 +1,32 @@
+--- servers/lloadd/libevent_support.c.orig     2023-02-08 18:53:35 UTC
++++ servers/lloadd/libevent_support.c
+@@ -131,6 +131,20 @@ lload_libevent_cond_timedwait(
+     return ldap_pvt_thread_cond_wait( cond, mutex );
+ }
+ 
++/*
++ * libevent2 expects the thread id has a type of unsigned long.
++ */
++static unsigned long
++lload_libevent_thread_self(void)
++{
++      unsigned long retval;
++      static_assert(sizeof(ldap_pvt_thread_t) <= sizeof(unsigned long),
++              "ldap_pvt_thread_t has to be smaller or equal to unsigned long");
++
++      retval = (unsigned long)ldap_pvt_thread_self();
++      return (retval);
++}
++
+ int
+ lload_libevent_init( void )
+ {
+@@ -152,7 +166,7 @@ lload_libevent_init( void )
+ 
+     evthread_set_lock_callbacks( &cbs );
+     evthread_set_condition_callbacks( &cond_cbs );
+-    evthread_set_id_callback( ldap_pvt_thread_self );
++    evthread_set_id_callback( lload_libevent_thread_self );
+     return 0;
+ }
+ 
diff --git a/net/openldap26-server/files/patch-servers_lloadd_module__init.c b/net/openldap26-server/files/patch-servers_lloadd_module__init.c
new file mode 100644
index 000000000000..1a1256f9610a
--- /dev/null
+++ b/net/openldap26-server/files/patch-servers_lloadd_module__init.c
@@ -0,0 +1,18 @@
+--- servers/lloadd/module_init.c.orig  2023-02-08 18:53:35 UTC
++++ servers/lloadd/module_init.c
+@@ -151,14 +151,13 @@ lload_back_initialize( BackendInfo *bi )
+ {
+     bi->bi_flags = SLAP_BFLAG_STANDALONE;
+     bi->bi_open = lload_back_open;
+-    bi->bi_config = config_generic_wrapper;
+     bi->bi_pause = lload_pause_cb;
+     bi->bi_unpause = lload_unpause_cb;
+     bi->bi_close = lload_back_close;
+     bi->bi_destroy = lload_back_destroy;
+ 
+     bi->bi_db_init = 0;
+-    bi->bi_db_config = 0;
++    bi->bi_db_config = config_generic_wrapper;
+     bi->bi_db_open = 0;
+     bi->bi_db_close = 0;
+     bi->bi_db_destroy = 0;
-- 
2.41.0


(note the bi_config should be assigned as NULL or 0, it's likely that we would have some better fixes so I'll not commit it for now.)