Giter Club home page Giter Club logo

elisp-native-comp's Introduction

Gentoo overlay for adding AOT native compilation support for emacs packages to portage.

Usage

Add this overlay to the systems repos and add eln to load-suffixes in your emacs early-init.el.

(add-to-list 'load-suffixes ".eln")

To prevent emacs from JIT compiling packages set native-comp-jit-compilation to nil.

(setq native-comp-jit-compilation nil)

Todo: Make packages add themselves to the JIT compilation deny list, which allows using portage AOT compilation and JIT compilation at the same time.

USE flags

Enable the native-compilation USE flag to enable native compilation on packages that inherit from elisp-common.eclass or elisp.eclass.

Importing and updating packages

Add gentoo.git as a remote, then compare or checkout ebuilds from gentoo’s master branch.

How does it work?

Eclasses

The elisp eclasses have been modified to compile and install binaries when the native-compilation USE flag is enabled.

elisp-compile

elisp-compile simply invokes the native compilation alternative to batch-compile, batch-native-compile.

The variable native-compile-target-directory is set to default-directory which causes emacs to output compiled binaries in the current working directory. This is how batch-compile works by default.

elisp-install

When provided, elisp-install will install binaries along with source and bytecode files.

Each package is installed into it’s own subdirectory inside of ${NATIVELISP} (technically a subdirectory of a version and ABI derived subdirectory in ${NATIVELISP}

Sitefiles

The packages sitefile is used to configure emacs to use the binaries. This is done by appending the path to the binaries to load-path and adding eln to load-suffixes.

The sitefile also contains a condition that checks if the currently running emacs instance is the same version and has the same ABI as the one that was used to build and install the binaries for this package. This is done using the value of comp-native-version-dir in emacs. Users can have this value interpolated into the sitefile using the @COMP_NATIVE_VERSION_DIR@ token.

;; use elisp binaries if possible
;;
;; @NATIVELISP@ expands to the path containing the packages
;; binaries.

(when (and (ignore-errors (native-comp-available-p))
           (string= comp-native-version-dir "@COMP_NATIVE_VERSION_DIR@"))
  (add-to-list 'load-path "@NATIVELISP@"))

Emacs patches

A few very small patches have been applied to comp.el to make batch-native-compile function more package manager friendly.

Before patching, batch-native-compile would not respect native-compile-target-directory, and only gave an option of using the last value of native-comp-eln-load-path which is intended to be used for binaries for packages built into emacs.

Also before patching, batch-native-compile would mangle filenames. The name mangling algorithm uses hashes of the source files absolute filename and it’s contents. Package managers such as portage typically compile files in a temporary directory and then move them into the root filesystem when installing, which breaks the name managling algorithm.

These patches can be found in ${elisp-native-comp}/app-editors/emacs/files.

elisp-native-comp's People

Contributors

jturnerusa avatar

Stargazers

Sam James avatar

Watchers

Sam James avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.