[MDEV-33091] pcre2 headers aren't found on Solaris Created: 2023-12-20  Updated: 2024-01-19  Resolved: 2024-01-19

Status: Closed
Project: MariaDB Server
Component/s: Compiling
Affects Version/s: 10.11.6
Fix Version/s: 10.6.17, 10.11.7, 11.0.5, 11.1.4, 11.2.3, 11.3.2

Type: Bug Priority: Critical
Reporter: Rainer Orth Assignee: Sergei Golubchik
Resolution: Fixed Votes: 0
Labels: None
Environment:

Solaris 11.4/x86 with GCC 13.2.0


Attachments: File MDEV-33091-pcre2.patch    

 Description   

`client/mysqltest.cc` and a few others fail to compile on Solaris:
```
/vol/src/mariadb/mariadb-10.11.6/client/mysqltest.cc:49:10: fatal error: pcre2posix.h: No such file or directory
49 | #include "pcre2posix.h" /* pcreposix regex library */

^~~~~~~~~~~~~~
```
While `pcre2` *is* bundled with Solaris, the headers live in `/usr/include/pcre` instead of cluttering `/usr/include` as happens on (some?) other targets.

Short of some cmake surgery in `cmake/pcre.cmake`, the easiest way to work around this was to add `-I/usr/include/pcre` to `CFLAGS` and `CXXFLAGS` before invoking `cmake`.



 Comments   
Comment by Sergei Golubchik [ 2024-01-03 ]

same as with other issues. We don't have Solaris in CI, but if you'll provide a patch, we'll apply it (providing it won't break anything else)

Comment by Rainer Orth [ 2024-01-09 ]

MDEV-33091-pcre2.patch

Since the pcre2 headers live in `/usr/include/pcre` on Solaris and so far `pcre.cmake` only checks for the existance of the libraries, not for the headers, that `cmake` check needs to be revamped:

  • Like e.g. `libxml2`(`FindLibXml2.cmake` bundled with `cmake`), the test now uses `PKG_CHECK_MODULES` (i.e. `pkg-config`) to check for `pcre2` headers and libraries.
  • In addition, it uses separate calls to `find_path` (which supports `PATH_SUFFIXES` to handle headers in subdirs of `/usr/include`) and `find_library`)
  • If the `pkg-config` check found a separate include directory for the `pcre2` headers, that one is assigned to `PCRE_INCLUDES` which is already used so those headers are found when a bundled version of `pcre2` is used.

Again, tested on Solaris 11.4/amd64 (which needs that separate `pcre` subdir) and Linux/x86_64 (which doesn't).

Comment by Sergei Golubchik [ 2024-01-10 ]

why do you need find_path and find_library in your patch? pkg-config is supposed to provide all paths, you shouldn't need to search manually after it.

I'd expect it to be just pkg_check_modules(PCRE ${required} libpcre2-8) and then use PCRE_LIBRARIES, PCRE_INCLUDE_DIRS, etc (here ${required} is REQUIRED if WITH_PCRE is "system")

Comment by Rainer Orth [ 2024-01-10 ]

I've followed `cmake's `FindLibXml2.cmake here. I suppose they use both `pkg_check_modules and `find_path/`find_library to allow for configurations with and without `pkg-config files.

Comment by Sergei Golubchik [ 2024-01-12 ]

rorth, please check commit 37beb8b8bc0 — does it work for you?

Comment by Rainer Orth [ 2024-01-15 ]

I just gave the bb-10.6-serg branch a try on Solaris 11.4: the errors not finding the pcre errors are gone. Thanks.

Generated at Thu Feb 08 10:36:19 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.