Bug #106212 Potentially incompatible system Boost gets picked even with -DWITH_BOOST=/path
Submitted: 19 Jan 11:40 Modified: 23 May 20:19
Reporter: Laurynas Biveinis (OCA) Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Compiling Severity:S3 (Non-critical)
Version:8.0 OS:MacOS (12.1)
Assigned to: CPU Architecture:x86
Tags: boost, cmake

[19 Jan 11:40] Laurynas Biveinis
Description:
If Boost on macOS is installed through Homebrew, then its headers take precedence over MySQL Boost headers specified by -DWITH_BOOST= option.

Current, the Homebrew Boost (1.76) is incompatible with MySQL Boost (1.73), resulting in compilation errors:

/Users/laurynas/vilniusdb/mysql-8.0.28/sql/gis/buffer.cc:70:7: error: no matching constructor for initialization of 'bg::strategy::buffer::geographic_point_circle<>'
      geo_point_circle(32, bg::srs::spheroid<double>(srs->semi_major_axis(),
      ^                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/local/include/boost/geometry/strategies/geographic/buffer_point_circle.hpp:61:14: note: candidate constructor not viable: allows at most single argument 'count', but 2 arguments were provided
    explicit geographic_point_circle(std::size_t count = 90)
             ^
/usr/local/include/boost/geometry/strategies/geographic/buffer_point_circle.hpp:55:7: note: candidate constructor (the implicit copy constructor) not viable: requires 1 argument, but 2 were provided
class geographic_point_circle
      ^
/usr/local/include/boost/geometry/strategies/geographic/buffer_point_circle.hpp:55:7: note: candidate constructor (the implicit move constructor) not viable: requires 1 argument, but 2 were provided

make VERBOSE=1 shows /usr/local/include preceding the Boost include path.

How to repeat:
On Mac:
brew install boost
cmake options -DWITH_BOOST=... -DWITH_SYSTEM_LIBS=ON -DWITH_ICU=bundled -DWITH_RAPIDJSON=bundled  -DWITH_LZ4=bundled -DWITH_FIDO=bundled
make

Suggested fix:
Probably caused by -DWITH_SYSTEM_LIBS=ON finding something in /usr/local/include, and putting this in the front of include search directories?

CMakeCache.txt has
555  LIBEVENT_INCLUDE_DIRECTORY:PATH=/usr/local/include
670  Protobuf_INCLUDE_DIR:PATH=/usr/local/include
958  ZSTD_INCLUDE_DIR:PATH=/usr/local/include

A workaround is brew unlink boost before compilation
[19 Jan 11:52] Laurynas Biveinis
Title typo
[19 Jan 12:21] Tor Didriksen
MySQL 8.0.28 must have *exactly* boost 1.73.0
anything else, and you may get build errors, and/or wrong results for GIS queries.
[19 Jan 12:23] Tor Didriksen
You must download boos yourself, or use the DOWNLOAD_BOOST cmake option.
[19 Jan 12:30] Laurynas Biveinis
I have used -DDOWNLOAD_BOOST=ON, and pointed with -DWITH_BOOST there. But the system Boost takes precedence over the downloaded one
[19 Jan 13:28] Tor Didriksen
I just got myself a mac, so good timing :)
However, it's an M1 so HOMEBREW is in /opt/homebrew
rather than /usr/local and I cannot reproduce.

Maybe do

INCLUDE_DIRECTORIES(BEFORE SYSTEM ${BOOST_PATCHES_DIR} ${BOOST_INCLUDE_DIR})
wherever we include boost stuff.

or 'brew install boost@1.73 ??
[19 Jan 14:01] Laurynas Biveinis
$ brew install boost@1.73
...
Warning: No available formula with the name "boost@1.73". Did you mean boost?
...

I think I found the bug - one of cmakecache.txt entries pointing to /usr/local/include was zstd, and in zstd.cmake there is
    IF(NOT ZSTD_INCLUDE_DIR STREQUAL "/usr/include")
      # In case of -DCMAKE_PREFIX_PATH=</path/to/custom/zstd>
      INCLUDE_DIRECTORIES(BEFORE SYSTEM ${ZSTD_INCLUDE_DIR})
    ENDIF()

- so ZSTD_INCLUDE is "/usr/local/include", != "/usr/include", and also gets prepended not appended to the include search list.
[19 Jan 14:17] Tor Didriksen
nice find.
I will have an extra look in current development branches then.
I have been working with using system libs (from homebrew) also on mac.
[19 Jan 14:17] MySQL Verification Team
Hi Mr. Biveinis,

We have tried to repeat the behaviour on Intel Mac, with Monterey OS and we were unable to repeat the behaviour.
[19 Jan 14:18] MySQL Verification Team
Sorry Mr. Biveinis,

We managed to reproduce the behaviour.

This bug is now verified ........
[28 Apr 15:21] Laurynas Biveinis
See bug 107151
[29 Apr 13:17] MySQL Verification Team
This bug report is, indeed, the original bug of the bug #107151.
[29 Apr 13:17] MySQL Verification Team
This bug report is, indeed, the original bug of the bug #107151.
[23 May 20:19] Philip Olson
It appears a patch for this was committed in 8.0.29 here:

https://github.com/mysql/mysql-server/commit/1de89d75257d19c8d5951b24805b79a16f4e8839

But the fix was incomplete, and the final fix for this issue was committed for Bug #107151

The 8.0.30 release note:

On MacOS, improved Boost library detection logic for Homebrew as a
potentially incompatible system's Boost version could get used even with
-DWITH_BOOST set.

Thanks Laurynas for both bug reports and sorry for the delayed response to this one.
[24 May 12:52] MySQL Verification Team
Thank you, Philip !!!