From 445371f309a62e9107ad78fb3c65fff768efb43c Mon Sep 17 00:00:00 2001 From: Wolfgang Walther Date: Sat, 30 Nov 2024 17:02:08 +0100 Subject: [PATCH 1/3] postgresql: enable strictDeps --- pkgs/servers/sql/postgresql/generic.nix | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pkgs/servers/sql/postgresql/generic.nix b/pkgs/servers/sql/postgresql/generic.nix index 79111b589938..a2826aa012f7 100644 --- a/pkgs/servers/sql/postgresql/generic.nix +++ b/pkgs/servers/sql/postgresql/generic.nix @@ -149,6 +149,8 @@ let ]; }; + strictDeps = true; + buildInputs = [ zlib readline @@ -171,6 +173,7 @@ let ++ lib.optionals nlsSupport [ gettext ]; nativeBuildInputs = [ + libxml2 makeWrapper pkg-config removeReferencesTo From 3bd9f92eae830c03ec6e37b1727d4b43052149eb Mon Sep 17 00:00:00 2001 From: Wolfgang Walther Date: Sun, 29 Sep 2024 14:48:16 +0200 Subject: [PATCH 2/3] pkgsStatic.postgresql: fix build The underlying problem was fixed as a side-effect of [1], for reasons unknown to me. In the current state, it's enough to disable a few breaking dependencies to make the build pass. Note, that this builds the full package, including backend. However, the backend is not working, yet: Loading shared modules, which PostgreSQL heavily depends is still broken. Further, all binaries in the default output, even client binaries such as psql, are currently dynamically linked against libpq.so. While the current autoconf based build system doesn't support changing this, this might be possible in the future with meson. However, not all is bad: Fixing the build allows using the static libpq.a library, which is probably the one thing that most users want from pkgsStatic.postgresql anyway. Resolves #191920 [1]: 77977286d80c9bfb77cbf80989d41c59d66dccf8 --- pkgs/servers/sql/postgresql/generic.nix | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/pkgs/servers/sql/postgresql/generic.nix b/pkgs/servers/sql/postgresql/generic.nix index a2826aa012f7..54658d76b959 100644 --- a/pkgs/servers/sql/postgresql/generic.nix +++ b/pkgs/servers/sql/postgresql/generic.nix @@ -53,7 +53,11 @@ let , libkrb5 # icu - , icuSupport ? true + # Building with icu in pkgsStatic gives tons of "undefined reference" errors like this: + # /nix/store/452lkaak37d3mzzn3p9ak7aa3wzhdqaj-icu4c-74.2-x86_64-unknown-linux-musl/lib/libicuuc.a(chariter.ao): + # (.data.rel.ro._ZTIN6icu_7417CharacterIteratorE[_ZTIN6icu_7417CharacterIteratorE]+0x0): + # undefined reference to `vtable for __cxxabiv1::__si_class_type_info' + , icuSupport ? !stdenv.hostPlatform.isStatic , icu # JIT @@ -71,7 +75,11 @@ let , gettext # PAM - , pamSupport ? stdenv.hostPlatform.isLinux + # Building with linux-pam in pkgsStatic gives a few "undefined reference" errors like this: + # /nix/store/3s55icpsbc36sgn7sa8q3qq4z6al6rlr-linux-pam-static-x86_64-unknown-linux-musl-1.6.1/lib/libpam.a(pam_audit.o): + # in function `pam_modutil_audit_write':(.text+0x571): + # undefined reference to `audit_close' + , pamSupport ? stdenv.hostPlatform.isLinux && !stdenv.hostPlatform.isStatic , linux-pam # PL/Perl @@ -267,7 +275,7 @@ let # because there is a realistic use-case for extensions to locate the /lib directory to # load other shared modules. remove-references-to -t "$dev" -t "$doc" -t "$man" "$out/bin/postgres" - + '' + lib.optionalString (!stdenv'.hostPlatform.isStatic) '' if [ -z "''${dontDisableStatic:-}" ]; then # Remove static libraries in case dynamic are available. for i in $lib/lib/*.a; do @@ -278,6 +286,7 @@ let fi done fi + '' + '' # The remaining static libraries are libpgcommon.a, libpgport.a and related. # Those are only used when building e.g. extensions, so go to $dev. moveToOutput "lib/*.a" "$dev" @@ -306,7 +315,7 @@ let # Also see /doc/stdenv/platform-notes.chapter.md doCheck = false; # Tests just get stuck on macOS 14.x for v13 and v14 - doInstallCheck = !(stdenv'.hostPlatform.isDarwin && olderThan "15"); + doInstallCheck = !(stdenv'.hostPlatform.isDarwin && olderThan "15") && !(stdenv'.hostPlatform.isStatic); installCheckTarget = "check-world"; passthru = let From a77adf3285ce0dde751b77ff970098fea1913870 Mon Sep 17 00:00:00 2001 From: Wolfgang Walther Date: Thu, 28 Nov 2024 20:31:41 +0100 Subject: [PATCH 3/3] postgresql: add -export_dynamic on darwin only for v16 --- pkgs/servers/sql/postgresql/generic.nix | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/pkgs/servers/sql/postgresql/generic.nix b/pkgs/servers/sql/postgresql/generic.nix index 54658d76b959..30191c1986ad 100644 --- a/pkgs/servers/sql/postgresql/generic.nix +++ b/pkgs/servers/sql/postgresql/generic.nix @@ -218,9 +218,8 @@ let ++ lib.optionals pythonSupport [ "--with-python" ] ++ lib.optionals jitSupport [ "--with-llvm" ] ++ lib.optionals pamSupport [ "--with-pam" ] - # This could be removed once the upstream issue is resolved: - # https://postgr.es/m/flat/427c7c25-e8e1-4fc5-a1fb-01ceff185e5b%40technowledgy.de - ++ lib.optionals (stdenv'.hostPlatform.isDarwin && atLeast "16") [ "LDFLAGS_EX_BE=-Wl,-export_dynamic" ] + # This can be removed once v17 is removed. v18+ ships with it. + ++ lib.optionals (stdenv'.hostPlatform.isDarwin && atLeast "16" && olderThan "18") [ "LDFLAGS_EX_BE=-Wl,-export_dynamic" ] ++ lib.optionals (atLeast "17" && !perlSupport) [ "--without-perl" ] ++ lib.optionals ldapSupport [ "--with-ldap" ] ++ lib.optionals tclSupport [ "--with-tcl" ]