[MDEV-27579] Errors while compiling mysql.cc on macOS with Xcode 9.4.1 (readline related it seems) Created: 2022-01-22  Updated: 2022-01-25

Status: Open
Project: MariaDB Server
Component/s: Compiling
Affects Version/s: 10.7.2, 10.6
Fix Version/s: 10.6

Type: Bug Priority: Major
Reporter: Valerii Kravchuk Assignee: Dmitry Shulga
Resolution: Unresolved Votes: 0
Labels: macos


 Description   

I've got the following errors (after patching current 10.6 from GitHub to fix MDEV-27402 as described there):

...
[ 99%] Building CXX object client/CMakeFiles/mariadb.dir/completion_hash.cc.o
[ 99%] Building CXX object client/CMakeFiles/mariadb.dir/mysql.cc.o
/Users/Valerii/git/server/client/mysql.cc:2747:59: error: expected expression
  rl_attempted_completion_function= (rl_completion_func_t*)&new_mysql_co...
                                                          ^
/Users/Valerii/git/server/client/mysql.cc:2747:38: error: use of undeclared
      identifier 'rl_completion_func_t'; did you mean 'rl_completion_matches'?
  rl_attempted_completion_function= (rl_completion_func_t*)&new_mysql_co...
                                     ^~~~~~~~~~~~~~~~~~~~
                                     rl_completion_matches
/usr/include/editline/readline.h:202:16: note: 'rl_completion_matches' declared
      here
char           **rl_completion_matches(const char *, rl_compentry_func_t *);
                 ^
/Users/Valerii/git/server/client/mysql.cc:2748:33: error: assigning to
      'Function *' (aka 'int (*)(const char *, int)') from incompatible type
      'rl_compentry_func_t *' (aka 'char *(*)(const char *, int)'): different
      return type ('int' vs 'char *')
  rl_completion_entry_function= (rl_compentry_func_t*)&no_completion;
                                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/Valerii/git/server/client/mysql.cc:2750:3: error: no matching function
      for call to 'rl_add_defun'
  rl_add_defun("magic-space", (rl_command_func_t *)&fake_magic_space, -1);
  ^~~~~~~~~~~~
/usr/include/editline/readline.h:195:7: note: candidate function not viable: no
      known conversion from 'rl_command_func_t *' (aka 'int (*)(int, int)') to
      'Function *' (aka 'int (*)(const char *, int)') for 2nd argument
int              rl_add_defun(const char *, Function *, int);
                 ^
4 errors generated.
make[2]: *** [client/CMakeFiles/mariadb.dir/mysql.cc.o] Error 1
make[1]: *** [client/CMakeFiles/mariadb.dir/all] Error 2
make: *** [all] Error 2
Yuliyas-Air:buildtmp Valerii$ cd ..
Yuliyas-Air:server Valerii$ git log -1
commit 21778b8aa88280458f2196aab93044149cf0a18c (HEAD -> 10.6, origin/10.6)
Merge: 764ca7e6e75 66465914c1a
Author: Marko M<C3><A4>kel<C3><A4> <marko.makela@mariadb.com>
Date:   Thu Jan 20 07:39:11 2022 +0200
 
    Merge 10.5 into 10.6
Yuliyas-Air:server Valerii$ git diff
diff --git a/storage/innobase/include/fil0fil.h b/storage/innobase/include/fil0fil.h
index 8ab28e4d84f..3af40d2b418 100644
--- a/storage/innobase/include/fil0fil.h
+++ b/storage/innobase/include/fil0fil.h
@@ -1545,7 +1545,7 @@ inline void fil_space_t::reacquire()
 inline bool fil_space_t::set_stopping_check()
 {
   mysql_mutex_assert_owner(&fil_system.mutex);
-#if defined __clang_major__ && __clang_major__ < 10
+#if (defined __clang_major__ && __clang_major__ < 10) || defined __APPLE_CC__
   /* Only clang-10 introduced support for asm goto */
   return n_pending.fetch_or(STOPPING, std::memory_order_relaxed) & STOPPING;
 #elif defined __GNUC__ && (defined __i386__ || defined __x86_64__)

The following cmake command line was used:

Yuliyas-Air:buildtmp Valerii$ cmake .. -DCMAKE_INSTALL_PREFIX=/Users/Valerii/dbs/maria10.6 -DCMAKE_BUILD_TYPE=RelWithDebInfo -DBUILD_CONFIG=mysql_release -DFEATURE_SET=community -DWITH_EMBEDDED_SERVER=OFF -DPLUGIN_TOKUDB=NO -DWITH_SSL=/opt/local/libexec/openssl11 -DENABLE_DTRACE=1



 Comments   
Comment by Valerii Kravchuk [ 2022-01-22 ]

The following lame patch:

Yuliyas-Air:server Valerii$ git diff
diff --git a/client/mysql.cc b/client/mysql.cc
index 37f506a99cd..d93c8ee8a3c 100644
--- a/client/mysql.cc
+++ b/client/mysql.cc
@@ -2743,12 +2743,12 @@ static void initialize_readline ()
   rl_terminal_name= getenv("TERM");
 
   /* Tell the completer that we want a crack first. */
-#if defined(USE_NEW_READLINE_INTERFACE)
+#if defined(USE_NEW_READLINE_INTERFACE) && !defined(__APPLE_CC__)
   rl_attempted_completion_function= (rl_completion_func_t*)&new_mysql_completion;
   rl_completion_entry_function= (rl_compentry_func_t*)&no_completion;
 
   rl_add_defun("magic-space", (rl_command_func_t *)&fake_magic_space, -1);
-#elif defined(USE_LIBEDIT_INTERFACE)
+#elif defined(USE_LIBEDIT_INTERFACE) && !defined(__APPLE_CC__)
 #ifdef HAVE_LOCALE_H
   setlocale(LC_ALL,""); /* so as libedit use isprint */
 #endif
@@ -2757,7 +2757,7 @@ static void initialize_readline ()
   rl_add_defun("magic-space", (Function*)&fake_magic_space, -1);
 #else
   rl_attempted_completion_function= (CPPFunction*)&new_mysql_completion;
-  rl_completion_entry_function= &no_completion;
+  /* rl_completion_entry_function= &no_completion; */
 #endif
 }
 
