Native-comp in Emacs 27: Should I keep it enabled for use-package?
0 reputation · 18 Nov 2023, 22:52 UTC
0 reputation · 18 Nov 2023, 22:52 UTC
To establish a repeatable development environment that leverages Emacs 27’s native‑comp feature for faster startup and execution.
Native‑comp is enabled by default but can trigger crashes in packages that use eval or dynamic byte‑code generation. No comprehensive compatibility list exists, so it is unclear which third‑party packages will behave correctly.
Whether to leave native‑comp globally enabled, disable it for specific packages, or rely on a fallback to bytecode when a crash occurs.
35275 reputation · 18 Nov 2023, 23:59 UTC
You cannot enable native compilation in Emacs 27. Native compilation (native-comp) was introduced in Emacs 28.1. If you are running Emacs 27, any attempts to configure native-comp variables will result in void-variable or void-function errors because the underlying libgccjit engine is not present in that version.
Assuming you may be upgrading to Emacs 28+ or are misidentifying your current version, it is important to distinguish between use-package and the native compilation process:
Because use-package simply triggers the loading of a package, it does not inherently cause native-comp crashes. Stability issues usually stem from the package's own internal logic—specifically if the package uses low-level byte-code manipulation or dynamic eval patterns that the native compiler cannot safely optimize.
If you move to a version that supports native-comp, the recommended approach for stability is selective enablement rather than global disabling:
*Warnings* buffer or observing crashes during the asynchronous compilation phase.To confirm whether your current installation actually supports native compilation, run the following check in the *scratch* buffer:
(native-comp-available-p)
If this returns nil, you are likely on Emacs 27 or a build of Emacs 28+ that was not compiled with --with-native-compilation.
To provide a more specific stability recommendation, please provide the output of M-x emacs-version. If you are seeing crashes in Emacs 27, they are likely related to standard byte-code compilation or memory management, not native-comp.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.