unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Yuri Khan <yuri.v.khan@gmail.com>
To: Joakim Verona <joakim@verona.se>
Cc: Emacs developers <emacs-devel@gnu.org>
Subject: Re: Alternatives for reliable build environments for emacs?
Date: Thu, 28 Oct 2021 23:07:25 +0700	[thread overview]
Message-ID: <CAP_d_8VjPczy_OMzYce9h9JGOuS6MG3Hcbk4KwG7c9QUS24b-A@mail.gmail.com> (raw)
In-Reply-To: <87bl39cnr4.fsf@tanaka.verona.se>

On Thu, 28 Oct 2021 at 19:57, <joakim@verona.se> wrote:

> I'm finding it increasingly difficult to build emacs in my distro,
> Fedora(Ok, I havent managed to build emacs using distro dependencies for
> a long time)
>
> What are the alternatives?
> I have tried guix and docker but not yet flatpak.
>
> These are nice because you can pin the dependency versions, to make sure
> you have a reproducible build environment.
>
> These all have the drawback that they are inconvenient when making local
> modifications to the emacs source, at least for me. Way back in the days
> when my original build environment worked, I automatically merged some
> branches and applied local patchs with stgit, and its these kind of
> things I've found awkward with the above mentioned containerized build
> systems.

I’m not an Emacs developer but the issue is familiar. I use Docker for
similar cases: (1) building software targeting an older version of the
distribution than is installed on my host system, or (2) building
software using newer versions of the toolchain than I’m comfortable
installing on my host machine.

The trick is that you keep the toolchain and build dependencies in the
container, but bind-mount the source and build trees so they are not
parts of the container image. This way, you work with the source tree
using your local tools; the container is completely disposable.

I’d use the following workspace layout:

…/emacs-workspace
  build/     ← out-of-tree build directory
  docker/    ← separate directory so nothing gets into Docker build context
    Dockerfile
  emacs/     ← source tree
  .env       ← see below
  docker-compose.yml  ← convenience wrapper
  Makefile   ← convenience wrapper over docker-compose

Sample configuration files below are completely untested and provided
only to give an idea.

docker/Dockerfile:
```
FROM ubuntu:20.04  # whatever distro is closest to yours

RUN apt-get update && \
    apt-get install --yes \
        build-essential gdb \
        …more toolchain and dependencies…
RUN adduser ubuntu  # non-privileged build user if not already provided by image
```

docker-compose.yaml:
```
version: "3.7"
services:
  builder:
    build:
      context: docker/
    user: ${DOCKER_UID:-1000}:${DOCKER_GID:-1000}
    volumes:
      - ./build:/home/ubuntu/build
      - ./emacs:/home/ubuntu/emacs
      - /tmp/.X11-unix:/tmp/.X11-unix
```

.env:
```
# If your local user ID or group ID is different from those in the container,
# specify them here
# DOCKER_UID=1001
# DOCKER_GID=1001
```

Makefile:
```
DOCKER_RUN = docker-compose run \
    --rm \
    --user=ubuntu \
    --workdir=/home/ubuntu/emacs \
    builder
CONFIGURE_FLAGS = …

configure:
    $(DOCKER_RUN) ./configure $(CONFIGURE_FLAGS)

build:
    $(DOCKER_RUN) make

debug:
    $(DOCKER_RUN) gdb --args ../build/emacs $(ARGS)
```



  parent reply	other threads:[~2021-10-28 16:07 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-28 12:55 Alternatives for reliable build environments for emacs? joakim
2021-10-28 13:33 ` Eli Zaretskii
2021-10-28 14:38   ` joakim
2021-10-28 14:45     ` Robert Pluim
2021-10-28 15:22       ` joakim
2021-10-28 15:29         ` Robert Pluim
2021-10-28 19:09           ` Tassilo Horn
2021-10-29  6:14         ` Po Lu
2021-10-28 16:08     ` Eli Zaretskii
2021-10-28 17:37       ` joakim
2021-10-28 20:37     ` Pierre Téchoueyres
2021-10-29  0:29     ` Yuchen Pei
2021-10-29  6:14       ` Eli Zaretskii
2021-11-03  6:53         ` Yuchen Pei
2021-10-28 16:07 ` Yuri Khan [this message]
2021-10-28 20:20   ` Daniel Martín
2021-10-28 19:02 ` Stefan Monnier
2021-10-28 19:58   ` Tim Cross
2021-10-28 21:35   ` joakim
2021-10-30  6:52 ` Richard Stallman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAP_d_8VjPczy_OMzYce9h9JGOuS6MG3Hcbk4KwG7c9QUS24b-A@mail.gmail.com \
    --to=yuri.v.khan@gmail.com \
    --cc=emacs-devel@gnu.org \
    --cc=joakim@verona.se \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).