From 6f7e06bd5a022d49972a92e7d317420fddd41a88 Mon Sep 17 00:00:00 2001 From: Jan Tojnar Date: Sat, 4 May 2019 05:47:04 +0200 Subject: [PATCH 1/2] networkmanager: Stop using libredirect for building docs Our gobject-introspection patches make the shared library paths absolute in the GIR files. When building docs, the library is not yet installed, though, so we need to replace the absolute path with a local one during build. Previously we used LD_PRELOAD to load libredirect and rewrite the installed paths to ones in the build directory. That was unnecessary complicated and many people spent whole night trying to figure out why it breaks some programs. Using a symlink from the installed location to the build directory fixes the issue as well, while having much less moving parts, thus being easier to grasp. The symlink will be overridden during installation. --- .../networking/network-manager/default.nix | 18 ++++++++---------- .../network-manager/fix-docs-build.patch | 11 ----------- 2 files changed, 8 insertions(+), 21 deletions(-) delete mode 100644 pkgs/tools/networking/network-manager/fix-docs-build.patch diff --git a/pkgs/tools/networking/network-manager/default.nix b/pkgs/tools/networking/network-manager/default.nix index c4a34dc6a909..e0cfac569358 100644 --- a/pkgs/tools/networking/network-manager/default.nix +++ b/pkgs/tools/networking/network-manager/default.nix @@ -58,13 +58,6 @@ in stdenv.mkDerivation rec { # Meson does not support using different directories during build and # for installation like Autotools did with flags passed to make install. ./fix-install-paths.patch - - # Our gobject-introspection patches make the shared library paths absolute - # in the GIR files. When building docs, the library is not yet installed, - # though, so we need to replace the absolute path with a local one during build. - # We are replacing the variables in postPatch since substituteAll does not support - # placeholders. - ./fix-docs-build.patch ]; buildInputs = [ @@ -87,10 +80,15 @@ in stdenv.mkDerivation rec { postPatch = '' patchShebangs ./tools patchShebangs libnm/generate-setting-docs.py + ''; - substituteInPlace libnm/meson.build \ - --subst-var-by DOCS_LD_PRELOAD "${libredirect}/lib/libredirect.so" \ - --subst-var-by DOCS_NIX_REDIRECTS "${placeholder "out"}/lib/libnm.so.0=$PWD/build/libnm/libnm.so.0" + preBuild = '' + # Our gobject-introspection patches make the shared library paths absolute + # in the GIR files. When building docs, the library is not yet installed, + # though, so we need to replace the absolute path with a local one during build. + # We are using a symlink that will be overridden during installation. + mkdir -p ${placeholder "out"}/lib + ln -s $PWD/libnm/libnm.so.0 ${placeholder "out"}/lib/libnm.so.0 ''; postInstall = '' diff --git a/pkgs/tools/networking/network-manager/fix-docs-build.patch b/pkgs/tools/networking/network-manager/fix-docs-build.patch deleted file mode 100644 index 45e18c42fbe1..000000000000 --- a/pkgs/tools/networking/network-manager/fix-docs-build.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/libnm/meson.build -+++ b/libnm/meson.build -@@ -262,6 +262,8 @@ - 'env', '-i', - 'GI_TYPELIB_PATH=' + gi_typelib_path, - 'LD_LIBRARY_PATH=' + ld_library_path, -+ 'LD_PRELOAD=' + '@DOCS_LD_PRELOAD@', -+ 'NIX_REDIRECTS=' + '@DOCS_NIX_REDIRECTS@', - ] - - name = 'nm-property-docs.xml' From a0c6efb9fd23b8e9b44a123252afc863b88eb8d7 Mon Sep 17 00:00:00 2001 From: Jan Tojnar Date: Sat, 4 May 2019 05:53:18 +0200 Subject: [PATCH 2/2] libredirect: remove dlopen support While it might be useful in some cases, there are too many caveats to be worth it. When libredirect intercepts dlopen call and calls the original function, the dynamic loader will use libredirect.so's DT_RUNPATH entry instead of the one from the ELF file the dlopen call originated from. That means that when program tries to dlopen a library that it expects to find on its RPATH, the call will fail. This broke Sublime Text for just that reason. --- pkgs/build-support/libredirect/libredirect.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/pkgs/build-support/libredirect/libredirect.c b/pkgs/build-support/libredirect/libredirect.c index dcf3a2016bc2..655399af58f5 100644 --- a/pkgs/build-support/libredirect/libredirect.c +++ b/pkgs/build-support/libredirect/libredirect.c @@ -166,10 +166,3 @@ int execv(const char *path, char *const argv[]) char buf[PATH_MAX]; return execv_real(rewrite(path, buf), argv); } - -void *dlopen(const char *filename, int flag) -{ - void * (*__dlopen_real) (const char *, int) = dlsym(RTLD_NEXT, "dlopen"); - char buf[PATH_MAX]; - return __dlopen_real(rewrite(filename, buf), flag); -}