From bd8187065928b9f79de8b14222c98f8dc34bfe5f Mon Sep 17 00:00:00 2001 From: Jim Myhrberg Date: Mon, 7 Jun 2021 23:03:52 +0100 Subject: [PATCH] fix(native_comp): crash on launch when gcc homebrew package was not installed It turns out all *.eln files link against the libgcc dylib in homebrew: /usr/local/lib/gcc/11/libgcc_s.1.dylib So here we find all *.eln files in all relevant paths they may be depending on how old of a native-comp source tree we're building, and copy in any shared libs that resides within the homebrew prefix. Just like we do for all other binaries that we copy libs for. --- build-emacs-for-macos | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/build-emacs-for-macos b/build-emacs-for-macos index 3ca9a3a..cd3fc27 100755 --- a/build-emacs-for-macos +++ b/build-emacs-for-macos @@ -652,11 +652,35 @@ class LibEmbedder < AbstractEmbedder FileUtils.cd(File.dirname(app)) do copy_libs(binary) copy_extra_libs(extra_libs, binary) if extra_libs.any? + if eln_files.any? + info "Embedding libraries for #{eln_files.size} *.eln files " \ + 'within Emacs.app' + rel_path = Pathname.new(lib_dir).relative_path_from( + Pathname.new(File.dirname(binary)) + ).to_s + eln_files.each { |f| copy_libs(f, rel_path) } + end end end private + def eln_files + @eln_files ||= Dir[ + File.join( + app, 'Contents', 'Resources', 'native-lisp', '**', '*.eln' + ), + File.join( + app, 'Contents', 'MacOS', 'lib', 'emacs', '**', + 'native-lisp', '**', '*.eln' + ), + File.join( + app, 'Contents', 'MacOS', 'libexec', 'emacs', '**', + 'eln-cache', '**', '*.eln' + ) + ] + end + def copy_libs(exe, rel_path = nil) exe_file = File.basename(exe) rel_path ||= Pathname.new(lib_dir).relative_path_from(