Trying to build a port for mariadb 10.11

I'm trying to get a port of MariaDB 10.11 working on FreeBSD 12.4. First, I'm a 25 year FreeBSD user, but not a C programmer. I work in the FreeBSD, Apache, MariaDB, PHP world. I want a feature that's in MariaDB 10.11 that's not in 10.6 (the latest in the ports, seems 10-7 thru 10.10 skipped, 10.11 is long term support released 2023/02).

I set up a test box and have copied what's in the 10.6 port to 10.11 and made adjustments to Makefile, patches, etc. I have made it as far as having make build and install mariadb1011-client, but it fails on linking of mysqltest 65% of the way building the server. The failure is on (complete c++ command at bottom):
Code:
ld: error: unable to find library -lpcre2-posix
ld: error: unable to find library -lpcre2-8
c++: error: linker command failed with exit code 1 (use -v to see invocation)

Yet at the beginning of the build they're found:
Code:
===>  Extracting for mariadb1011-server-10.11.2
=> SHA256 Checksum OK for mariadb-10.11.2.tar.gz.
===>  Patching for mariadb1011-server-10.11.2^M
===>  Applying FreeBSD patches for mariadb1011-server-10.11.2 from /usr/ports/databases/mariadb1011-server/files
===>  mariadb1011-server-10.11.2 depends on executable: bison - found
===>  mariadb1011-server-10.11.2 depends on file: /usr/local/bin/cmake - found
===>  mariadb1011-server-10.11.2 depends on executable: ninja - found
===>  mariadb1011-server-10.11.2 depends on file: /usr/local/bin/python3.9 - found
===>  mariadb1011-server-10.11.2 depends on shared library: libpcre2-8.so - found (/usr/local/lib/libpcre2-8.so)
===>  mariadb1011-server-10.11.2 depends on shared library: libpcre2-posix.so - found (/usr/local/lib/libpcre2-posix.so)

And the libraries are in /usr/local/lib:
Code:
rw-r--r--  1 root  wheel  1067360 Mar  7 17:16 /usr/local/lib/libpcre2-8.a
lrwxr-xr-x  1 root  wheel      20 Mar  7 17:16 /usr/local/lib/libpcre2-8.so@ -> libpcre2-8.so.0.11.2
lrwxr-xr-x  1 root  wheel      20 Mar  7 17:16 /usr/local/lib/libpcre2-8.so.0@ -> libpcre2-8.so.0.11.2
-rwxr-xr-x  1 root  wheel  759336 Mar  7 17:16 /usr/local/lib/libpcre2-8.so.0.11.2*
-rw-r--r--  1 root  wheel    8154 Mar  7 17:16 /usr/local/lib/libpcre2-posix.a
lrwxr-xr-x  1 root  wheel      23 Mar  7 17:16 /usr/local/lib/libpcre2-posix.so@ -> libpcre2-posix.so.3.0.4
lrwxr-xr-x  1 root  wheel      23 Mar  7 17:16 /usr/local/lib/libpcre2-posix.so.3@ -> libpcre2-posix.so.3.0.4


If someone could throw me a bone on where to look from here, it would be much appreciated!


