Bug #95740 mysql-client broken on Mac OS
Submitted: 11 Jun 2019 16:51 Modified: 15 Jul 2019 14:40
Reporter: Daniel Sieradski Email Updates:
Status: Closed Impact on me:
None 
Category:Shell General / Core Client Severity:S3 (Non-critical)
Version:5.7.26 OS:Any
Assigned to: CPU Architecture:x86
Tags: homebrew, macos, mysql-client

[11 Jun 2019 16:51] Daniel Sieradski
Description:
Installing mysql-client via Homebrew is no longer working because the current Homebrew version is 5.7.23 and it has been removed from the MySQL downloads CDN in favor of 5.7.24.

I tried patching the formula to update to 5.7.24, but now it fails to build in the last three Mac OSes, throwing the following error at build-time:

```
03:58:15 /usr/local/Homebrew/Library/Homebrew/shims/mac/super/clang++   -Wall -Wextra -Wformat-security -Wvla -Woverloaded-virtual -Wno-unused-parameter -Wno-null-conversion -Wno-unused-private-field -DNDEBUG -DDBUG_OFF -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk -Wl,-search_paths_first -Wl,-headerpad_max_install_names  CMakeFiles/mysqlbinlog.dir/mysqlbinlog.cc.o  -o mysqlbinlog ../archive_output_directory/libmysqlclient.a ../libbinlogevents/lib/libbinlogevents.a /usr/local/opt/openssl/lib/libssl.dylib /usr/local/opt/openssl/lib/libcrypto.dylib ../archive_output_directory/libmysys.a ../archive_output_directory/libdbug.a ../archive_output_directory/libmysys.a ../archive_output_directory/libdbug.a ../archive_output_directory/libstrings.a ../archive_output_directory/libz.a 
03:58:15 Undefined symbols for architecture x86_64:
03:58:15   "_mysql_file_read", referenced from:
03:58:15       _my_b_fill in libmysqlclient.a(mf_iocache2.c.o)
03:58:15   "_mysql_file_seek", referenced from:
03:58:15       _my_b_fill in libmysqlclient.a(mf_iocache2.c.o)
03:58:15       _my_b_filelength in libmysqlclient.a(mf_iocache2.c.o)
03:58:15 ld: symbol(s) not found for architecture x86_64
03:58:15 clang: error: linker command failed with exit code 1 (use -v to see invocation)
03:58:15 make[2]: *** [client/mysqlbinlog] Error 1
03:58:15 make[1]: *** [client/CMakeFiles/mysqlbinlog.dir/all] Error 2
03:58:15 make[1]: *** Waiting for unfinished jobs....
```

How to repeat:
brew bump-formula-pr --tag=5.7.24 mysql-client
[12 Jun 2019 17:30] Daniel Sieradski
Tried 5.7.26 with the same result. 

```
[ 77%] Linking CXX executable mysqlbinlog
cd /tmp/mysql-client-20190612-63317-1knl6m8/mysql-5.7.26/client && /usr/local/Cellar/cmake/3.14.5/bin/cmake -E cmake_link_script CMakeFiles/mysqlbinlog.dir/link.txt --verbose=1
/usr/local/Homebrew/Library/Homebrew/shims/mac/super/clang++   -Wall -Wextra -Wformat-security -Wvla -Woverloaded-virtual -Wno-unused-parameter -Wno-null-conversion -Wno-unused-private-field -DNDEBUG -DDBUG_OFF -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk -Wl,-search_paths_first -Wl,-headerpad_max_install_names  CMakeFiles/mysqlbinlog.dir/mysqlbinlog.cc.o  -o mysqlbinlog ../archive_output_directory/libmysqlclient.a ../libbinlogevents/lib/libbinlogevents.a /usr/local/opt/openssl/lib/libssl.dylib /usr/local/opt/openssl/lib/libcrypto.dylib ../archive_output_directory/libmysys.a ../archive_output_directory/libdbug.a ../archive_output_directory/libmysys.a ../archive_output_directory/libdbug.a ../archive_output_directory/libstrings.a ../archive_output_directory/libz.a 
Undefined symbols for architecture x86_64:
  "_mysql_file_read", referenced from:
      _my_b_fill in libmysqlclient.a(mf_iocache2.c.o)
  "_mysql_file_seek", referenced from:
      _my_b_fill in libmysqlclient.a(mf_iocache2.c.o)
      _my_b_filelength in libmysqlclient.a(mf_iocache2.c.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [client/mysqlbinlog] Error 1
make[1]: *** [client/CMakeFiles/mysqlbinlog.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
```

Full build output here: https://jenkins.brew.sh/job/Homebrew%20Core%20Pull%20Requests/43571/version=mojave/testRep...
[13 Jun 2019 13:09] MySQL Verification Team
Hi Mr. Sieradski,

I am building all latest MySQL versions on macOS, with latest CMake and XCode and do not have, nor did I ever had, any problems.

So, please, use your source tarball, downloaded from our WWW site, then use CMake and XCode and you will not have any problems.

Simply, CMake was not run correctly. The symbols that are raised by errors are inline functions, so they should not be any problem.
[13 Jun 2019 14:44] Daniel Sieradski
Sinisa Milivojevic,

Didn't anyone ever tell you "works for me" isn't a sufficient answer to a bug report?

