Re: Deferring native compilation finalization until idle

Perry Fraser <[email protected]> Sat, 25 Jul 2026 20:32:36 -0400
Newsgroups gmane.emacs.devel
Message-ID <[email protected]>
Right, so here are the circumstances in which I was able to obtain a hiccup-less load:

- Using the advice snippet listed in etc/PROBLEMS.
- Using jimeh's build and not using `startup-redirect-eln-cache' or similar.
  - It seems this is due to a lot of customization in how the bundle is assembled as well as some custom elisp in macos-startup.el which itself is called from loadup.el. Note that it stores its eln cache inside the .app.
- Manually codesigning and setting the eln cache to be a folder in the .app. (The default of `~/.emacs.d/eln-cache' does not work)

  This was fairly involved and doesn't really bear resemblance to the solution described in etc/PROBLEMS. Given that, and the fact that it is disabling a security feature (as trivial as it may seem), I think it might make more sense to either remove this solution from PROBLEMS (as the advice snippet works fine), or rework it to be more detailed. (I'm willing to write a patch, but I still think removal is the better option.) I've described what I did for posterity below.

After normal building and installing (in self-contained mode, the default), I renamed any directories under `Contents/Frameworks/native-lisp' so that they didn't contain any periods (because otherwise codesign complains, it's very odd). Then I ran:

,----
| codesign --force --sign - \
|          nextstep/Emacs.app/Contents/Frameworks/native-lisp/**.eln
| 
| codesign --force --deep --sign - --entitlements entitlents.plist \
|          nextstep/Emacs.app/
`----

And in `entitlements.plist' I had:
,----
| <?xml version="1.0" encoding="UTF-8"?>
| <!DOCTYPE plist PUBLIC
| "-//Apple//DTD PLIST 1.0//EN"
| "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
| <plist version="1.0">
|   <dict>
|     <key>com.apple.security.automation.apple-events</key>
|     <true/>
|     <key>com.apple.security.cs.allow-dyld-environment-variables</key>
|     <true/>
|     <key>com.apple.security.cs.allow-jit</key>
|     <true/>
|     <key>com.apple.security.cs.disable-library-validation</key>
|     <true/>
|     <key>com.apple.security.network.client</key>
|     <true/>
|   </dict>
| </plist>
`----

(Not all of these were probably necessary; I was just using the same entitlements that jimeh's build used.)

I then needed to set in my early-init.el:
,----
| (startup-redirect-eln-cache
|  (concat invocation-directory "../Resources/eln-cache"))
`----

Thanks,

― Perry