From d61c5c4816afed4692c32a23db08c01ee2457755 Mon Sep 17 00:00:00 2001 From: Wez Furlong Date: Thu, 26 Mar 2020 05:46:49 -0700 Subject: [PATCH] getdeps: fixup the dyndeps fixed up by fixup dyndeps Summary: On linux we didn't account for the `--final-install-prefix` argument which meant that the binaries would always be rewritten to be relative to the destdir. This commit fixes that. Refs: https://github.com/facebook/watchman/issues/760 (this doesn't deal with the compiled in statedir being in the scratch path though) Reviewed By: simpkins Differential Revision: D20659749 fbshipit-source-id: 1e8e198a58361882249c33a67f54a7d97b849257 --- build/fbcode_builder/getdeps/dyndeps.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/build/fbcode_builder/getdeps/dyndeps.py b/build/fbcode_builder/getdeps/dyndeps.py index d1014ad52..3af26fc1e 100644 --- a/build/fbcode_builder/getdeps/dyndeps.py +++ b/build/fbcode_builder/getdeps/dyndeps.py @@ -203,9 +203,11 @@ class ElfDeps(DepBase): subprocess.check_call([sys.executable, sys.argv[0], "build", "patchelf"]) # ... and that we know where it lives self.patchelf = os.path.join( - subprocess.check_output( - [sys.executable, sys.argv[0], "show-inst-dir", "patchelf"] - ).strip(), + os.fsdecode( + subprocess.check_output( + [sys.executable, sys.argv[0], "show-inst-dir", "patchelf"] + ).strip() + ), "bin/patchelf", ) @@ -221,8 +223,11 @@ class ElfDeps(DepBase): return lines def rewrite_dep(self, objfile, depname, old_dep, new_dep, final_lib_dir): + final_dep = os.path.join( + final_lib_dir, os.path.relpath(new_dep, self.munged_lib_dir) + ) subprocess.check_call( - [self.patchelf, "--replace-needed", depname, new_dep, objfile] + [self.patchelf, "--replace-needed", depname, final_dep, objfile] ) def is_objfile(self, objfile):