Compare commits

..

12 Commits

Author SHA1 Message Date
9f6ec5954f chore(release): 0.4.13 2021-05-22 18:52:45 +01:00
9ea79670d8 Merge pull request #42 from jimeh/prepare-for-codesign
feat(codesign): minor internal fix to output Emacs.app bundle for compatibility with codesign
2021-05-22 18:51:09 +01:00
72e40248e1 chore(cli): remove deprecated flags and update readme usage 2021-05-22 18:33:16 +01:00
7259111478 fix(codesign): prevent "bundle format unrecognized" error from codesign
Apple's codesign CLI toolthrows a "bundle format unrecognized" error if
there are any folders within the application that contain two dots in
their name.

Hence we need to get rid of the one instance of that we end up with from
GCC, and update the native-comp patch accordingly.

As of writing, this means renaming:
Emacs.app/Contents/MacOS/lib/gcc/11/gcc/x86_64-apple-darwin20/11.1.0

To:
Emacs.app/Contents/MacOS/lib/gcc/11/gcc/x86_64-apple-darwin20/11
2021-05-20 01:55:41 +01:00
bb45cda023 fix(embed): avoid potential error caused by trying to set duplicate rpath 2021-05-20 01:55:41 +01:00
ab872202df chore: minor improvement 2021-05-20 01:55:41 +01:00
2d1c5d47d9 chore(release): 0.4.12 2021-05-17 23:14:50 +01:00
30a71c423e Merge pull request #40 from jimeh/fix-svg
fix(svg): fix SVG rendering crash and enable SVG support by default
2021-05-17 23:12:44 +01:00
5c48445397 chore(cli): improve CLI help output 2021-05-17 23:12:12 +01:00
bf7c4d5deb fix(svg): enable SVG by default via librsvg 2021-05-17 23:12:12 +01:00
3ffeb4854c chore(shared-libraries): add @executable_path/lib to @rpath for good measure 2021-05-17 23:12:12 +01:00
0a22d8393c 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
2021-05-17 23:11:51 +01:00
4 changed files with 74 additions and 67 deletions

View File