diff --git a/storage/innobase/include/fil0fil.h b/storage/innobase/include/fil0fil.h
index 8ab28e4d84f..3af40d2b418 100644
--- a/storage/innobase/include/fil0fil.h
+++ b/storage/innobase/include/fil0fil.h
@@ -1545,7 +1545,7 @@ inline void fil_space_t::reacquire()
 inline bool fil_space_t::set_stopping_check()
 {
   mysql_mutex_assert_owner(&fil_system.mutex);
-#if defined __clang_major__ && __clang_major__ < 10
+#if (defined __clang_major__ && __clang_major__ < 10) || defined __APPLE_CC__
   /* Only clang-10 introduced support for asm goto */
   return n_pending.fetch_or(STOPPING, std::memory_order_relaxed) & STOPPING;
 #elif defined __GNUC__ && (defined __i386__ || defined __x86_64__)

allows 10.6 build to complete successfully on macOS 10.6.13 High Sierra:

...
[100%] Linking CXX executable mariadb-tzinfo-to-sql
Creating mysql_tzinfo_to_sql link
[100%] Built target mariadb-tzinfo-to-sql
[100%] Building C object sql/CMakeFiles/udf_example.dir/udf_example.c.o
[100%] Linking CXX shared module udf_example.so
[100%] Built target udf_example
[100%] Building CXX object mysql-test/lib/My/SafeProcess/CMakeFiles/my_safe_process.dir/safe_process.cc.o
[100%] Linking CXX executable my_safe_process
[100%] Built target my_safe_process
[100%] Building C object mysql-test/lib/My/SafeProcess/CMakeFiles/wsrep_check_version.dir/wsrep_check_version.c.o
[100%] Linking C executable wsrep_check_version
[100%] Built target wsrep_check_version
Yuliyas-Air:buildtmp Valerii$ ./sql/mariadbd --version
./sql/mariadbd  Ver 10.6.6-MariaDB for osx10.13 on x86_64 (MariaDB Server)

Comment by Valerii Kravchuk [ 2022-01-25 ]

10.7.2 (current from GitHub) is also affected. The following lame patch handles readline-related part of the problem:

Yuliyas-Air:server Valerii$ git diff
diff --git a/client/mysql.cc b/client/mysql.cc
index 37f506a99cd..6bfbfd87b95 100644
--- a/client/mysql.cc
+++ b/client/mysql.cc
@@ -2743,7 +2743,7 @@ static void initialize_readline ()
   rl_terminal_name= getenv("TERM");
 
   /* Tell the completer that we want a crack first. */
-#if defined(USE_NEW_READLINE_INTERFACE)
+#if defined(USE_NEW_READLINE_INTERFACE) && !defined(__APPLE_CC__)
   rl_attempted_completion_function= (rl_completion_func_t*)&new_mysql_completion;
   rl_completion_entry_function= (rl_compentry_func_t*)&no_completion;
 
@@ -2753,7 +2753,7 @@ static void initialize_readline ()
   setlocale(LC_ALL,""); /* so as libedit use isprint */
 #endif
   rl_attempted_completion_function= (CPPFunction*)&new_mysql_completion;
-  rl_completion_entry_function= &no_completion;
+  /* rl_completion_entry_function= &no_completion; */
   rl_add_defun("magic-space", (Function*)&fake_magic_space, -1);
 #else
   rl_attempted_completion_function= (CPPFunction*)&new_mysql_completion;
...,

Generated at Thu Feb 08 09:53:59 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.