I’ve set about using Nix to build binaries of a range of Emacs versions, for convenient use in CI setups by emacs lisp authors. I have pared down the NixPkgs Emacs derivation to build Emacs very minimally, and have got it working on Darwin for the nine releases from Emacs 24.3 to 26.3.
My CI build for this spans Linux and MacOS, and I’ve had a tough time getting it to build the three 24.x versions on Linux: using clangStdenv
instead of stdenv
seems to have got it down to just 24.3 failing.
Specifically, the failed job explodes with
clang -nostdlib -Demacs -I. -I/tmp/nix-build-emacs-24.3.drv-0/emacs-24.3/src -I../lib -I/tmp/nix-build-emacs-24.3.drv-0/emacs-24.3/src/../lib -I/nix/store/2q1c6v8sr0mdsw6p1jggwhh02z300kd4-libxml2-2.9.9-dev/include/libxml2 -MMD -MF deps/.d -MP -I/nix/store/b5w7sqzrpwk8v7p5x9h838h358n0h2zf-gnutls-3.6.9-dev/include -DMAC_OS_X_VERSION_MAX_ALLOWED=101200 -Wl,-znocombreloc \
-o temacs pre-crt0.o /nix/store/6yaj6n8l925xxfbcd65gzqx3dz7idrnn-glibc-2.27/lib/crt1.o /nix/store/6yaj6n8l925xxfbcd65gzqx3dz7idrnn-glibc-2.27/lib/crti.o dispnew.o frame.o scroll.o xdisp.o menu.o window.o charset.o coding.o category.o ccl.o character.o chartab.o bidi.o cm.o term.o terminal.o xfaces.o emacs.o keyboard.o macros.o keymap.o sysdep.o buffer.o filelock.o insdel.o marker.o minibuf.o fileio.o dired.o cmds.o casetab.o casefiddle.o indent.o search.o regex.o undo.o alloc.o data.o doc.o editfns.o callint.o eval.o floatfns.o fns.o font.o print.o lread.o syntax.o unexelf.o bytecode.o process.o gnutls.o callproc.o region-cache.o sound.o atimer.o doprnt.o intervals.o textprop.o composite.o xml.o profiler.o terminfo.o lastfile.o gmalloc.o ralloc.o vm-limit.o ../lib/libgnu.a -lrt -L/nix/store/2falbql0rlhwd7xwwgzb7zx54a1bvbd3-libxml2-2.9.9/lib -lxml2 -ltinfo -L/nix/store/dil5xi0davx349cdfppgw9zi6mf82vn0-gnutls-3.6.9/lib -lgnutls -lpthread -lm -lgcc -lc -lgcc /nix/store/6yaj6n8l925xxfbcd65gzqx3dz7idrnn-glibc-2.27/lib/crtn.o
/nix/store/m5wwsdqmb62xzjxa7q70x7j46f5b2d1m-binutils-2.31.1/bin/ld: /nix/store/6yaj6n8l925xxfbcd65gzqx3dz7idrnn-glibc-2.27/lib/libpthread_nonshared.a(pthread_atfork.oS): in function `__pthread_atfork':
(.text+0x3): undefined reference to `__dso_handle'
/nix/store/m5wwsdqmb62xzjxa7q70x7j46f5b2d1m-binutils-2.31.1/bin/ld: temacs: hidden symbol `__dso_handle' isn't defined
/nix/store/m5wwsdqmb62xzjxa7q70x7j46f5b2d1m-binutils-2.31.1/bin/ld: final link failed: bad value
clang-7: error: linker command failed with exit code 1 (use -v to see invocation)
make[1]: *** [Makefile:632: temacs] Error 1
make[1]: Leaving directory '/tmp/nix-build-emacs-24.3.drv-0/emacs-24.3/src'
make: *** [Makefile:334: src] Error 2
builder for '/nix/store/6clzpqfzja0qgslgww238kqlyx1dpkfp-emacs-24.3.drv' failed with exit code 2
which was the error I saw with all three 24.x versions prior to switching to clangStdenv
.
The corresponding successful command on Darwin is
clang -Demacs -I. -I/private/tmp/nix-build-emacs-24.3.drv-0/emacs-24.3/src -I../lib -I/private/tmp/nix-build-emacs-24.3.drv-0/emacs-24.3/src/../lib -I/nix/store/zalidv7dj4bhc8nvwqamrll35hlnh8jv-libxml2-2.9.9-dev/include/libxml2 -MMD -MF deps/.d -MP -I/nix/store/y99mxhf52pi0xfk9zrsn8ykiss1q42f2-gnutls-3.6.9-dev/include -DMAC_OS_X_VERSION_MAX_ALLOWED=101200 -fno-pie -prebind -Xlinker -headerpad -Xlinker 690 \
-o temacs pre-crt0.o dispnew.o frame.o scroll.o xdisp.o menu.o window.o charset.o coding.o category.o ccl.o character.o chartab.o bidi.o cm.o term.o terminal.o xfaces.o emacs.o keyboard.o macros.o keymap.o sysdep.o buffer.o filelock.o insdel.o marker.o minibuf.o fileio.o dired.o cmds.o casetab.o casefiddle.o indent.o search.o regex.o undo.o alloc.o data.o doc.o editfns.o callint.o eval.o floatfns.o fns.o font.o print.o lread.o syntax.o unexmacosx.o bytecode.o process.o gnutls.o callproc.o region-cache.o sound.o atimer.o doprnt.o intervals.o textprop.o composite.o xml.o profiler.o terminfo.o lastfile.o ../lib/libgnu.a -L/nix/store/4slbcvclgg0naizcj321w84agn4qj4rc-libxml2-2.9.9/lib -lxml2 -lncurses -L/nix/store/znz8d6c9q85b49s4fynxh6807kd3i99h-gnutls-3.6.9/lib -lgnutls -lpthread
which shows up obvious differences due to glibc
being in use on the failing Linux build, while it is unavailable on Darwin.
Now, I’m new to this and have been cargo-culting liberally, so I thought I’d ask if anyone can offer me a pointer please? (The most recent comments on this article seem potentially relevant, and indicate that linking order might be involved, but that could be a red herring.)