diff options
author | Matthew Waters <matthew@centricular.com> | 2022-02-01 18:59:07 +1100 |
---|---|---|
committer | GStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org> | 2022-02-01 11:18:35 +0000 |
commit | 5dc5688fa332105120f4d212cf227e7046276a61 (patch) | |
tree | dc14a3da7d7bcd7b55bc87b5e981b223ddb7d6b6 | |
parent | 0a8183e3bf5dedb4fb546aa3930a88e5f3136240 (diff) |
build: fix relocating universal binaries1.19.90
The process for relocating a universal binary involves copying the
original single architecture binaries to a temporary directory without
preserving the directory layout. The merge of some resources (libraries,
executables) depends on where exactly the binary is located in order to
correctly compute the rpath for the file. This is incompatible.
Fix by passing to the relocation and rpath handling code, the path to
the original binary so that rpath computation can be performed on that
file location instead.
Part-of: <https://gitlab.freedesktop.org/gstreamer/cerbero/-/merge_requests/791>
-rwxr-xr-x | cerbero/tools/osxrelocator.py | 16 | ||||
-rw-r--r-- | cerbero/tools/osxuniversalgenerator.py | 2 |
2 files changed, 13 insertions, 5 deletions
diff --git a/cerbero/tools/osxrelocator.py b/cerbero/tools/osxrelocator.py index 4f2cc440..85b788cd 100755 --- a/cerbero/tools/osxrelocator.py +++ b/cerbero/tools/osxrelocator.py @@ -49,8 +49,8 @@ class OSXRelocator(object): def relocate_dir(self, dirname): self.parse_dir(os.path.join(self.root, dirname)) - def relocate_file(self, object_file): - self.change_libs_path(object_file) + def relocate_file(self, object_file, original_file=None): + self.change_libs_path(object_file, original_file) def change_id(self, object_file, id=None): id = id or object_file.replace(self.lib_prefix, '@rpath') @@ -60,8 +60,16 @@ class OSXRelocator(object): cmd = [INT_CMD, '-id', id, object_file] shell.new_call(cmd, fail=False, logfile=self.logfile) - def change_libs_path(self, object_file): - depth = len(object_file.split('/')) - len(self.root.split('/')) - 1 + def change_libs_path(self, object_file, original_file=None): + # @object_file: the actual file location + # @original_file: where the file will end up in the output directory + # structure and the basis of how to calculate rpath entries. This may + # be different from where the file is currently located e.g. when + # creating a fat binary from copy of the original file in a temporary + # location. + if original_file is None: + original_file = object_file + depth = len(original_file.split('/')) - len(self.lib_prefix.split('/')) - 1 p_depth = '/..' * depth rpaths = ['.'] rpaths += ['@loader_path' + p_depth, '@executable_path' + p_depth] diff --git a/cerbero/tools/osxuniversalgenerator.py b/cerbero/tools/osxuniversalgenerator.py index 19a72072..e1e056f3 100644 --- a/cerbero/tools/osxuniversalgenerator.py +++ b/cerbero/tools/osxuniversalgenerator.py @@ -116,7 +116,7 @@ class OSXUniversalGenerator(object): False, logfile=self.logfile) # since we are using a temporary file, we must force the library id # name to real one and not based on the filename - relocator.relocate_file(tmp.name) + relocator.relocate_file(tmp.name, f) relocator.change_id(tmp.name, id=f.replace(prefix_to_replace, self.output_root)) cmd = [self.LIPO_CMD, '-create'] + [f.name for f in tmp_inputs] + ['-output', output] shell.new_call(cmd) |