From b8a6649797a73f75586c589a1b4c8197d9920c43 Mon Sep 17 00:00:00 2001 From: Andrew Childs Date: Thu, 6 Jun 2019 22:51:28 +0900 Subject: [PATCH] mariadb: fix clang and darwin build The contents of `clang-isfinite.patch` are no longer necessary after upstream revision 031fa6d4258574379ca3c1cbe912d235e9581982, which includes a similar change. Building in c++11 mode removes support for the GCC `typeof` extension in favor of the standardized `__typeof__`. This causes errors when using the `strmake_buf` macro, which relies on `typeof`. --- pkgs/servers/sql/mariadb/clang-isfinite.patch | 17 ------------ pkgs/servers/sql/mariadb/default.nix | 27 +++++++++++++------ .../mariadb/fix-c++11-narrowing-error.patch | 13 +++++++++ 3 files changed, 32 insertions(+), 25 deletions(-) delete mode 100644 pkgs/servers/sql/mariadb/clang-isfinite.patch create mode 100644 pkgs/servers/sql/mariadb/fix-c++11-narrowing-error.patch diff --git a/pkgs/servers/sql/mariadb/clang-isfinite.patch b/pkgs/servers/sql/mariadb/clang-isfinite.patch deleted file mode 100644 index 8da527d57847..000000000000 --- a/pkgs/servers/sql/mariadb/clang-isfinite.patch +++ /dev/null @@ -1,17 +0,0 @@ -diff --git a/include/my_global.h b/include/my_global.h -index cb31ae2..2866f87 100644 ---- a/include/my_global.h -+++ b/include/my_global.h -@@ -803,12 +803,6 @@ inline unsigned long long my_double2ulonglong(double d) - #endif - - #ifndef isfinite --#ifdef HAVE_FINITE --#define isfinite(x) finite(x) --#else --#define finite(x) (1.0 / fabs(x) > 0.0) --#endif /* HAVE_FINITE */ --#elif (__cplusplus >= 201103L) - #include - static inline bool isfinite(double x) { return std::isfinite(x); } - #endif /* isfinite */ diff --git a/pkgs/servers/sql/mariadb/default.nix b/pkgs/servers/sql/mariadb/default.nix index 988a90e27065..94cdf801ff29 100644 --- a/pkgs/servers/sql/mariadb/default.nix +++ b/pkgs/servers/sql/mariadb/default.nix @@ -9,6 +9,8 @@ with stdenv.lib; let # in mariadb # spans the whole file +libExt = stdenv.hostPlatform.extensions.sharedLibrary; + mariadb = everything // { inherit client; # libmysqlclient.so in .out, necessary headers in .dev and utils in .bin server = everything; # a full single-output build, including everything in `client` again @@ -45,7 +47,11 @@ common = rec { # attributes common to both builds ''; patches = [ ./cmake-includedir.patch ] - ++ stdenv.lib.optional stdenv.cc.isClang ./clang-isfinite.patch; + ++ optionals stdenv.isDarwin [ + # Derived from "Fixed c++11 narrowing error" + # https://github.com/MariaDB/server/commit/a0dfefb0f8a47145e599a5f1b0dc576fa7634b92 + ./fix-c++11-narrowing-error.patch + ]; cmakeFlags = [ "-DBUILD_CONFIG=mysql_release" @@ -112,9 +118,10 @@ client = stdenv.mkDerivation (common // { rm -r "$out"/share/doc rm "$out"/bin/{msql2mysql,mysql_plugin,mytop,wsrep_sst_rsync_wan,mysql_config,mariadb_config} rm "$out"/lib/plugin/{daemon_example.ini,dialog.so,mysql_clear_password.so,sha256_password.so} - rm "$out"/lib/{libmariadb.so,libmysqlclient.so,libmysqlclient_r.so} - mv "$out"/lib/libmariadb.so.3 "$out"/lib/libmysqlclient.so - ln -sv libmysqlclient.so "$out"/lib/libmysqlclient_r.so + libmysqlclient_path=$(readlink -f $out/lib/libmysqlclient${libExt}) + rm "$out"/lib/{libmariadb${libExt},libmysqlclient${libExt},libmysqlclient_r${libExt}} + mv "$libmysqlclient_path" "$out"/lib/libmysqlclient${libExt} + ln -sv libmysqlclient${libExt} "$out"/lib/libmysqlclient_r${libExt} mkdir -p "$dev"/lib && mv "$out"/lib/{libmariadbclient.a,libmysqlclient.a,libmysqlclient_r.a,libmysqlservices.a} "$dev"/lib ''; @@ -161,16 +168,20 @@ everything = stdenv.mkDerivation (common // { rm -r "$out"/data # Don't need testing data rm "$out"/bin/{mysql_find_rows,mysql_waitpid,mysqlaccess,mysqladmin,mysqlbinlog,mysqlcheck} rm "$out"/bin/{mysqldump,mysqlhotcopy,mysqlimport,mysqlshow,mysqlslap,mysqltest} - rm "$out"/lib/mysql/plugin/{auth_gssapi_client.so,client_ed25519.so,daemon_example.ini} - rm "$out"/lib/{libmysqlclient.so,libmysqlclient_r.so} + ${ # We don't build with GSSAPI on Darwin + optionalString (! stdenv.isDarwin) '' + rm "$out"/lib/mysql/plugin/auth_gssapi_client.so + '' + } + rm "$out"/lib/mysql/plugin/{client_ed25519.so,daemon_example.ini} + rm "$out"/lib/{libmysqlclient${libExt},libmysqlclient_r${libExt}} mv "$out"/share/{groonga,groonga-normalizer-mysql} "$out"/share/doc/mysql mkdir -p "$dev"/lib && mv "$out"/lib/{libmariadbclient.a,libmysqlclient.a,libmysqlclient_r.a,libmysqlservices.a} "$dev"/lib '' + optionalString (! stdenv.isDarwin) '' sed -i 's/-mariadb/-mysql/' "$out"/bin/galera_new_cluster ''; - CXXFLAGS = optionalString stdenv.isi686 "-fpermissive" - + optionalString stdenv.isDarwin " -std=c++11"; + CXXFLAGS = optionalString stdenv.isi686 "-fpermissive"; }); connector-c = stdenv.mkDerivation rec { diff --git a/pkgs/servers/sql/mariadb/fix-c++11-narrowing-error.patch b/pkgs/servers/sql/mariadb/fix-c++11-narrowing-error.patch new file mode 100644 index 000000000000..7399d8e39275 --- /dev/null +++ b/pkgs/servers/sql/mariadb/fix-c++11-narrowing-error.patch @@ -0,0 +1,13 @@ +diff --git a/sql/table.cc b/sql/table.cc +index e46af771507..9bef21a1da2 100644 +--- a/sql/table.cc ++++ b/sql/table.cc +@@ -8814,7 +8814,7 @@ bool TR_table::update(ulonglong start_id, ulonglong end_id) + + store(FLD_BEGIN_TS, thd->transaction_time()); + thd->set_time(); +- timeval end_time= {thd->query_start(), long(thd->query_start_sec_part())}; ++ timeval end_time= {thd->query_start(), int(thd->query_start_sec_part())}; + store(FLD_TRX_ID, start_id); + store(FLD_COMMIT_ID, end_id); + store(FLD_COMMIT_TS, end_time);