Skip to content

Instantly share code, notes, and snippets.

@abstraction
Forked from abidanBrito/build-emacs.sh
Created June 5, 2024 20:41
Show Gist options
  • Save abstraction/dc4988a75a4193336c1baba35407c8d1 to your computer and use it in GitHub Desktop.
Save abstraction/dc4988a75a4193336c1baba35407c8d1 to your computer and use it in GitHub Desktop.

Revisions

  1. @abidanBrito abidanBrito revised this gist May 10, 2024. 1 changed file with 11 additions and 11 deletions.
    22 changes: 11 additions & 11 deletions build-emacs.sh
    Original file line number Diff line number Diff line change
    @@ -5,7 +5,7 @@
    ## tree-sitter, libjansson (C JSON library), pure GTK and mailutils.

    # Exit on error and print out commands before executing them.
    set -euxo pipefail
    set -euxo pipefail

    # Let's set the number of jobs to something reasonable; keep 2 cores
    # free to avoid choking the computer during compilation.
    @@ -28,14 +28,14 @@ sudo apt install -y build-essential \
    libgtk-3-dev \
    libtree-sitter-dev \
    libmagick++-dev \
    #libwebkit2gtk-4.0-dev \
    #libwebkit2gtk-4.1-dev \

    # Get dependencies for gcc-10 and the build process.
    sudo apt update -y
    sudo apt install -y gcc-10 \
    g++-10 \
    sudo apt install -y gcc-11 \
    g++-11 \
    libgccjit0 \
    libgccjit-10-dev \
    libgccjit-11-dev \
    autoconf \

    # Get dependencies for fast JSON.
    @@ -44,7 +44,7 @@ sudo apt install -y libjansson4 libjansson-dev
    # Get GNU Mailutils (protocol-independent mail framework).
    sudo apt install -y mailutils

    # Enable source packages and get dependencies for whatever
    # Enable source packages and get dependencies for whatever
    # Emacs version Ubuntu supports by default.
    #
    # Taken from here:
    @@ -57,7 +57,7 @@ sudo apt install -y mailutils
    DEBIAN_FRONTEND=noninteractive

    # Needed for compiling libgccjit or we'll get cryptic error messages.
    export CC=/usr/bin/gcc-10 CXX=/usr/bin/g++-10
    export CC=/usr/bin/gcc-11 CXX=/usr/bin/g++-11

    # Configure and run.
    # NOTE(abi): binaries should go to /usr/local/bin by default.
    @@ -82,6 +82,8 @@ export CC=/usr/bin/gcc-10 CXX=/usr/bin/g++-10
    --with-tree-sitter \
    --with-wide-int \
    --with-json \
    --with-modules \
    --without-dbus \
    --with-gnutls \
    --with-mailutils \
    --without-pop \
    @@ -93,9 +95,7 @@ export CC=/usr/bin/gcc-10 CXX=/usr/bin/g++-10
    #--prefix="" # output binaries location
    #--with-x-toolkit=lucid # supposedly more stable
    #--with-xwidgets
    #--with-modules
    #--without-dbus


    # Compiler flags:
    # -O2 -> Turn on a bunch of optimization flags. There's also -O3, but it increases
    # the instruction cache footprint, which may end up reducing performance.
    @@ -111,7 +111,7 @@ export CC=/usr/bin/gcc-10 CXX=/usr/bin/g++-10
    # NOTE(abi): NATIVE_FULL_AOT=1 ensures native compilation ahead-of-time for all
    # elisp files included in the distribution.
    make -j${JOBS} NATIVE_FULL_AOT=1 \
    && sudo make install
    && make install

    # Return to the original path.
    popd
  2. Abidán Brito revised this gist Jan 7, 2024. No changes.
  3. Abidán Brito revised this gist Jan 6, 2024. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion build-emacs.sh
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    #!/usr/bin/env bash

    ## Author: Abidán Brito
    ## This script builds GNU Emacs 29 with support for native elisp compilation,
    ## This script builds GNU Emacs 29.1 with support for native elisp compilation,
    ## tree-sitter, libjansson (C JSON library), pure GTK and mailutils.

    # Exit on error and print out commands before executing them.
  4. Abidán Brito revised this gist Jan 6, 2024. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion build-emacs.sh
    Original file line number Diff line number Diff line change
    @@ -2,7 +2,7 @@

    ## Author: Abidán Brito
    ## This script builds GNU Emacs 29 with support for native elisp compilation,
    ## libjansson (C JSON library), pure GTK and mailutils.
    ## tree-sitter, libjansson (C JSON library), pure GTK and mailutils.

    # Exit on error and print out commands before executing them.
    set -euxo pipefail
  5. Abidán Brito revised this gist Jan 6, 2024. 1 changed file with 6 additions and 6 deletions.
    12 changes: 6 additions & 6 deletions build-emacs.sh
    Original file line number Diff line number Diff line change
    @@ -97,12 +97,12 @@ export CC=/usr/bin/gcc-10 CXX=/usr/bin/g++-10
    #--without-dbus

    # Compiler flags:
    # -O2 -> Turn on a bunch of optimization flags. There's also -O3, but it increases
    # the instruction cache footprint, which may end up reducing performance.
    # -pipe -> Reduce temporary files to the minimum.
    # -mtune=native -> Optimize code for the local machine (under ISA constraints).
    # -march=native-> Enable all instruction subsets supported by the local machine.
    # -fomit-frame-pointer -> Small functions don't need a frame pointer (optimization).
    # -O2 -> Turn on a bunch of optimization flags. There's also -O3, but it increases
    # the instruction cache footprint, which may end up reducing performance.
    # -pipe -> Reduce temporary files to the minimum.
    # -mtune=native -> Optimize code for the local machine (under ISA constraints).
    # -march=native -> Enable all instruction subsets supported by the local machine.
    # -fomit-frame-pointer -> Small functions don't need a frame pointer (optimization).
    #
    # https://lemire.me/blog/2018/07/25/it-is-more-complicated-than-i-thought-mtune-march-in-gcc/
    CFLAGS="-O2 -pipe -mtune=native -march=native -fomit-frame-pointer"
  6. Abidán Brito revised this gist Jan 6, 2024. 1 changed file with 36 additions and 25 deletions.
    61 changes: 36 additions & 25 deletions build-emacs.sh
    Original file line number Diff line number Diff line change
    @@ -60,33 +60,34 @@ DEBIAN_FRONTEND=noninteractive
    export CC=/usr/bin/gcc-10 CXX=/usr/bin/g++-10

    # Configure and run.
    #
    # Compiler flags:
    # -O2 -> Turn on a bunch of optimization flags. There's also -O3, but it increases
    # the instruction cache footprint, which may end up reducing performance.
    # -pipe -> Reduce temporary files to the minimum.
    # -mtune=native -> Optimize code for the local machine (under ISA constraints).
    # -march=native -> Enable all instruction subsets supported by the local machine.
    # -fomit-frame-pointer -> Small functions don't need a frame pointer (optimization).
    # https://lemire.me/blog/2018/07/25/it-is-more-complicated-than-i-thought-mtune-march-in-gcc/
    #
    # NOTE(abi): binaries should go to /usr/local/bin by default.
    #
    # Options:
    # --with-native-compilation -> use the libgccjit native compiler
    # --with-pgtk -> better font rendering
    # --with-x-toolkit=gtk3 -> widgets toolkit
    # --with-tree-sitter -> syntax parsing
    # --with-wide-int -> larger file size limit
    # --with-json -> fast JSON
    # --with-gnutls -> TLS/SSL
    # --with-mailutils -> e-mail
    # --without-pop -> no pop3 (insecure channels)
    # --with-cairo -> vector graphics backend
    # --with-imagemagick -> raster images backend
    ./autogen.sh \
    && ./configure \
    --with-native-compilation # use the libgccjit native compiler \
    --with-pgtk # better font rendering \
    --with-x-toolkit=gtk3 # widgets toolkit \
    --with-tree-sitter # syntax parsing \
    --with-wide-int # larger file size limit \
    --with-json # fast JSON \
    --with-gnutls # TLS/SSL \
    --with-mailutils # e-mail \
    --without-pop # no pop3 (insecure channels) \
    --with-cairo # vector graphics backend \
    --with-imagemagick # raster images backend \

    CFLAGS="-O2 -pipe -mtune=native -march=native -fomit-frame-pointer"

    --with-native-compilation \
    --with-pgtk \
    --with-x-toolkit=gtk3 \
    --with-tree-sitter \
    --with-wide-int \
    --with-json \
    --with-gnutls \
    --with-mailutils \
    --without-pop \
    --with-cairo \
    --with-imagemagick \

    # Other interesting compilation options:
    #
    #--prefix="" # output binaries location
    @@ -95,8 +96,18 @@ export CC=/usr/bin/gcc-10 CXX=/usr/bin/g++-10
    #--with-modules
    #--without-dbus

    # Compiler flags:
    # -O2 -> Turn on a bunch of optimization flags. There's also -O3, but it increases
    # the instruction cache footprint, which may end up reducing performance.
    # -pipe -> Reduce temporary files to the minimum.
    # -mtune=native -> Optimize code for the local machine (under ISA constraints).
    # -march=native-> Enable all instruction subsets supported by the local machine.
    # -fomit-frame-pointer -> Small functions don't need a frame pointer (optimization).
    #
    # https://lemire.me/blog/2018/07/25/it-is-more-complicated-than-i-thought-mtune-march-in-gcc/
    CFLAGS="-O2 -pipe -mtune=native -march=native -fomit-frame-pointer"

    # Build.
    #
    # NOTE(abi): NATIVE_FULL_AOT=1 ensures native compilation ahead-of-time for all
    # elisp files included in the distribution.
    make -j${JOBS} NATIVE_FULL_AOT=1 \
  7. Abidán Brito revised this gist Jan 6, 2024. 1 changed file with 11 additions and 11 deletions.
    22 changes: 11 additions & 11 deletions build-emacs.sh
    Original file line number Diff line number Diff line change
    @@ -73,17 +73,17 @@ export CC=/usr/bin/gcc-10 CXX=/usr/bin/g++-10
    # NOTE(abi): binaries should go to /usr/local/bin by default.
    ./autogen.sh \
    && ./configure \
    --with-native-compilation \ # use the libgccjit native compiler
    --with-pgtk \ # better font rendering
    --with-x-toolkit=gtk3 \ # widgets toolkit
    --with-tree-sitter \ # syntax parsing
    --with-wide-int \ # larger file size limit
    --with-json \ # fast JSON
    --with-gnutls \ # TLS/SSL
    --with-mailutils \ # e-mail
    --without-pop \ # no pop3 (insecure channels)
    --with-cairo \ # vector graphics backend
    --with-imagemagick \ # raster images backend
    --with-native-compilation # use the libgccjit native compiler \
    --with-pgtk # better font rendering \
    --with-x-toolkit=gtk3 # widgets toolkit \
    --with-tree-sitter # syntax parsing \
    --with-wide-int # larger file size limit \
    --with-json # fast JSON \
    --with-gnutls # TLS/SSL \
    --with-mailutils # e-mail \
    --without-pop # no pop3 (insecure channels) \
    --with-cairo # vector graphics backend \
    --with-imagemagick # raster images backend \

    CFLAGS="-O2 -pipe -mtune=native -march=native -fomit-frame-pointer"

  8. Abidán Brito revised this gist Jan 6, 2024. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions build-emacs.sh
    Original file line number Diff line number Diff line change
    @@ -89,8 +89,8 @@ export CC=/usr/bin/gcc-10 CXX=/usr/bin/g++-10

    # Other interesting compilation options:
    #
    #--prefix="" # output binaries location
    #--with-x-toolkit=lucid # supposedly more stable
    #--prefix="" # output binaries location
    #--with-x-toolkit=lucid # supposedly more stable
    #--with-xwidgets
    #--with-modules
    #--without-dbus
  9. Abidán Brito revised this gist Jan 6, 2024. 1 changed file with 0 additions and 1 deletion.
    1 change: 0 additions & 1 deletion build-emacs.sh
    Original file line number Diff line number Diff line change
    @@ -25,7 +25,6 @@ sudo apt install -y build-essential \
    libgif-dev \
    libxpm-dev \
    libncurses-dev \
    #libncurses5-dev \
    libgtk-3-dev \
    libtree-sitter-dev \
    libmagick++-dev \
  10. Abidán Brito revised this gist Jan 6, 2024. 1 changed file with 10 additions and 10 deletions.
    20 changes: 10 additions & 10 deletions build-emacs.sh
    Original file line number Diff line number Diff line change
    @@ -74,23 +74,23 @@ export CC=/usr/bin/gcc-10 CXX=/usr/bin/g++-10
    # NOTE(abi): binaries should go to /usr/local/bin by default.
    ./autogen.sh \
    && ./configure \
    --prefix="$HOME/.local/opt/emacs/" \
    --with-native-compilation \ # use the libgccjit native compiler
    --with-json \
    --with-gnutls \
    --with-mailutils \
    --with-tree-sitter \
    --with-wide-int \ # larger file size limit
    --without-pop \ # no pop3 email via insecure channels
    --with-cairo \
    --with-pgtk \ # better font rendering
    --with-x-toolkit=gtk3 \
    --with-imagemagick \
    --with-x-toolkit=gtk3 \ # widgets toolkit
    --with-tree-sitter \ # syntax parsing
    --with-wide-int \ # larger file size limit
    --with-json \ # fast JSON
    --with-gnutls \ # TLS/SSL
    --with-mailutils \ # e-mail
    --without-pop \ # no pop3 (insecure channels)
    --with-cairo \ # vector graphics backend
    --with-imagemagick \ # raster images backend

    CFLAGS="-O2 -pipe -mtune=native -march=native -fomit-frame-pointer"

    # Other interesting compilation options:
    #
    #--prefix="" # output binaries location
    #--with-x-toolkit=lucid # supposedly more stable
    #--with-xwidgets
    #--with-modules
  11. Abidán Brito revised this gist Jan 6, 2024. 1 changed file with 3 additions and 6 deletions.
    9 changes: 3 additions & 6 deletions build-emacs.sh
    Original file line number Diff line number Diff line change
    @@ -68,7 +68,8 @@ export CC=/usr/bin/gcc-10 CXX=/usr/bin/g++-10
    # -pipe -> Reduce temporary files to the minimum.
    # -mtune=native -> Optimize code for the local machine (under ISA constraints).
    # -march=native -> Enable all instruction subsets supported by the local machine.
    # -fomit-frame-pointer -> I'm not sure what this does yet...
    # -fomit-frame-pointer -> Small functions don't need a frame pointer (optimization).
    # https://lemire.me/blog/2018/07/25/it-is-more-complicated-than-i-thought-mtune-march-in-gcc/
    #
    # NOTE(abi): binaries should go to /usr/local/bin by default.
    ./autogen.sh \
    @@ -86,11 +87,7 @@ export CC=/usr/bin/gcc-10 CXX=/usr/bin/g++-10
    --with-x-toolkit=gtk3 \
    --with-imagemagick \

    # -pipe -> reduces the number of temporary files
    # -mtune -> redundant if -march is set to the same
    # -fomit-frame-pointer -> optimization, small functions don't need a frame pointer
    # https://lemire.me/blog/2018/07/25/it-is-more-complicated-than-i-thought-mtune-march-in-gcc/
    CFLAGS="-O2 -pipe -march=native -fomit-frame-pointer"
    CFLAGS="-O2 -pipe -mtune=native -march=native -fomit-frame-pointer"

    # Other interesting compilation options:
    #
  12. Abidán Brito revised this gist Jan 5, 2024. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion build-emacs.sh
    Original file line number Diff line number Diff line change
    @@ -12,7 +12,7 @@ set -euxo pipefail
    JOBS=`nproc --ignore=2`

    # Clone repo locally and get into it.
    git clone --branch emacs-29 git://git.savannah.gnu.org/emacs.git
    git clone --depth 1 --branch emacs-29 git://git.savannah.gnu.org/emacs.git
    pushd emacs

    # Get essential dependencies.
    @@ -25,6 +25,7 @@ sudo apt install -y build-essential \
    libgif-dev \
    libxpm-dev \
    libncurses-dev \
    #libncurses5-dev \
    libgtk-3-dev \
    libtree-sitter-dev \
    libmagick++-dev \
  13. Abidán Brito revised this gist Jan 5, 2024. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions build-emacs.sh
    Original file line number Diff line number Diff line change
    @@ -26,6 +26,7 @@ sudo apt install -y build-essential \
    libxpm-dev \
    libncurses-dev \
    libgtk-3-dev \
    libtree-sitter-dev \
    libmagick++-dev \
    #libwebkit2gtk-4.0-dev \

  14. Abidán Brito revised this gist Jan 5, 2024. 1 changed file with 2 additions and 4 deletions.
    6 changes: 2 additions & 4 deletions build-emacs.sh
    Original file line number Diff line number Diff line change
    @@ -16,8 +16,7 @@ git clone --branch emacs-29 git://git.savannah.gnu.org/emacs.git
    pushd emacs

    # Get essential dependencies.
    sudo apt install -y
    build-essential \
    sudo apt install -y build-essential \
    texinfo \
    libgnutls28-dev \
    libjpeg-dev \
    @@ -32,8 +31,7 @@ sudo apt install -y

    # Get dependencies for gcc-10 and the build process.
    sudo apt update -y
    sudo apt install -y
    gcc-10 \
    sudo apt install -y gcc-10 \
    g++-10 \
    libgccjit0 \
    libgccjit-10-dev \
  15. Abidán Brito revised this gist Jan 5, 2024. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion build-emacs.sh
    Original file line number Diff line number Diff line change
    @@ -37,7 +37,7 @@ sudo apt install -y
    g++-10 \
    libgccjit0 \
    libgccjit-10-dev \
    autoconf
    autoconf \

    # Get dependencies for fast JSON.
    sudo apt install -y libjansson4 libjansson-dev
  16. Abidán Brito revised this gist Jan 5, 2024. 1 changed file with 4 additions and 2 deletions.
    6 changes: 4 additions & 2 deletions build-emacs.sh
    Original file line number Diff line number Diff line change
    @@ -16,7 +16,8 @@ git clone --branch emacs-29 git://git.savannah.gnu.org/emacs.git
    pushd emacs

    # Get essential dependencies.
    sudo apt install -y build-essential \
    sudo apt install -y
    build-essential \
    texinfo \
    libgnutls28-dev \
    libjpeg-dev \
    @@ -31,7 +32,8 @@ sudo apt install -y build-essential \

    # Get dependencies for gcc-10 and the build process.
    sudo apt update -y
    sudo apt install -y gcc-10 \
    sudo apt install -y
    gcc-10 \
    g++-10 \
    libgccjit0 \
    libgccjit-10-dev \
  17. Abidán Brito revised this gist Jan 5, 2024. 1 changed file with 20 additions and 9 deletions.
    29 changes: 20 additions & 9 deletions build-emacs.sh
    Original file line number Diff line number Diff line change
    @@ -25,9 +25,9 @@ sudo apt install -y build-essential \
    libgif-dev \
    libxpm-dev \
    libncurses-dev \
    libgtk-3-dev
    #libwebkit2gtk-4.0-dev
    #libmagick++-dev
    libgtk-3-dev \
    libmagick++-dev \
    #libwebkit2gtk-4.0-dev \

    # Get dependencies for gcc-10 and the build process.
    sudo apt update -y
    @@ -70,21 +70,32 @@ export CC=/usr/bin/gcc-10 CXX=/usr/bin/g++-10
    #
    # NOTE(abi): binaries should go to /usr/local/bin by default.
    ./autogen.sh \
    && ./configure --with-native-compilation \
    && ./configure \
    --prefix="$HOME/.local/opt/emacs/" \
    --with-native-compilation \ # use the libgccjit native compiler
    --with-json \
    --with-gnutls \
    --with-mailutils \
    --with-tree-sitter \
    --with-wide-int \ # larger file size limit
    --without-pop \ # no pop3 email via insecure channels
    --with-cairo \
    --with-pgtk \
    --with-x-toolkit=lucid
    --with-pgtk \ # better font rendering
    --with-x-toolkit=gtk3 \
    --with-imagemagick \

    CFLAGS="-O2 -pipe -mtune=native -march=native -fomit-frame-pointer"
    # -pipe -> reduces the number of temporary files
    # -mtune -> redundant if -march is set to the same
    # -fomit-frame-pointer -> optimization, small functions don't need a frame pointer
    # https://lemire.me/blog/2018/07/25/it-is-more-complicated-than-i-thought-mtune-march-in-gcc/
    CFLAGS="-O2 -pipe -march=native -fomit-frame-pointer"

    # Other interesting compilation options:
    #
    #--with-x-toolkit=gtk3 # less stable than lucid
    #--with-x-toolkit=lucid # supposedly more stable
    #--with-xwidgets
    #--with-imagemagick
    #--with-modules
    #--without-dbus

    # Build.
    #
  18. Abidán Brito revised this gist Jan 5, 2024. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion build-emacs.sh
    Original file line number Diff line number Diff line change
    @@ -34,7 +34,8 @@ sudo apt update -y
    sudo apt install -y gcc-10 \
    g++-10 \
    libgccjit0 \
    libgccjit-10-dev
    libgccjit-10-dev \
    autoconf

    # Get dependencies for fast JSON.
    sudo apt install -y libjansson4 libjansson-dev
  19. Abidán Brito revised this gist Jan 5, 2024. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion build-emacs.sh
    Original file line number Diff line number Diff line change
    @@ -26,7 +26,7 @@ sudo apt install -y build-essential \
    libxpm-dev \
    libncurses-dev \
    libgtk-3-dev
    libwebkit2gtk-4.0-dev
    #libwebkit2gtk-4.0-dev
    #libmagick++-dev

    # Get dependencies for gcc-10 and the build process.
  20. Abidán Brito revised this gist Jan 5, 2024. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion build-emacs.sh
    Original file line number Diff line number Diff line change
    @@ -26,7 +26,7 @@ sudo apt install -y build-essential \
    libxpm-dev \
    libncurses-dev \
    libgtk-3-dev
    #libwebkit2gtk-4.0-dev
    libwebkit2gtk-4.0-dev
    #libmagick++-dev

    # Get dependencies for gcc-10 and the build process.
  21. Abidán Brito revised this gist Jan 5, 2024. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion build-emacs.sh
    Original file line number Diff line number Diff line change
    @@ -25,7 +25,7 @@ sudo apt install -y build-essential \
    libgif-dev \
    libxpm-dev \
    libncurses-dev \
    #libgtk-3-dev
    libgtk-3-dev
    #libwebkit2gtk-4.0-dev
    #libmagick++-dev

  22. Abidán Brito revised this gist Jan 5, 2024. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion build-emacs.sh
    Original file line number Diff line number Diff line change
    @@ -25,7 +25,7 @@ sudo apt install -y build-essential \
    libgif-dev \
    libxpm-dev \
    libncurses-dev \
    libgtk-3-dev
    #libgtk-3-dev
    #libwebkit2gtk-4.0-dev
    #libmagick++-dev

  23. Abidán Brito revised this gist Jan 5, 2024. 1 changed file with 3 additions and 5 deletions.
    8 changes: 3 additions & 5 deletions build-emacs.sh
    Original file line number Diff line number Diff line change
    @@ -74,18 +74,16 @@ export CC=/usr/bin/gcc-10 CXX=/usr/bin/g++-10
    --with-gnutls \
    --with-mailutils \
    --with-cairo \
    --with-pgtk
    --with-pgtk \
    --with-x-toolkit=lucid

    CFLAGS="-O2 -pipe -mtune=native -march=native -fomit-frame-pointer"

    # Other interesting compilation options:
    #
    #--with-pgtk (Emacs 29)
    #--with-x-toolkit=gtk3
    #--with-x-toolkit=gtk3 # less stable than lucid
    #--with-xwidgets
    #--with-imagemagick
    # https://ubuntuhandbook.org/index.php/2021/12/compile-gnu-emacs-source-ubuntu/
    #--with-x-toolkit=lucid

    # Build.
    #
  24. Abidán Brito revised this gist Jan 5, 2024. 1 changed file with 4 additions and 1 deletion.
    5 changes: 4 additions & 1 deletion build-emacs.sh
    Original file line number Diff line number Diff line change
    @@ -75,6 +75,7 @@ export CC=/usr/bin/gcc-10 CXX=/usr/bin/g++-10
    --with-mailutils \
    --with-cairo \
    --with-pgtk

    CFLAGS="-O2 -pipe -mtune=native -march=native -fomit-frame-pointer"

    # Other interesting compilation options:
    @@ -83,7 +84,9 @@ export CC=/usr/bin/gcc-10 CXX=/usr/bin/g++-10
    #--with-x-toolkit=gtk3
    #--with-xwidgets
    #--with-imagemagick

    # https://ubuntuhandbook.org/index.php/2021/12/compile-gnu-emacs-source-ubuntu/
    #--with-x-toolkit=lucid

    # Build.
    #
    # NOTE(abi): NATIVE_FULL_AOT=1 ensures native compilation ahead-of-time for all
  25. Abidán Brito revised this gist Sep 25, 2023. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion build-emacs.sh
    Original file line number Diff line number Diff line change
    @@ -2,7 +2,7 @@

    ## Author: Abidán Brito
    ## This script builds GNU Emacs 29 with support for native elisp compilation,
    ## libjansson (C JSON library) and mailutils.
    ## libjansson (C JSON library), pure GTK and mailutils.

    # Exit on error and print out commands before executing them.
    set -euxo pipefail
  26. Abidán Brito revised this gist Sep 25, 2023. No changes.
  27. Abidán Brito renamed this gist Sep 25, 2023. 1 changed file with 4 additions and 3 deletions.
    7 changes: 4 additions & 3 deletions build-emacs28.sh → build-emacs.sh
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    #!/usr/bin/env bash

    ## Author: Abidán Brito
    ## This script builds GNU Emacs 28 with support for native elisp compilation,
    ## This script builds GNU Emacs 29 with support for native elisp compilation,
    ## libjansson (C JSON library) and mailutils.

    # Exit on error and print out commands before executing them.
    @@ -12,7 +12,7 @@ set -euxo pipefail
    JOBS=`nproc --ignore=2`

    # Clone repo locally and get into it.
    git clone --branch emacs-28 git://git.savannah.gnu.org/emacs.git
    git clone --branch emacs-29 git://git.savannah.gnu.org/emacs.git
    pushd emacs

    # Get essential dependencies.
    @@ -73,7 +73,8 @@ export CC=/usr/bin/gcc-10 CXX=/usr/bin/g++-10
    --with-json \
    --with-gnutls \
    --with-mailutils \
    --with-cairo
    --with-cairo \
    --with-pgtk
    CFLAGS="-O2 -pipe -mtune=native -march=native -fomit-frame-pointer"

    # Other interesting compilation options:
  28. @abidanBrito abidanBrito revised this gist Feb 5, 2022. 1 changed file with 23 additions and 19 deletions.
    42 changes: 23 additions & 19 deletions build-emacs28.sh
    Original file line number Diff line number Diff line change
    @@ -2,7 +2,7 @@

    ## Author: Abidán Brito
    ## This script builds GNU Emacs 28 with support for native elisp compilation,
    ## libjansson (C JSON library), mailutils, and Webkit widgets (xwidgets).
    ## libjansson (C JSON library) and mailutils.

    # Exit on error and print out commands before executing them.
    set -euxo pipefail
    @@ -25,21 +25,23 @@ sudo apt install -y build-essential \
    libgif-dev \
    libxpm-dev \
    libncurses-dev \
    libmagick++-dev
    libgtk-3-dev
    #libwebkit2gtk-4.0-dev
    #libmagick++-dev

    # Get dependencies for gcc-10 and the build process.
    sudo apt update -y \
    && apt install -y gcc-10 g++-10 libgccjit0 libgccjit-10-dev
    sudo apt update -y
    sudo apt install -y gcc-10 \
    g++-10 \
    libgccjit0 \
    libgccjit-10-dev

    # Get dependencies for fast JSON.
    sudo apt install -y libjansson4 libjansson-dev

    # Get GNU Mailutils (protocol-independent mail framework).
    sudo apt install -y mailutils

    # Get Xwidgets dependencies.
    sudo apt install -y libgtk-3-dev

    # Enable source packages and get dependencies for whatever
    # Emacs version Ubuntu supports by default.
    #
    @@ -65,26 +67,28 @@ export CC=/usr/bin/gcc-10 CXX=/usr/bin/g++-10
    # -march=native -> Enable all instruction subsets supported by the local machine.
    # -fomit-frame-pointer -> I'm not sure what this does yet...
    #
    # NOTE(abi): binaries should go to /opt/emacs. If you remove the --prefix argument
    # they should go to /usr/local/bin by default.
    # NOTE(abi): binaries should go to /usr/local/bin by default.
    ./autogen.sh \
    && ./configure --with-native-compilation \
    --with-json \
    --with-gnutls \
    --with-mailutils \
    --with-cairo \
    --with-imagemagick \
    --with-x-toolkit=gtk3 \
    --with-xwidgets \
    --prefix=/opt/emacs \
    --with-cairo
    CFLAGS="-O2 -pipe -mtune=native -march=native -fomit-frame-pointer"

    # Other interesting compilation options:
    #
    #--with-pgtk (Emacs 29)
    #--with-x-toolkit=gtk3
    #--with-xwidgets
    #--with-imagemagick

    # Build.
    #
    # NOTE(abi): NATIVE_FULL_AOT=1 ensures native compilation ahead-of-time for
    # all elisp files included in the distribution.
    make -j${JOBS} NATIVE_FULL_AOT=1
    sudo make install
    # NOTE(abi): NATIVE_FULL_AOT=1 ensures native compilation ahead-of-time for all
    # elisp files included in the distribution.
    make -j${JOBS} NATIVE_FULL_AOT=1 \
    && sudo make install

    # Return to the original path.
    popd
    popd
  29. @abidanBrito abidanBrito created this gist Feb 5, 2022.
    90 changes: 90 additions & 0 deletions build-emacs28.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,90 @@
    #!/usr/bin/env bash

    ## Author: Abidán Brito
    ## This script builds GNU Emacs 28 with support for native elisp compilation,
    ## libjansson (C JSON library), mailutils, and Webkit widgets (xwidgets).

    # Exit on error and print out commands before executing them.
    set -euxo pipefail

    # Let's set the number of jobs to something reasonable; keep 2 cores
    # free to avoid choking the computer during compilation.
    JOBS=`nproc --ignore=2`

    # Clone repo locally and get into it.
    git clone --branch emacs-28 git://git.savannah.gnu.org/emacs.git
    pushd emacs

    # Get essential dependencies.
    sudo apt install -y build-essential \
    texinfo \
    libgnutls28-dev \
    libjpeg-dev \
    libpng-dev \
    libtiff5-dev \
    libgif-dev \
    libxpm-dev \
    libncurses-dev \
    libmagick++-dev

    # Get dependencies for gcc-10 and the build process.
    sudo apt update -y \
    && apt install -y gcc-10 g++-10 libgccjit0 libgccjit-10-dev

    # Get dependencies for fast JSON.
    sudo apt install -y libjansson4 libjansson-dev

    # Get GNU Mailutils (protocol-independent mail framework).
    sudo apt install -y mailutils

    # Get Xwidgets dependencies.
    sudo apt install -y libgtk-3-dev

    # Enable source packages and get dependencies for whatever
    # Emacs version Ubuntu supports by default.
    #
    # Taken from here:
    # https://www.masteringemacs.org/article/speed-up-emacs-libjansson-native-elisp-compilation
    #sudo sed -i 's/# deb-src/deb-src/' /etc/apt/sources.list \
    # && apt update \
    # && apt build-dep -y emacs

    # Stop debconf from complaining about postfix nonsense.
    DEBIAN_FRONTEND=noninteractive

    # Needed for compiling libgccjit or we'll get cryptic error messages.
    export CC=/usr/bin/gcc-10 CXX=/usr/bin/g++-10

    # Configure and run.
    #
    # Compiler flags:
    # -O2 -> Turn on a bunch of optimization flags. There's also -O3, but it increases
    # the instruction cache footprint, which may end up reducing performance.
    # -pipe -> Reduce temporary files to the minimum.
    # -mtune=native -> Optimize code for the local machine (under ISA constraints).
    # -march=native -> Enable all instruction subsets supported by the local machine.
    # -fomit-frame-pointer -> I'm not sure what this does yet...
    #
    # NOTE(abi): binaries should go to /opt/emacs. If you remove the --prefix argument
    # they should go to /usr/local/bin by default.
    ./autogen.sh \
    && ./configure --with-native-compilation \
    --with-json \
    --with-gnutls \
    --with-mailutils \
    --with-cairo \
    --with-imagemagick \
    --with-x-toolkit=gtk3 \
    --with-xwidgets \
    --prefix=/opt/emacs \
    CFLAGS="-O2 -pipe -mtune=native -march=native -fomit-frame-pointer"

    # Build.
    #
    # NOTE(abi): NATIVE_FULL_AOT=1 ensures native compilation ahead-of-time for
    # all elisp files included in the distribution.
    make -j${JOBS} NATIVE_FULL_AOT=1
    sudo make install

    # Return to the original path.
    popd