From 0a22d8393c53305354c4c6d8e784e7d59caa039a Mon Sep 17 00:00:00 2001 From: Jim Myhrberg Date: Sun, 16 May 2021 17:02:05 +0100 Subject: [PATCH 1/4] 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) From 3ffeb4854c5ec02f6c4ac69ac4587e34bda281c9 Mon Sep 17 00:00:00 2001 From: Jim Myhrberg Date: Sun, 16 May 2021 17:08:02 +0100 Subject: [PATCH 2/4] chore(shared-libraries): add @executable_path/lib to @rpath for good measure --- build-emacs-for-macos | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/build-emacs-for-macos b/build-emacs-for-macos index 0077e20..a090140 100755 --- a/build-emacs-for-macos +++ b/build-emacs-for-macos @@ -628,6 +628,11 @@ class LibEmbedder < AbstractEmbedder Pathname.new(File.dirname(exe)) ).to_s + while_writable(exe) do + system('install_name_tool', '-add_rpath', + File.join('@executable_path', rel_path), exe) + end + `otool -L "#{exe}"`.split("\n")[1..-1].each do |line| match = line.match(%r{^\s+(.+/(lib[^/ ]+))\s}) next unless match && match[1].start_with?(lib_source) From bf7c4d5debf32980dbbabc1ea99b58b266390011 Mon Sep 17 00:00:00 2001 From: Jim Myhrberg Date: Sun, 16 May 2021 20:31:48 +0100 Subject: [PATCH 3/4] fix(svg): enable SVG by default via librsvg --- build-emacs-for-macos | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/build-emacs-for-macos b/build-emacs-for-macos index a090140..dbd38fc 100755 --- a/build-emacs-for-macos +++ b/build-emacs-for-macos @@ -314,7 +314,7 @@ class Build configure_flags << '--with-xwidgets' end configure_flags << native_comp_configure_flag if options[:native_comp] - configure_flags << '--without-rsvg' unless options[:rsvg] + configure_flags << '--without-rsvg' if options[:rsvg] == false run_cmd './configure', *configure_flags @@ -819,7 +819,7 @@ if __FILE__ == $PROGRAM_NAME work_dir: File.expand_path(__dir__), native_full_aot: false, parallel: Etc.nprocessors, - rsvg: false, + rsvg: true, xwidgets: true } @@ -863,9 +863,10 @@ if __FILE__ == $PROGRAM_NAME cli_options[:native_full_aot] = v end - opts.on('--rsvg', 'Enable SVG image support via librsvg, ' \ - 'can yield a unstable build (default: disabled)') do - cli_options[:rsvg] = true + opts.on('--[no-]rsvg', + 'Enable/disable SVG image support via librsvg ' \ + '(default: enabled)') do |v| + cli_options[:rsvg] = v end opts.on('--no-titlebar', 'Apply no-titlebar patch (default: disabled)') do From 5c48445397c654e703584ea1f05bec50bcea200a Mon Sep 17 00:00:00 2001 From: Jim Myhrberg Date: Sun, 16 May 2021 20:32:57 +0100 Subject: [PATCH 4/4] chore(cli): improve CLI help output --- build-emacs-for-macos | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/build-emacs-for-macos b/build-emacs-for-macos index dbd38fc..9538bf6 100755 --- a/build-emacs-for-macos +++ b/build-emacs-for-macos @@ -836,18 +836,19 @@ if __FILE__ == $PROGRAM_NAME opts.on('-j', '--parallel COUNT', 'Compile using COUNT parallel processes ' \ - "(detected: #{cli_options[:parallel]})") do |v| + "(default: #{cli_options[:parallel]})") do |v| cli_options[:parallel] = v end - opts.on('--git-sha SHA', 'Override detected git SHA of specified ' \ - 'branch allowing builds of old commits') do |v| + opts.on('--git-sha SHA', + 'Override detected git SHA of specified ' \ + 'branch allowing builds of old commits') do |v| cli_options[:git_sha] = v end opts.on('--[no-]xwidgets', - 'Enable/disable XWidgets ' \ - '(default: enabled if supported)') do |v| + 'Enable/disable XWidgets if supported ' \ + '(default: enabled)') do |v| cli_options[:xwidgets] = v end