Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-33091

pcre2 headers aren't found on Solaris

Details

    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`.

      Attachments

        Issue Links

          Activity

            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)

            serg Sergei Golubchik added a comment - 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)
            rorth Rainer Orth added a comment -

            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).

            rorth Rainer Orth added a comment - 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).

            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")

            serg Sergei Golubchik added a comment - 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")
            rorth Rainer Orth added a comment -

            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.

            rorth Rainer Orth added a comment - 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.

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

            serg Sergei Golubchik added a comment - rorth , please check commit 37beb8b8bc0 — does it work for you?
            rorth Rainer Orth added a comment -

            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.

            rorth Rainer Orth added a comment - 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.
            danblack Daniel Black added a comment -

            FYI back ported same fix to 10.5.27 as well - was affecting FreeBSD also

            danblack Daniel Black added a comment - FYI back ported same fix to 10.5.27 as well - was affecting FreeBSD also
            otto Otto Kekäläinen added a comment - Related fix pending review at https://github.com/MariaDB/server/pull/3225

            People

              serg Sergei Golubchik
              rorth Rainer Orth
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Git Integration

                  Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.