Bug #105464 | MySQL 8.0.27 don't build on macOS 12.0.1 due to fragile cmake code | ||
---|---|---|---|
Submitted: | 4 Nov 2021 23:08 | Modified: | 20 Jan 2022 21:00 |
Reporter: | Christopher Chavez (OCA) | Email Updates: | |
Status: | Can't repeat | Impact on me: | |
Category: | MySQL Server: Compiling | Severity: | S3 (Non-critical) |
Version: | 8.0.27 | OS: | MacOS (12.0.1) |
Assigned to: | CPU Architecture: | Any |
[4 Nov 2021 23:08]
Christopher Chavez
[5 Nov 2021 0:10]
Christopher Chavez
Here is the change I intend to attach to "Contributions" if my OCA is approved: diff --git a/cmake/package_name.cmake b/cmake/package_name.cmake index 058b0bcbd8cb..be1af896d515 100644 --- a/cmake/package_name.cmake +++ b/cmake/package_name.cmake @@ -88,7 +88,7 @@ MACRO(GET_PACKAGE_FILE_NAME Var) STRING(REGEX MATCH "ProductVersion:[\n\t ]*([0-9]+)\\.([0-9]+)" UNUSED ${SW_VERS_PRODUCTVERSION}) - IF(NOT CMAKE_MATCH_1 OR NOT CMAKE_MATCH_2) + IF(NOT CMAKE_MATCH_COUNT EQUAL 2) MESSAGE(FATAL_ERROR "Could not run sw_vers") ENDIF()
[5 Nov 2021 13:37]
MySQL Verification Team
Hi Mr. Chavez, Thank you for your bug report. However, we are not able to repeat the problem. We have built 8.0.27 several times on macOS Monterey, without any problems. The only thing that we had to do is to use latest stable CMake program , which is 3.21.3 and latest XCode. We also had to choose the options carefully, so that they use only the resources that are available on macOS and not those that are running only on Linux. Hence, we can't repeat the problem.
[5 Nov 2021 13:52]
MySQL Verification Team
One more info from us ..... We can run program `sw_vers` without problem on our Monterey. Make sure you have it available and in the PATH.
[5 Nov 2021 22:33]
Christopher Chavez
Thank you for verifying this report. The person I am reporting this issue on behalf of was using Xcode 13.1 and CMake 3.21.4. I provided them this debugging patch which prints relevant CMake variables and truth values: https://github.com/chrstphrchvz/mysql-server/commit/f9af863dabd5.patch This is the output they received (https://trac.macports.org/ticket/63726#comment:10): -- SW_VERS_OUTPUT_LIST: 'ProductName: macOS;ProductVersion: 12.0.1;BuildVersion: 21A559' -- SW_VERS_PRODUCTNAME: 'ProductName: macOS' -- SW_VERS_PRODUCTVERSION: 'ProductVersion: 12.0.1' -- CMAKE_MATCH_1: '12' -- CMAKE_MATCH_2: '0' -- CMAKE_MATCH_1: TRUE -- CMAKE_MATCH_2: FALSE CMake Error at cmake/package_name.cmake:107 (MESSAGE): Could not run sw_vers So the problem did not appear to be with running the sw_vers command itself, but rather how the parsed output from it is being handled. The code in cmake/package_name.cmake relevant to this issue is specific to macOS, so I did not have the impression the error could be due to MySQL being configured requiring resources (I’m not sure if this refers to system commands or MySQL features) not compatible with macOS. Someone also suggested it would be simpler for the code to run `sw_vers -productVersion` (an option supported even by older macOS versions) and rely less on regex parsing.
[6 Nov 2021 16:14]
Terje Røsten
Hi! Thanks for your report. This issue has been resolved upstream already. The patch used is: iff --git a/cmake/package_name.cmake b/cmake/package_name.cmake index 058b0bcbd8c..7983475221c 100644 --- a/cmake/package_name.cmake +++ b/cmake/package_name.cmake @@ -88,7 +88,7 @@ MACRO(GET_PACKAGE_FILE_NAME Var) STRING(REGEX MATCH "ProductVersion:[\n\t ]*([0-9]+)\\.([0-9]+)" UNUSED ${SW_VERS_PRODUCTVERSION}) - IF(NOT CMAKE_MATCH_1 OR NOT CMAKE_MATCH_2) + IF(NOT DEFINED CMAKE_MATCH_1 OR NOT DEFINED CMAKE_MATCH_2) MESSAGE(FATAL_ERROR "Could not run sw_vers") ENDIF() Can you please try this patch and verify this fix works for you?
[7 Nov 2021 11:34]
Christopher Chavez
Someone else opened a pull request on GitHub suggesting the exact same fix as in Terje Røsten’s comment: https://github.com/mysql/mysql-server/pull/379 The GitHub pull request author confirms that the upstream (MySQL internal development?) fix works. I’ve not heard from the person I reported this issue on behalf of regarding the results of trying the upstream fix, however I am confident it will work as I believe it is functionally equivalent to the CMAKE_MATCH_COUNT fix I proposed.
[8 Nov 2021 12:17]
MySQL Verification Team
Thank you, Terje ..... For the info, we use XCode 13.1 and CMake 3.21.3.
[10 Nov 2021 7:46]
Christopher Chavez
The person that reported the issue to me has verified that the upstream fix works.
[10 Nov 2021 12:28]
MySQL Verification Team
Thank you , Mr. Chavez.
[1 Dec 2021 7:20]
MySQL Verification Team
Bug #105760 marked as duplicate of this one
[14 Dec 2021 15:45]
MySQL Verification Team
Bug #105893 marked as duplicate of this one.
[20 Jan 2022 21:00]
Christopher Chavez
MySQL 8.0.28 includes the fix for this issue.
[21 Jan 2022 13:37]
MySQL Verification Team
Yes, that is true ....... It is a single line fix ......