From 0a22d8393c53305354c4c6d8e784e7d59caa039a Mon Sep 17 00:00:00 2001 From: Jim Myhrberg Date: Sun, 16 May 2021 17:02:05 +0100 Subject: [PATCH] fix(shared-libraries): stop aggressive dylib re-linking This seems to be the cause of SVG rendering crashing, as it re-links libiconv.2.dylib from /usr/lib/libiconv.2.dylib to @executable_path/lib/lib/libiconv.2.dylib within libintl.8.dylib. When this re-linking does not happen, SVG rendering works without crashing Emacs. Some further testing is needed by installing brew dependencies by building them from source, in an attempt to get various libraries all linking to homebrew-built versions, to get as many shared libraries as possible embedded into the application bundle. Fixes #12 --- build-emacs-for-macos | 26 -------------------------- 1 file changed, 26 deletions(-) diff --git a/build-emacs-for-macos b/build-emacs-for-macos index a6d49e6..0077e20 100755 --- a/build-emacs-for-macos +++ b/build-emacs-for-macos @@ -617,7 +617,6 @@ class LibEmbedder < AbstractEmbedder FileUtils.cd(File.dirname(app)) do copy_libs(binary) copy_extra_libs(extra_libs, binary) if extra_libs.any? - self_ref_libs(binary) end end @@ -673,31 +672,6 @@ class LibEmbedder < AbstractEmbedder end end - def self_ref_libs(exe) - rel_path = Pathname.new(lib_dir).relative_path_from( - Pathname.new(File.dirname(exe)) - ).to_s - lib_paths ||= Dir.glob("#{lib_dir}/*").select { |f| File.file?(f) } - libs = lib_paths.map { |f| File.basename(f) } - - ([exe] + lib_paths).each do |bin_path| - `otool -L "#{bin_path}"`.split("\n")[1..-1].each do |line| - match = line.match(%r{^\s+(.+/(lib[^/ ]+))\s}) - next unless match - next if match[1].start_with?('@executable_path/') - next unless libs.include?(match[2]) - - while_writable(bin_path) do - system( - 'install_name_tool', '-change', match[1], - File.join('@executable_path', rel_path, match[2].to_s), - bin_path - ) - end - end - end - end - def while_writable(file) mode = File.stat(file).mode File.chmod(0o775, file)