Bug 230538

Summary: devel/apr1 fails with mysql80-client
Product: Ports & Packages Reporter: Please <please>
Component: Individual Port(s)Assignee: Jochen Neumeister <joneum>
Status: Open ---    
Severity: Affects Some People CC: arnaud, avkarenow, brnrd, busheval, eugen, i.dani, joneum, mmokhi, please
Priority: --- Keywords: needs-patch
Version: LatestFlags: bugzilla: maintainer-feedback? (apache)
Hardware: amd64   
OS: Any   
URL: https://bz.apache.org/bugzilla/show_bug.cgi?id=62631
See Also: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=220699
Description Flags
poudniere log
proposed patch for mysql80
working patch not coflicing with other patches
Build stopped with this messages none

Description Please 2018-08-11 16:05:09 UTC
Created attachment 196091 [details]
poudniere log

---Begin OPTIONS List---
===> The following configuration options are available for apr-
     IPV6=on: IPv6 protocol support
====> Database support
     BDB=on: Berkeley DB support
     GDBM=on: GNU dbm library support
     LDAP=on: LDAP protocol support
     MYSQL=on: MySQL database support
     NDBM=off: NDBM support
     ODBC=off: ODBC database backend
     PGSQL=off: PostgreSQL database support
     SQLITE=off: SQLite database support
====> Cryptography provider: you can only select none or one of them
     SSL=on: OpenSSL crypto driver
     NSS=off: NSS crypto driver
===> Use 'make config' to modify these settings
---End OPTIONS List---


=======================<phase: package        >============================
===>  Building package for apr-
pkg-static: Unable to access file /wrkdirs/usr/ports/devel/apr1/work/stage/usr/local/lib/apr-util-1/apr_dbd_mysql-1.so:No such file or directory
pkg-static: Unable to access file /wrkdirs/usr/ports/devel/apr1/work/stage/usr/local/lib/apr-util-1/apr_dbd_mysql.a:No such file or directory
pkg-static: Unable to access file /wrkdirs/usr/ports/devel/apr1/work/stage/usr/local/lib/apr-util-1/apr_dbd_mysql.so:No such file or directory
*** Error code 1

Problem might be mentioned in : bug #220699
Comment 1 Please 2018-08-11 17:02:15 UTC
It looks like it is a APR1 conflict with Mysql80-client 

(build and install apr manually)
./configure --with-apr=../apr-1.6.3/ --with-mysql 

apr-util configure gives this with mysql80-client 

checking for mysql_config... /usr/local/bin/mysql_config
  adding "-I/usr/local/include/mysql" to CPPFLAGS
  setting LIBS to "-L/usr/local/lib/mysql -lmysqlclient -pthread -lz -lm -lrt -lexecinfo -lssl -lcrypto"
checking for mysql.h... no
checking for mysql/mysql.h... no

when mysql57-client gives:
checking for mysql_config... /usr/local/bin/mysql_config
  adding "-I/usr/local/include/mysql" to CPPFLAGS
  setting LIBS to "-L/usr/local/lib/mysql -lmysqlclient -pthread -lz -lm -lrt -lexecinfo -lssl -lcrypto"
checking for mysql.h... yes
checking for mysql_init in -lmysqlclient... yes
checking for my_global.h... yes
Comment 2 Please 2018-08-11 19:43:30 UTC
After a while, it looks like my_global.h is generating a problem 

it is mentioned:

my_global.h should not have #defines that modify behavior of system
headers; this is brittle, and better suited to CMake options,
so move it there.

