mirror of
https://github.com/jimeh/build-emacs-for-macos.git
synced 2026-02-19 13:06:38 +00:00
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
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user