mariadb-connector-c: fix build against gcc15 (#442634)

This commit is contained in:
Emily
2025-09-13 20:46:20 +01:00
committed by GitHub
@@ -2,6 +2,7 @@
lib,
stdenv,
fetchFromGitHub,
fetchpatch,
cmake,
curl,
openssl,
@@ -28,6 +29,14 @@ stdenv.mkDerivation {
inherit hash;
};
patches = [
# fix compilation against gcc15
(fetchpatch {
url = "https://github.com/mariadb-corporation/mariadb-connector-c/commit/e8448137f3365568090d5c0d4051039ddc1cdb6f.patch";
hash = "sha256-aDbaaJA8DxGG5RrOa+CHhk4wuzlBy5tWyS+f/zVYU0c=";
})
];
outputs = [
"out"
"dev"
@@ -42,19 +51,19 @@ stdenv.mkDerivation {
postPatch = ''
substituteInPlace mariadb_config/mariadb_config.c.in \
--replace '#define INCLUDE "-I%s/@INSTALL_INCLUDEDIR@ -I%s/@INSTALL_INCLUDEDIR@/mysql"' "#define INCLUDE \"-I$dev/include -I$dev/include/mysql\"" \
--replace '#define LIBS "-L%s/@INSTALL_LIBDIR@/ -lmariadb"' "#define LIBS \"-L$out/lib/mariadb -lmariadb\"" \
--replace '#define PKG_LIBDIR "%s/@INSTALL_LIBDIR@"' "#define PKG_LIBDIR \"$out/lib/mariadb\"" \
--replace '#define PLUGIN_DIR "%s/@INSTALL_PLUGINDIR@"' "#define PLUGIN_DIR \"$out/lib/mariadb/plugin\"" \
--replace '#define PKG_PLUGINDIR "%s/@INSTALL_PLUGINDIR@"' "#define PKG_PLUGINDIR \"$out/lib/mariadb/plugin\""
--replace-fail '#define INCLUDE "-I%s/@INSTALL_INCLUDEDIR@ -I%s/@INSTALL_INCLUDEDIR@/mysql"' "#define INCLUDE \"-I$dev/include -I$dev/include/mysql\"" \
--replace-fail '#define LIBS "-L%s/@INSTALL_LIBDIR@/ -lmariadb"' "#define LIBS \"-L$out/lib/mariadb -lmariadb\"" \
--replace-fail '#define PKG_LIBDIR "%s/@INSTALL_LIBDIR@"' "#define PKG_LIBDIR \"$out/lib/mariadb\"" \
--replace-fail '#define PLUGIN_DIR "%s/@INSTALL_PLUGINDIR@"' "#define PLUGIN_DIR \"$out/lib/mariadb/plugin\"" \
--replace-fail '#define PKG_PLUGINDIR "%s/@INSTALL_PLUGINDIR@"' "#define PKG_PLUGINDIR \"$out/lib/mariadb/plugin\""
''
+ lib.optionalString stdenv.hostPlatform.isStatic ''
# Disables all dynamic plugins
substituteInPlace cmake/plugins.cmake \
--replace 'if(''${CC_PLUGIN_DEFAULT} STREQUAL "DYNAMIC")' 'if(''${CC_PLUGIN_DEFAULT} STREQUAL "INVALID")'
--replace-fail 'if(''${CC_PLUGIN_DEFAULT} STREQUAL "DYNAMIC")' 'if(''${CC_PLUGIN_DEFAULT} STREQUAL "INVALID")'
# Force building static libraries
substituteInPlace libmariadb/CMakeLists.txt \
--replace 'libmariadb SHARED' 'libmariadb STATIC'
--replace-fail 'libmariadb SHARED' 'libmariadb STATIC'
'';
# The cmake setup-hook uses $out/lib by default, this is not the case here.
@@ -86,6 +95,7 @@ stdenv.mkDerivation {
meta = with lib; {
description = "Client library that can be used to connect to MySQL or MariaDB";
homepage = "https://github.com/mariadb-corporation/mariadb-connector-c";
license = licenses.lgpl21Plus;
maintainers = with maintainers; [ globin ];
platforms = platforms.all;