It should also not try to #undef symbols from other files, which is
again brittle (especially as these symbols tend to change without
people remembering to update my_global.h -- it seems to already have
happened during the introduction of yaSSL). Instead, make sure these
symbols are simply not added during compilation in the first place.
Every plugin now gets compiled with ${SSL_DEFINES} added automatically,
so they don't have to add that manually -- except if they are recompiled
for embedded, in which case ${SSL_DEFINES} is never added in the first
place (instead of having to #undef them).
Comment 3 Please 2018-08-11 20:36:50 UTC
To make apr1 compile with mysql80-client I found that 2 files need to updated from apr-util:


add to after line 50:
/* MySQL 8.0 replaces my_bool with C99 bool. Earlier versions of MySQL had
* a typedef to char. Gem users reported failures on big endian systems when
* using C99 bool types with older MySQLs due to mismatched behavior. */
#include <stdbool.h>
typedef bool my_bool;

second file : apr-util-1.6.1/build/dbd.m4
replace line 178:
AC_CHECK_HEADERS([mysql.h my_global.h my_sys.h],

replace line 183:
AC_CHECK_HEADERS([mysql/mysql.h mysql/my_global.h mysql/my_sys.h],

the same on lines 209 and 215

then replace all occurrence of 
[#include <mysql/my_global.h>]) 
[#include <mysql/mysql.h>])


[#include <my_global.h>]) 
[#include <mysql.h>])

then commands to test it : 

see if dbd/apr_dbd_mysql.o file was generated.

I am no expert at doing patches, hope someone will pick it app and apply this with some testing, ah this is only when mysql80-client is installed.
Comment 4 Jochen Neumeister freebsd_committer 2018-08-12 07:02:28 UTC
(In reply to Please from comment #3)

Is there a link to this 2 files? :)
Then i will have a look
Comment 6 Please 2018-08-12 12:55:47 UTC
Created attachment 196124 [details]
proposed patch for mysql80

also makefile require USES=autoreconf for rebuilding configure
Comment 7 Please 2018-08-12 14:37:24 UTC
Created attachment 196126 [details]
working patch not coflicing with other patches

Patch works, produces apr_dbd_mysql.so, other packages build fine. if library works and it is stable, cannot say.

To make it fully work, did modification to Makefile too :
--- Makefile.orig       2018-03-21 22:24:43.000000000 +0100
+++ Makefile    2018-08-12 16:25:15.442304000 +0200
@@ -16,7 +16,7 @@

 LIB_DEPENDS=   libexpat.so:textproc/expat2

-USES=          iconv pathfix libtool cpe
+USES=          autoreconf iconv pathfix libtool cpe

@@ -136,6 +136,8 @@
                ${SETENV} ${APR_CONF_ENV} ./configure ${APR_CONF_ARGS} ${CONFIGURE_ARGS})
        @${ECHO_MSG} "# ===> ${.TARGET} apr-util-${APU_VERSION}"
        (cd ${APU_WRKDIR} && \
+               ${SETENV} ${APU_CONF_ENV} autoconf)
+       (cd ${APU_WRKDIR} && \
                ${SETENV} ${APU_CONF_ENV} ./configure ${APU_CONF_ARGS} ${CONFIGURE_ARGS})

Comment 8 Jochen Neumeister freebsd_committer 2018-08-12 15:15:23 UTC
(In reply to Please from comment #6)

The Patch 196124 is obsolete?
Comment 9 Please 2018-08-12 18:06:06 UTC
Yeap. The only one that works for me is 196126, keep in mind that I have no idea what will happen to people with mysql5x. So I assume Makefile would need to have condition patch. This way package will keep compatibility with m57 and will work with m80. I do not know how to do it.
Comment 10 Jochen Neumeister freebsd_committer 2018-08-13 20:06:20 UTC
There was an update for mysql80 today.
It will take a few days until all tests are done.
I'll take care of it :-)
Comment 12 Please 2018-08-14 17:09:53 UTC
you are using mysql56-client-5.6.41, update make.conf to have: 
Comment 14 Please 2018-08-18 11:08:47 UTC
Library compile with patch and produce valid .so that does not help to the build process of other packages. 

However, apr1-util for apache24 with mod_dbd do not like it, and gives error: 
  Can't load driver file apr_dbd_mysql-1.so

Did some code tracing and this is kind of general error without specific information. The same error is when driver name is changed in configuration file for non-existing dso. So apr gives always the same error. Is apr faulty?
Reference to 'apr_dbd_get_driver' with error 'APR_STATUS_IS_EDSOOPEN' and then to 'apr_dso_load' to dso.c

I would mark port as conflict with mysql80 if mysql option is selected unless someone have idea how to fix it.
Comment 15 Bernard Spil freebsd_committer 2018-10-01 09:16:40 UTC
Adding Mahdi to the cc list.

Mahdi: Any changes in MySQL 8 that may cause this problem? For MariaDB I've been having issues with the changed libmariadb and mysql_config...
Comment 16 Mahdi Mokhtari freebsd_committer freebsd_triage 2018-10-06 17:26:10 UTC
First sorry for my a bit delayed answer on this.
today I looked into it a bit:
it seems the apr1's configure script is unable to find the mysql.h as you already pointed, it's right there in /usr/local/include/mysql/mysql.h as it is in all mysqls.
I wonder about the line `--with-mysql=${LOCALBASE}` in apr's Makefile I'm gonna play with it a bit more... (not sure if it's right thing to do ``:D but seems like a path ;D)

@brnrd, what kind of change do you mean for mysql_config? paths? output-formats?
Comment 17 Bernard Spil freebsd_committer 2018-10-24 16:47:40 UTC
Added in the upstream bugzilla:

I'm trying to fix this as team-member of the apache@ team in FreeBSD which is also the maintainer of the APR packages.

Looks like this issue is NOT FreeBSD specific, MySQL 8 ships different headers than 5.x. The autoconf needs some 

Looking at the config.log I see
> configure:20376: checking for mysql.h
> configure:20376: cc -c -O2 -fno-strict-aliasing -pipe -march=native  -DLIBICONV_PLUG -fstack-protector  -I/usr/ports/devel/apr1/work/apr-1.6.5/include -I/usr/local/include -I/usr/local/include/mysql -DHAVE_MYSQL_H -I/usr/local/include -DLIBICONV_PLUG conftest.c >&5
> conftest.c:21:10: fatal error: 'my_global.h' file not found
> #include <my_global.h>
>          ^~~~~~~~~~~~~
> 1 error generated.
> configure:20376: $? = 1
> configure: failed program was:

MySQL 8.0 does not ship a my_global.h, and APR decides that there's no usable MySQL.
There's a my_global.h in 
but not in 

The requirement for my_global.h was introduced in 2008
Comment 18 commit-hook freebsd_committer 2018-10-27 21:47:50 UTC
A commit references this bug:

Author: brnrd
Date: Sat Oct 27 21:46:52 UTC 2018
New revision: 483173
URL: https://svnweb.freebsd.org/changeset/ports/483173

  devel/apr1: Update APR to 1.6.5

   - MySQL 8.0 (port marked "devel") not compatible [1]

  PR:		230538 [1]
  Reported by:	<please forget me.uk>
  Differential Revision:	https://reviews.freebsd.org/D17688

Comment 19 Bernard Spil freebsd_committer 2018-10-27 22:08:22 UTC
Please follow up upstream.
I did my part, please assist.
Comment 20 Arnaud de Prelle 2018-10-30 22:02:21 UTC
I just upgraded from MariaDB 10.1 to MariaDB 10.3 (mariadb103-server-10.3.10_1) and I'm encountering the same issue.

===>  Installing for apr-
===>  Checking if apr already installed
===>   Registering installation for apr-
pkg-static: Unable to access file /usr/ports/devel/apr1/work/stage/usr/local/lib/apr-util-1/apr_dbd_mysql-1.so:No such file or directory
pkg-static: Unable to access file /usr/ports/devel/apr1/work/stage/usr/local/lib/apr-util-1/apr_dbd_mysql.a:No such file or directory
pkg-static: Unable to access file /usr/ports/devel/apr1/work/stage/usr/local/lib/apr-util-1/apr_dbd_mysql.so:No such file or directory
*** Error code 74

make[1]: stopped in /usr/ports/devel/apr1
*** Error code 1

make: stopped in /usr/ports/devel/apr1
Comment 21 Jochen Neumeister freebsd_committer 2018-10-31 17:11:53 UTC
(In reply to apn from comment #20)

Ports-Tree up-to-date?
You test it with delete this port and then a new install?
Comment 22 commit-hook freebsd_committer 2018-10-31 17:35:35 UTC
A commit references this bug:

Author: brnrd
Date: Wed Oct 31 17:35:28 UTC 2018
New revision: 483598
URL: https://svnweb.freebsd.org/changeset/ports/483598

  databases/mariadb103-client: Fix mariadb_config output

   - port fix from mariadb102-client port

  PR:		226049, 230538
  Reported by:	flo

Comment 23 Bernard Spil freebsd_committer 2018-10-31 17:43:15 UTC
(In reply to apn from comment #20)
Please check if this is fixed with mariadb103-client-10.3.10_2
Comment 24 Arnaud de Prelle 2018-10-31 18:49:26 UTC
(In reply to Bernard Spil from comment #23)

Hi Bernard, yes it's fixed ! Thanks
Comment 25 Dani I. 2020-01-02 16:19:44 UTC
(In reply to Bernard Spil from comment #23)

Bernard: Could you please take a look at bug #242156 ?
Comment 26 Eugene Grosbein freebsd_committer 2020-12-26 08:39:42 UTC
The PR was closed by mistake, the problem is still here. Re-open it.
Comment 27 Jochen Neumeister freebsd_committer 2021-08-26 21:25:19 UTC
does the problem still exist?
Comment 28 avkarenow 2021-09-07 20:58:40 UTC
Unfortunately yes, but the solution mentioned in comments #3 (replace my_bool, remove my_global.h and my_sys.h) and #6 (USES=autoreconf) still works.
I compiled arp1 with MySQL 8.0.26 on FreeBSD 13.0 after that modifications.
Comment 29 And 2022-04-08 09:12:11 UTC
Created attachment 233047 [details]
Build stopped with this messages
Comment 30 And 2022-04-08 09:14:19 UTC
Comment on attachment 233047 [details]
Build stopped with this messages

Have same problem on FreeBSD 12.3-RELEASE-p5 GENERIC  amd64 with mysql80-client-8.0.28_2.
After replace "my_bool" in file apr_dbd_mysql.c (from solution in Comment #3) apr is build and updated from apr- to apr-
File dbd.m4 do not changed.