Complete c++ command that fails:
Code:
[ 65% 1672/2534] /usr/bin/c++ -DHAVE_CONFIG_H -DHAVE_DLOPEN -DHAVE_OPENSSL -Dmariadb_test_EXPORTS -I/usr/ports/databases/mariadb1011-server/work/mariadb-10.11.2/
libmariadb/include -I/usr/ports/databases/mariadb1011-server/work/mariadb-10.11.2/wsrep-lib/include -I/usr/ports/databases/mariadb1011-server/work/mariadb-10.11.
2/wsrep-lib/wsrep-API/v26 -I/usr/ports/databases/mariadb1011-server/work/mariadb-10.11.2/include -I/usr/ports/databases/mariadb1011-server/work/mariadb-10.11.2/i
nclude/providers -I/usr/ports/databases/mariadb1011-server/work/mariadb-10.11.2/mysys_ssl -I/usr/ports/databases/mariadb1011-server/work/mariadb-10.11.2/sql -I/u
sr/ports/databases/mariadb1011-server/work/mariadb-10.11.2/strings -I/usr/ports/databases/mariadb1011-server/work/mariadb-10.11.2/client -I/usr/local/include/edi
tline -O2 -pipe -fstack-protector-strong -isystem /usr/local/include -fno-strict-aliasing  -isystem /usr/local/include -fstack-protector --param=ssp-buffer-size=
4 -O2 -pipe -fstack-protector-strong -isystem /usr/local/include -fno-strict-aliasing  -isystem /usr/local/include  -DNDEBUG -D_FORTIFY_SOURCE=2 -DDBUG_OFF  -is
ystem /usr/local/include -std=gnu++11 -DTHREADS -MD -MT client/CMakeFiles/mariadb-test.dir/mysqltest.cc.o -MF client/CMakeFiles/mariadb-test.dir/mysqltest.cc.o.d
-o client/CMakeFiles/mariadb-test.dir/mysqltest.cc.o -c /usr/ports/databases/mariadb1011-server/work/mariadb-10.11.2/client/mysqltest.cc
[ 65% 1673/2534] : && /usr/bin/c++ -O2 -pipe -fstack-protector-strong -isystem /usr/local/include -fno-strict-aliasing  -isystem /usr/local/include -fstack-prote
ctor --param=ssp-buffer-size=4 -O2 -pipe -fstack-protector-strong -isystem /usr/local/include -fno-strict-aliasing  -isystem /usr/local/include  -DNDEBUG -D_FORT
IFY_SOURCE=2 -DDBUG_OFF -L/usr/local/lib, -Wl,-z,notext  -fstack-protector-strong -Wl,-z,relro,-z,now  -Wl,--export-dynamic client/CMakeFiles/mariadb-test.dir/m
ysqltest.cc.o client/CMakeFiles/mariadb-test.dir/__/sql/sql_string.cc.o -o client/mariadb-test  -pthread  libmariadb/libmariadb/libmariadbclient.a  mysys/libmysy
s.a  -lpcre2-posix  -lpcre2-8  -lssl  -lcrypto  dbug/libdbug.a  strings/libstrings.a  mysys/libmysys.a  dbug/libdbug.a  strings/libstrings.a  -lm  -lz  -lexecinf
o  -pthread && cd /usr/ports/databases/mariadb1011-server/work/mariadb-10.11.2/client && /usr/local/bin/cmake -E create_symlink mariadb-test mysqltes
^[[31mFAILED: ^[[0mclient/mariadb-test 
: && /usr/bin/c++ -O2 -pipe -fstack-protector-strong -isystem /usr/local/include -fno-strict-aliasing  -isystem /usr/local/include -fstack-protector --param=ssp-
buffer-size=4 -O2 -pipe -fstack-protector-strong -isystem /usr/local/include -fno-strict-aliasing  -isystem /usr/local/include  -DNDEBUG -D_FORTIFY_SOURCE=2 -DDB
UG_OFF -L/usr/local/lib, -Wl,-z,notext  -fstack-protector-strong -Wl,-z,relro,-z,now  -Wl,--export-dynamic client/CMakeFiles/mariadb-test.dir/mysqltest.cc.o cli
ent/CMakeFiles/mariadb-test.dir/__/sql/sql_string.cc.o -o client/mariadb-test  -pthread  libmariadb/libmariadb/libmariadbclient.a  mysys/libmysys.a  -lpcre2-posi
x  -lpcre2-8  -lssl  -lcrypto  dbug/libdbug.a  strings/libstrings.a  mysys/libmysys.a  dbug/libdbug.a  strings/libstrings.a  -lm  -lz  -lexecinfo  -pthread && cd
/usr/ports/databases/mariadb1011-server/work/mariadb-10.11.2/client && /usr/local/bin/cmake -E create_symlink mariadb-test mysqltest
ld: error: unable to find library -lpcre2-posix
ld: error: unable to find library -lpcre2-8
c++: error: linker command failed with exit code 1 (use -v to see invocation)
 
You could try to get in touch with the maintainer of the current mariadb106-server. Or try the mailing-lists. As this is "specialised". On this forum we are a bit more "basic", i.e. simple mortal beings.
 
You could try to get in touch with the maintainer of the current mariadb106-server. Or try the mailing-lists. As this is "specialised". On this forum we are a bit more "basic", i.e. simple mortal beings.
Ok, I know mariadb and mysql are not the easiest things to build.
 
Here are my 'ports' if anyone wants to try building it.
to build you have to change at least one other fle:
edit /usr/ports/Mk/Uses/mysql.mk and add (near line 78), you'll see the list of other versions:
MYSQL1011m_LIBVER= 3

There is also a comment to add as well, but it's only a comment, not needed for this but to be correct it ought to be added. Add `10.11m` to this comment (about line 92) in /usr/ports/Mk/bsd.default-versions.mk
# Possible values: 5.6, 5.7, 8.0, 10.3m, 10.4m, 10.5m, 10.11m,5.7p, 5.7w
 

Attachments

  • mariadb-port.20230317.zip
    15.5 KB · Views: 111
in your Makefile (LDFLAGS+= -L${LOCALBASE}/lib,) / remove the comma
then will bomb because tpool/* is not build with -fPIC i just edited build.ninja and fixed that but it obviously needs a better fix
i see there is a patch to add -fPIC in tpool/CMakeLists.txt but is in the wrong place
 
in your Makefile (LDFLAGS+= -L${LOCALBASE}/lib,) / remove the comma
then will bomb because tpool/* is not build with -fPIC i just edited build.ninja and fixed that but it obviously needs a better fix
i see there is a patch to add -fPIC in tpool/CMakeLists.txt but is in the wrong place
Both of those are my mistakes. I had the `-Wl,-z,notext` on same line as the first LDFLAGS, then moved down leaving the shrapnel behind. Resolved and now builds. Won't install, I'll work on figuring that out before I ask. The latest version of the ports is attached
 

Attachments

  • mariadb-port.20230317.zip
    15.5 KB · Views: 92
Maintainer of MariaDB ports here... Porting MariaDB is a task that requires more time and effort than I currently have to spend on it.
  • The number of released versions is too large to manage.
  • Updating the ports requires a lot of time and effort (with ca. 15 min for a single -server build, for every version, for every supported FreeBSD version and arch I can build).
  • Let alone building all combinations of OPTIONS...
  • The number of fixes you'll need to apply to make it behave in FreeBSD terms (replace bundled libs with libs from base/ports) and build on all versions/arch is a chore.
  • Requires more Cmake skill and knowledge than I have.
  • MariaDB project doesn't care too much about FreeBSD.
  • It may work if you let it run its course without fiddling with the build and/or cmake files.
Originally I took over the MariaDB port from a Ukranian guy, around the time Russia invaded Ukraine and occupied Crimea. It's gotten way out of hand.

I'm willing to commit a new port if all QA work is done, but will not make myself the maintainer. That should then be a Bugzilla PR.
 
I'm stuck again, this time on this message (which has incorrect man page locations in stage):
pkg-static: Unable to access file /usr/ports/databases/mariadb1011-server/work/stage/usr/local/man/man1/innochecksum.1.gz:No such file or directory

The interesting thing is the man pages are in the place they ought to be:
/usr/ports/databases/mariadb1011-server/work/stage/usr/local/share/man/man1/innochecksum.1.gz

Code:
# ll /usr/ports/databases/mariadb1011-server/work/stage/usr/local/share/man/man1/innochecksum.1.gz
-rw-r--r--  1 root  wheel  1788 Feb  6 14:55 /usr/ports/databases/mariadb1011-server/work/stage/usr/local/share/man/man1/innochecksum.1.gz

If I build mariadb106-server, the files install from the staged share directory perfectly fine. I'm a old fart computer guy that's been coding since 1986 and I usually can figure anything out. Yet the ports are so full of macros and constants it's really difficult for a newbie to wade though them. I diffed the mariadb106 Makefile (what I started from) and the one I'm working on for mariadb1011 and don't see anything afoul.

Code:
# diff ../mariadb106-server/Makefile Makefile
2c2
< PORTVERSION=    10.6.12
---
> PORTVERSION=    10.11.2
5,17c5,30
< MASTER_SITES=    https://mirror.nodesdirect.com/${SITESDIR}/ \
<excluded additional mirrors from this post>
< PKGNAMESUFFIX?=    106-server
---
> MASTER_SITES=    https://mirror.rackspace.com/mariadb/${SITESDIR}/ \
<excluded additional mirrors from this post>
> PKGNAMESUFFIX?=    1011-server
26a40
>         libpcre2-posix.so:devel/pcre2 \
30a45
> LDFLAGS+=     -Wl,-z,notext
232,233c247
<         ${WRKSRC}/cmake/pcre.cmake \
<         ${WRKSRC}/storage/innobase/*.cmake
---
>         ${WRKSRC}/cmake/pcre.cmake

As for maintaining versions, I don't see why it wouldn't be fine to have a current long term support version, and the prior long term support version if it's still being supported. Anyone running a version 5 years out of date ought to be on their own. It's relatively painless to upgrade, although there is downtime because you have to deinstall the prior version.

BTW: The list of mirrors in the Makefile I worked on are all current and tested to work.
 
Tried dropping MariaDB 10.3, some people required features not available in later versions.
That's kind of when I gave up with MariaDB porting, reflected in EXPIRY set on the ports.
 
Code:
# mysql -u root -p
Enter password:
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 14
Server version: 10.11.2-MariaDB FreeBSD Ports

It was a struggle for me to do this as I was a total fish out of water. Yet, you can see with a little guidance you folks kindly provided I was able to figure this out. The docs aren't meant for fish though! A little struggling and figuring out why things are as they are.

So attached is my latest version of the mariadb-10.11.2 ports for both -client and -server. I have connected to it as you see, and run a couple queries against the mysql table. I'll try to figure out how to really test it this evening, or tomorrow.
If anyone wants to try it out on a test server they have, you'll have to edit /usr/ports/Mk/Uses/mysql.mk and add (near line 78), you'll see the list of other versions:
MYSQL1011m_LIBVER= 3
If you don't do the above you get error "unknown mariadb/mysql version" at beginning of make

There is also a comment to add to, but it's only a comment, not needed for this. add 10.11m to this comment (about line 92) in /usr/ports/Mk/bsd.default-versions.mk
# Possible values: 5.6, 5.7, 8.0, 10.3m, 10.4m, 10.5m, 10.6m, 10.11m, 5.7p, 5.7w
 

Attachments

  • mariadb1011-port.20230320.zip
    10.9 KB · Views: 97
Tried dropping MariaDB 10.3, some people required features not available in later versions.
That's kind of when I gave up with MariaDB porting, reflected in EXPIRY set on the ports.
mariadb is a beast, and multiple versions make it exponentially hard to keep up. I'm just a regular FreeBSD user but my opinion is that folks on a version that was released 5 years ago are simply delaying the inevitable while causing maintenance issues for others. I don't really see any killer issues listed here: https://mariadb.com/kb/en/upgrading-from-mariadb-103-to-mariadb-104/ maybe they didn't even look. There is even a direct path from 10.6 to 10.11 https://mariadb.com/kb/en/upgrading-from-mariadb-10-6-to-mariadb-10-11/
 
Gosh. I cleaned up my ports too much and delete the pkg-plist from the mariadb1011-server port files. Attached is a revised version
 

Attachments

  • mariadb1011-port.20230321.zip
    13.3 KB · Views: 107
Here is my latest packaging of the maria 10.11.2 client and server ports after I built packages tonight, and have a validated pkg-plist from make check-plist.
 

Attachments

  • mariadb1011-port.20230323-2107.zip
    13.4 KB · Views: 124
I have 10.11 running fine on a live server now using default config.

Note make the changes to the files noted above and then set the default mysql version on your server:
# cat /etc/make.conf
Code:
DEFAULT_VERSIONS+= mysql=10.11m

The m in 10.11m indicates to the port system it's MariaDB vs mySQL (would be without an m)

mariadb-10.11-config.png
 
That's really cool, RatFink ! I might try to build this myself, feeling inspired now!
The number of released versions is too large to manage.
Or one can leave older mariadb versions die in unmainted peace.
Or have a jump in version from X direct to X+2.
Or just stick to the LTS versions. I wouldn't bother with the others.

(MariaDB has only recently adopted the LTS concept, I think. So all versions 10.6 and earlier are all considered LTS, then it makes a jump to 10.11 for the next LTS.)
 
FYI: If you navigate to https://mariadb.org/download/ and select the version which currently says 'MariaDB Server 11.1.0 Alpha', then go to the Operating System drop-down and you will find that there is - for the first time ever (AFAIK) - a FreeBSD (13) binary distribution option!

Edit: Can confirm that at least basic features are working correctly.
SQL:
SELECT @@version, user();
+----------------+----------------+
| @@version      | user()         |
+----------------+----------------+
| 11.1.0-MariaDB | root@localhost |
+----------------+----------------+
1 row in set (0.000 sec)
 
FYI: If you navigate to https://mariadb.org/download/ and select the version which currently says 'MariaDB Server 11.1.0 Alpha', then go to the Operating System drop-down and you will find that there is - for the first time ever (AFAIK) - a FreeBSD (13) binary distribution option!
Oh, wow! Seems to have been immediately discontinued in "11.2.0 Alpha" already though, I hope they get back.
(having some proper upstream interest is always nice)
 
Back
Top