Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

postgresql: libpq-only lib output #273175

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions pkgs/servers/sql/postgresql/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ let
, pkg-config, libxml2, tzdata, libkrb5, substituteAll, darwin

# This is important to obtain a version of `libpq` that does not depend on systemd.
, enableSystemd ? lib.meta.availableOn stdenv.hostPlatform systemd && !stdenv.hostPlatform.isStatic
, enableSystemd ? lib.meta.availableOn stdenv.hostPlatform systemd && !stdenv.buildPlatform.isDarwin && !stdenv.hostPlatform.isStatic
, gssSupport ? with stdenv.hostPlatform; !isWindows && !isStatic

# for postgresql.pkgs
Expand Down Expand Up @@ -87,7 +87,7 @@ let
"--with-libxml"
"--with-icu"
"--sysconfdir=/etc"
"--libdir=$(lib)/lib"
"--libdir=$(out)/lib"
"--with-system-tzdata=${tzdata}/share/zoneinfo"
"--enable-debug"
(lib.optionalString enableSystemd "--with-systemd")
Expand Down Expand Up @@ -166,18 +166,15 @@ let
# Hardcode the path to pgxs so pg_config returns the path in $out
substituteInPlace "src/common/config_info.c" --replace HARDCODED_PGXS_PATH "$out/lib"
'' + lib.optionalString jitSupport ''
# Force lookup of jit stuff in $out instead of $lib
# Hardcode lookup of jit stuff in $out
substituteInPlace src/backend/jit/jit.c --replace pkglib_path \"$out/lib\"
substituteInPlace src/backend/jit/llvm/llvmjit.c --replace pkglib_path \"$out/lib\"
substituteInPlace src/backend/jit/llvm/llvmjit_inline.cpp --replace pkglib_path \"$out/lib\"
'';

postInstall =
''
moveToOutput "lib/pgxs" "$out" # looks strange, but not deleting it
moveToOutput "lib/libpgcommon*.a" "$out"
moveToOutput "lib/libpgport*.a" "$out"
moveToOutput "lib/libecpg*" "$out"
moveToOutput "lib/libpq.*" "$lib"

# Prevent a retained dependency on gcc-wrapper.
substituteInPlace "$out/lib/pgxs/src/Makefile.global" --replace ${stdenv'.cc}/bin/ld ld
Expand All @@ -193,11 +190,6 @@ let
done
fi
'' + lib.optionalString jitSupport ''
# Move the bitcode and libllvmjit.so library out of $lib; otherwise, every client that
# depends on libpq.so will also have libLLVM.so in its closure too, bloating it
moveToOutput "lib/bitcode" "$out"
moveToOutput "lib/llvmjit*" "$out"

# In the case of JIT support, prevent a retained dependency on clang-wrapper
substituteInPlace "$out/lib/pgxs/src/Makefile.global" --replace ${self.llvmPackages.stdenv.cc}/bin/clang clang
nuke-refs $out/lib/llvmjit_types.bc $(find $out/lib/bitcode -type f)
Expand All @@ -221,7 +213,15 @@ let
''}
'';

postFixup = lib.optionalString (!stdenv'.isDarwin && stdenv'.hostPlatform.libc == "glibc")
postFixup = ''
substituteInPlace "$out/lib/pkgconfig/libpq.pc" \
--replace 'libdir=''${exec_prefix}/lib' \
"libdir=$lib/lib"
''
+ lib.optionalString stdenv'.isDarwin ''
install_name_tool -id $lib/lib/libpq.5.dylib $lib/lib/libpq.5.dylib
''
+ lib.optionalString (!stdenv'.isDarwin && stdenv'.hostPlatform.libc == "glibc")
''
# initdb needs access to "locale" command from glibc.
wrapProgram $out/bin/initdb --prefix PATH ":" ${glibc.bin}/bin
Expand Down