This package failed to build on FOUR different systems running FOUR different MacOS versions and FOUR different Xcode versions.
[13 Jun 2019 19:19] MySQL Verification Team
Server and Client running om MAC OSX Compiled version 5.7.26

Attachment: 95740.png (image/png, text), 888.39 KiB.

[13 Jun 2019 19:21] MySQL Verification Team
cmake log

Attachment: 5.7-cmake.log (application/octet-stream, text), 28.79 KiB.

[13 Jun 2019 19:21] MySQL Verification Team
make log

Attachment: 5.7-make.log (application/octet-stream, text), 1.49 MiB.

[13 Jun 2019 19:22] MySQL Verification Team
I compiled 5.7.26 on MAC OS X, please see screenshot and camke and make logs. Thanks.
[13 Jun 2019 19:24] Daniel Sieradski
🤷‍♂️

Here are three builds failing on Homebrew's Jenkins test runner:
https://jenkins.brew.sh/job/Homebrew%20Core%20Pull%20Requests/43571/

Is there something specific to Homebrew that's causing it to fail? I assume you're building from source and not using Homebrew.
[13 Jun 2019 19:37] MySQL Verification Team
Forgot to paste the cmake command line:
miguel:mysql-5.7.26 miguel$ cmake . -DCMAKE_INSTALL_PREFIX=/Users/miguel/tmp/5.7 -DMYSQL_DATADIR=/Users/miguel/tmp/5.7/data -DWITH_DEBUG=OFF -DINSTALL_MYSQLKEYRINGDIR=/Users/miguel/tmp/5.7/keyring -DWITH_BOOST=/Users/miguel/tmp/ -DCMAKE_C_FLAGS=-w -DCMAKE_CXX_FLAGS=-w > 5.7-cmake.log
[13 Jun 2019 19:50] MySQL Verification Team
Yes I built from source like Sinisa told you before, I don't know what could be the issue with Homebrew.
[14 Jun 2019 12:25] MySQL Verification Team
HI Mr. Sieradski,

What my colleague Godofredo Solorzano has demonstrated to you is the manner of building MySQL on macOS. 

We do not support Homebrew builds, because we do not use it. We do not know whether it is possible to build with Homebrew, because this is not our official manner of building MySQL on macOS.

Not a bug.
[14 Jun 2019 16:31] Daniel Sieradski
I hear what you're saying and I appreciate where you're coming from, but hear me out for a minute:

Homebrew is the most popular and commonly used package manager for MacOS. It has tens of thousands of users and is considered the de facto standard. You have official package support for Yum, APT, and SUSE. While I appreciate that most MySQL installs are made to Linux servers and not to developers' desktops/laptops, a major portion of the web developer community that works with MySQL is on Mac and using Homebrew to manage their MySQL installation.

Maintaining a Homebrew tap (repo) is such a low-effort task—why not officially support it?
[19 Jun 2019 12:23] MySQL Verification Team
Hello Mr. Sieradski,

Our build team will not consider Homebrew building for the foreseeable future.

Hence, this manner of building is not supported by MySQL.
[24 Jun 2019 11:31] Tor Didriksen
The build is broken, also on Linux, run cmake with -DWITHOUT_SERVER=1

mysys/mf_iocache2.c:106:5: error: implicit declaration of function mysql_file_tell [-Werror=implicit-function-declaration]

Broken by this patch:
f65b4435376c0f1f1f11481aefe05dbc4218d02d
Author: Marc Alff <marc.alff@oracle.com>
Date:   Fri Aug 17 14:20:25 2018 +0200

    Bug#27788907 SOME FILE OPERATIONS IN MF_IOCACHE2.C ARE NOT INSTRUMENTED
    
    MySQL bug number 90264
    
    Contribution by Yura Sorokin.
    
    Problem:
    
    File mysys/mf_iocache2.c contains non instrumented file io operations.
    This causes inaccurate statistics in PERFORMANCE_SCHEMA.
    
    Solution:
    
    Use the instrumentation apis (mysql_file_tell instead of my_tell, etc).

The fix is simple:
diff --git a/mysys/mf_iocache2.c b/mysys/mf_iocache2.c
index 5ed4ef6e588..ba6ea20bdb5 100644
--- a/mysys/mf_iocache2.c
+++ b/mysys/mf_iocache2.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
+/* Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -23,6 +23,8 @@
 #include <stdarg.h>
 #include <m_ctype.h>
 
+#include "mysql/psi/mysql_file.h"
+
 /*
   Copy contents of an IO_CACHE to a file.
[12 Jul 2019 16:27] Paul DuBois
Posted by developer:
 
Fixed in 5.7.28, 8.0.18.

MySQL builds configured with -DWITHOUT_SERVER=1 failed.
[15 Jul 2019 12:19] MySQL Verification Team
Thank you, Paul ......
[15 Jul 2019 14:40] Daniel Sieradski
Hey Paul,

Any idea when 5.7.28 will be pushed out?

Thanks
[15 Jul 2019 15:14] MySQL Verification Team
Hi,

No, we do not know anything about when it will be available ...

Scheduling of the patch-fix releases is a very complex process, 100 % internal to Development. It is so complex, that the release is known, at best, within a couple of days prior to release.