postgresql: move dynamic modules to default output
Dynamic modules are technically libraries, but are not used by other packages. Instead they are loaded by PostgreSQL itself, e.g. as extensions. Those just increased the size of the lib output without benefit. This removes the NIX_PGLIBDIR hack introduced in #17838 and instead makes sure that pg_config always returns the correct PGLIBDIR. The test for postgis introduced in the same PR is still passing with the change.
This commit is contained in:
@@ -117,7 +117,6 @@ let
|
||||
${preBuildAndTest}
|
||||
${maybeEnterBuildAndTestSubdir}
|
||||
|
||||
NIX_PGLIBDIR="${postgresql}/lib" \
|
||||
PGRX_BUILD_FLAGS="--frozen -j $NIX_BUILD_CORES ${builtins.concatStringsSep " " cargoBuildFlags}" \
|
||||
${lib.optionalString stdenv.isDarwin ''RUSTFLAGS="''${RUSTFLAGS:+''${RUSTFLAGS} }-Clink-args=-Wl,-undefined,dynamic_lookup"''} \
|
||||
cargo pgrx package \
|
||||
|
||||
@@ -112,7 +112,6 @@ let
|
||||
(if atLeast "16" then ./patches/relative-to-symlinks-16+.patch else ./patches/relative-to-symlinks.patch)
|
||||
./patches/less-is-more.patch
|
||||
./patches/paths-for-split-outputs.patch
|
||||
./patches/specify_pkglibdir_at_runtime.patch
|
||||
./patches/paths-with-postgresql-suffix.patch
|
||||
|
||||
(substituteAll {
|
||||
@@ -129,18 +128,13 @@ let
|
||||
installTargets = [ "install-world" ];
|
||||
|
||||
postPatch = ''
|
||||
substituteInPlace "src/Makefile.global.in" --subst-var out
|
||||
# Hardcode the path to pgxs so pg_config returns the path in $out
|
||||
substituteInPlace "src/common/config_info.c" --subst-var out
|
||||
'' + lib.optionalString jitSupport ''
|
||||
# Force lookup of jit stuff in $out instead of $lib
|
||||
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"
|
||||
@@ -159,11 +153,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 ${stdenv'.cc}/bin/clang clang
|
||||
nuke-refs $out/lib/llvmjit_types.bc $(find $out/lib/bitcode -type f)
|
||||
@@ -225,7 +214,7 @@ let
|
||||
in import ./ext newSelf newSuper;
|
||||
|
||||
withPackages = postgresqlWithPackages {
|
||||
inherit makeWrapper buildEnv;
|
||||
inherit buildEnv;
|
||||
postgresql = this;
|
||||
}
|
||||
this.pkgs;
|
||||
@@ -271,30 +260,14 @@ let
|
||||
};
|
||||
});
|
||||
|
||||
postgresqlWithPackages = { postgresql, makeWrapper, buildEnv }: pkgs: f: buildEnv {
|
||||
postgresqlWithPackages = { postgresql, buildEnv }: pkgs: f: buildEnv {
|
||||
name = "postgresql-and-plugins-${postgresql.version}";
|
||||
paths = f pkgs ++ [
|
||||
postgresql
|
||||
postgresql.lib
|
||||
postgresql.man # in case user installs this into environment
|
||||
];
|
||||
nativeBuildInputs = [ makeWrapper ];
|
||||
|
||||
|
||||
# We include /bin to ensure the $out/bin directory is created, which is
|
||||
# needed because we'll be removing the files from that directory in postBuild
|
||||
# below. See #22653
|
||||
pathsToLink = ["/" "/bin"];
|
||||
|
||||
# Note: the duplication of executables is about 4MB size.
|
||||
# So a nicer solution was patching postgresql to allow setting the
|
||||
# libdir explicitly.
|
||||
postBuild = ''
|
||||
mkdir -p $out/bin
|
||||
rm $out/bin/{pg_config,postgres,pg_ctl}
|
||||
cp --target-directory=$out/bin ${postgresql}/bin/{postgres,pg_config,pg_ctl}
|
||||
wrapProgram $out/bin/postgres --set NIX_PGLIBDIR $out/lib
|
||||
'';
|
||||
pathsToLink = ["/"];
|
||||
|
||||
passthru.version = postgresql.version;
|
||||
passthru.psqlSchema = postgresql.psqlSchema;
|
||||
|
||||
@@ -9,3 +9,14 @@
|
||||
strlcat(path, "/pgxs/src/makefiles/pgxs.mk", sizeof(path));
|
||||
cleanup_path(path);
|
||||
configdata[i].setting = pstrdup(path);
|
||||
--- a/src/Makefile.global.in
|
||||
+++ b/src/Makefile.global.in
|
||||
@@ -116,7 +116,7 @@ endif
|
||||
|
||||
libdir := @libdir@
|
||||
|
||||
-pkglibdir = $(libdir)
|
||||
+pkglibdir = @out@/lib
|
||||
ifeq "$(findstring pgsql, $(pkglibdir))" ""
|
||||
ifeq "$(findstring postgres, $(pkglibdir))" ""
|
||||
override pkglibdir := $(pkglibdir)/postgresql
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
--- a/src/port/path.c
|
||||
+++ b/src/port/path.c
|
||||
@@ -714,7 +714,11 @@
|
||||
void
|
||||
get_lib_path(const char *my_exec_path, char *ret_path)
|
||||
{
|
||||
- make_relative_path(ret_path, LIBDIR, PGBINDIR, my_exec_path);
|
||||
+ char const * const nix_pglibdir = getenv("NIX_PGLIBDIR");
|
||||
+ if(nix_pglibdir == NULL)
|
||||
+ make_relative_path(ret_path, LIBDIR, PGBINDIR, my_exec_path);
|
||||
+ else
|
||||
+ make_relative_path(ret_path, nix_pglibdir, PGBINDIR, my_exec_path);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -723,7 +727,11 @@
|
||||
void
|
||||
get_pkglib_path(const char *my_exec_path, char *ret_path)
|
||||
{
|
||||
- make_relative_path(ret_path, PKGLIBDIR, PGBINDIR, my_exec_path);
|
||||
+ char const * const nix_pglibdir = getenv("NIX_PGLIBDIR");
|
||||
+ if(nix_pglibdir == NULL)
|
||||
+ make_relative_path(ret_path, PKGLIBDIR, PGBINDIR, my_exec_path);
|
||||
+ else
|
||||
+ make_relative_path(ret_path, nix_pglibdir, PGBINDIR, my_exec_path);
|
||||
}
|
||||
|
||||
/*
|
||||
Reference in New Issue
Block a user