@@ -2,6 +2,22 @@
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
### [0.4.13](https://github.com/jimeh/build-emacs-for-macos/compare/0.4.12...0.4.13) (2021-05-22)
### Bug Fixes
* **codesign:** prevent "bundle format unrecognized" error from codesign ([7259111](https://github.com/jimeh/build-emacs-for-macos/commit/7259111478ecb838dea9c8f50ea39eafdf47ed5a))
* **embed:** avoid potential error caused by trying to set duplicate rpath ([bb45cda](https://github.com/jimeh/build-emacs-for-macos/commit/bb45cda0231e99618571dc835348cf5c3345e277))
### [0.4.12](https://github.com/jimeh/build-emacs-for-macos/compare/0.4.11...0.4.12) (2021-05-17)
### Bug Fixes
* **shared-libraries:** stop aggressive dylib re-linking ([0a22d83](https://github.com/jimeh/build-emacs-for-macos/commit/0a22d8393c53305354c4c6d8e784e7d59caa039a)), closes [#12](https://github.com/jimeh/build-emacs-for-macos/issues/12)
* **svg:** enable SVG by default via librsvg ([bf7c4d5](https://github.com/jimeh/build-emacs-for-macos/commit/bf7c4d5debf32980dbbabc1ea99b58b266390011))
### [0.4.11](https://github.com/jimeh/build-emacs-for-macos/compare/0.4.10...0.4.11) (2021-05-08)

View File

@@ -72,14 +72,14 @@ available here: https://github.com/emacs-mirror/emacs
Options:
-j, --parallel COUNT Compile using COUNT parallel processes (detected: 8)
--git-sha SHA Override detected git SHA of specified branch allowing builds of old commits
--[no-]xwidgets Enable/disable XWidgets (default: enabled if supported)
--[no-]xwidgets Enable/disable XWidgets if supported (default: enabled)
--[no-]native-comp Enable/disable native-comp (default: enabled if supported)
--[no-]native-full-aot Enable/disable NATIVE_FULL_AOT / Ahead of Time compilation (default: disabled)
--rsvg Enable SVG image support via librsvg, can yield a unstable build (default: disabled)
--[no-]rsvg Enable/disable SVG image support via librsvg (default: enabled)
--no-titlebar Apply no-titlebar patch (default: disabled)
--no-frame-refocus Apply no-frame-refocus patch (default: disabled)
--[no-]native-fast-boot DEPRECATED: use --[no-]native-full-aot instead
--[no-]launcher DEPRECATED: Launcher script is no longer used.
--work-dir DIR Specify a working directory where tarballs, sources, and builds will be stored and worked with
--plan FILE Follow given plan file, instead of using given git ref/sha
```
Resulting applications are saved to the `builds` directory in a bzip2 compressed

View File

@@ -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
@@ -585,7 +585,7 @@ class AbstractEmbedder
private
def invocation_dir
File.join(app, 'Contents/MacOS')
File.join(app, 'Contents', 'MacOS')
end
def bin
@@ -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
@@ -629,6 +628,16 @@ class LibEmbedder < AbstractEmbedder
Pathname.new(File.dirname(exe))
).to_s
rpath = File.join('@executable_path', rel_path)
rpaths = `otool -l "#{exe}" | grep -A 2 'cmd LC_RPATH' | grep 'path'`
unless rpaths.include?(rpath)
while_writable(exe) do
system('install_name_tool', '-add_rpath',
File.join('@executable_path', rel_path), exe)
end
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)
@@ -673,31 +682,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)
@@ -729,7 +713,9 @@ class GccLibEmbedder < AbstractEmbedder
FileUtils.mkdir_p(File.dirname(target_dir))
FileUtils.cp_r(source_dir, target_dir)
FileUtils.rm(Dir[File.join(target_dir, '**/.DS_Store')], force: true)
FileUtils.rm(Dir[File.join(target_dir, '**', '.DS_Store')], force: true)
FileUtils.chmod_R('u+w', target_dir)
FileUtils.mv(source_darwin_dir, target_darwin_dir)
end
private
@@ -742,9 +728,21 @@ class GccLibEmbedder < AbstractEmbedder
File.join(invocation_dir, gcc_info.relative_lib_dir)
end
def source_darwin_dir
File.join(invocation_dir, gcc_info.relative_darwin_lib_dir)
end
def target_darwin_dir
File.join(invocation_dir, gcc_info.sanitized_relative_darwin_lib_dir)
end
def source_dir
gcc_info.lib_dir
end
def relative_dir(path, root)
Pathname.new(path).relative_path_from(Pathname.new(root)).to_s
end
end
class GccInfo
@@ -784,6 +782,17 @@ class GccInfo
@relative_darwin_lib_dir ||= relative_dir(darwin_lib_dir, root_dir)
end
# Sanitize folder name with full "MAJOR.MINOR.PATCH" version number to just
# the MAJOR version. Apple's codesign CLI tool throws a "bundle format
# unrecognized" error if there are any folders with two dots in their name
# within the Emacs.app application bundle.
def sanitized_relative_darwin_lib_dir
@sanitized_relative_darwin_lib_dir ||= File.join(
File.dirname(relative_darwin_lib_dir),
File.basename(relative_darwin_lib_dir).split('.').first
)
end
def libgccjit_root_dir
@libgccjit_root_dir ||= `brew --prefix libgccjit`.chomp
end
@@ -828,10 +837,7 @@ class GccInfo
private
def relative_dir(path, root)
root += '/' unless root[-1] == '/'
return if path[0..root.size - 1] != root
path[root.size..-1]
Pathname.new(path).relative_path_from(Pathname.new(root)).to_s
end
end
@@ -840,7 +846,7 @@ if __FILE__ == $PROGRAM_NAME
work_dir: File.expand_path(__dir__),
native_full_aot: false,
parallel: Etc.nprocessors,
rsvg: false,
rsvg: true,
xwidgets: true
}
@@ -861,14 +867,15 @@ if __FILE__ == $PROGRAM_NAME
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
@@ -884,9 +891,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
@@ -910,23 +918,6 @@ if __FILE__ == $PROGRAM_NAME
) do |v|
cli_options[:plan] = v
end
opts.on('--[no-]native-fast-boot',
'DEPRECATED: use --[no-]native-full-aot instead') do |v|
if v
raise Error, '--native-fast-boot option is deprecated, ' \
'use --no-native-full-aot instead'
else
raise Error, '--no-native-fast-boot option is deprecated, ' \
'use --native-full-aot instead'
end
end
opts.on('--[no-]launcher',
'DEPRECATED: Launcher script is no longer used.') do |_|
raise Error, '--[no-]launcher option is deprecated, launcher ' \
'script is no longer used.'
end
end.parse!
work_dir = cli_options.delete(:work_dir)

View File

@@ -1,10 +1,10 @@
diff --git a/lisp/emacs-lisp/comp.el b/lisp/emacs-lisp/comp.el
index 4036080976..2ff8dbd74c 100644
index 8c638312b0..87af889ef4 100644
--- a/lisp/emacs-lisp/comp.el
+++ b/lisp/emacs-lisp/comp.el
@@ -4079,6 +4079,52 @@ of (commands) to run simultaneously."
@@ -4215,6 +4215,52 @@ native-compile-async
(let ((load (not (not load))))
(native--compile-async paths recursively load selector)))
(native--compile-async files recursively load selector)))
+;;;###autoload
+(defun native-compile-setup-environment-variables (&rest _args)
@@ -19,7 +19,7 @@ index 4036080976..2ff8dbd74c 100644
+ "<%= relative_lib_dir %>"
+ invocation-directory))
+ (darwin-dir (expand-file-name
+ "<%= relative_darwin_lib_dir %>"
+ "<%= sanitized_relative_darwin_lib_dir %>"
+ invocation-directory))
+ (lib-paths (list)))
+
@@ -54,4 +54,4 @@ index 4036080976..2ff8dbd74c 100644
+
(provide 'comp)
;;; comp.el ends here
;; LocalWords: limplified limplified limplification limplify Limple LIMPLE libgccjit elc eln