Меnu:


In our previous article We mentioned about 'reinstalling emacs23', that's the purpose of this article.

some history about ¿why are we reinstalling emacs23?

Our lower end machine is an SBC which is 'orange pi plus 2e'. But also It is an always on machine. Our SBC has archlinux-ARM as its operative system, our SBC uses mainline kernel. Its installation date goes back to 2018. At that time the emacs version was emacs-25. But as We also have emacs-23 running on our phone the Nokia N900. We never lost touch with emacs-23. And little by little We started noticing how quick emacs-23 was compared to latest versions.

How was the previous emacs-23 version compiled?

It was compiled with the "CANNOT_DUMP=yes" option. It was tricky getting it to run, at least on our SBC. But after working with it. It stopped booting with a segfault. Sometimes It is not possible for us fixing it right away. We are doing it now which is quite nice :).

Is it simple compiling emacs-23 on 2022?

The answer is NO. emacs-23 was released at the time of kernel-2.6.28. On 2022 We have kernel 5.15. A lot has happened from the times of kernel-2.6.28. kernel-2.6.28 was released on 2008. So We have fourteen years of kernel development.

Getting emacs-23 source code.

Besides getting emacs-23 source code as it was released on 2012. We would need the gentoo patches for emacs-23. That's the minimum for getting emacs-23 compiled nowadays. But In our particular case We were also affected for another couple of issues that we have solved.

Our emacs-23 version has the last tramp version that supports emacs-23

With the help of Michael Albinus. We got patching manually the emacs-23.4 source code with the tramp version 2.3.1. Quite nice having multi-hops on emacs-23. Upgrading the emacs-23.4 tramp version to version 2.3.1. requires modifying 'src/Makefile.in', rm src/lisp/net/tramp*, and cp the tramp-2.3.1/tramp* files to src/lisp/net/. All of the steps of the quick explanation are being done with an script for avoiding mistakes in the process.

compiling emacs-23 with gcc-11 y glibc 2.35

We just needed to grab the PKGBUILD from our previous emacs-23 compilation with 'CANNOT_DUMP=yes'. Obviously removing the 'CANNOT_DUMP=yes' from it. Also download an apply all the gentoo patches (which are 33 on 2022).

First of all You would need to run 'makepkg -o' for applying all the patches to the source code.

Secondly. As configure.in was affected by the patches. Now is mandatory to run 'autoreconf -fiv' at './src/emacs-23.4'. JIC before 'autoreconf -fiv' We run the script for upgrading tramp.

Thirdly. You should just run 'makepkg -e'

running the just compiled emacs-23 binary on our always on SBC

The previous part gaves You the emacs23.tar.xz package for installing on archlinux-ARM. But After installing it and trying It we got the following issues.

Well. The binary segfaults. So We had to attach gdb for getting a backtrace.

First issue:

--8<---------------cut here---------------start------------->8---
Starting program: /usr/local/bin/emacsemacs23 -Q
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/usr/lib/libthread_db.so.1".

Program received signal SIGSEGV, Segmentation fault.
0xb5ec4360 in malloc_usable_size () from /usr/lib/libc.so.6
(gdb) bt
#0  0xb5ec4360 in malloc_usable_size () at /usr/lib/libc.so.6
#1  0xb2cca4c8 in  () at /usr/lib/libnss_resolve.so.2
#2  0xb2cd3e34 in  () at /usr/lib/libnss_resolve.so.2
#3  0xb2cd4988 in  () at /usr/lib/libnss_resolve.so.2
#4  0xb2cd8e00 in  () at /usr/lib/libnss_resolve.so.2
#5  0xb2cd9eac in  () at /usr/lib/libnss_resolve.so.2
#6  0xb2cc2bd4 in _nss_resolve_gethostbyname4_r () at /usr/lib/libnss_resolve.so.2
#7  0xb5f0efa8 in gaih_inet.constprop () at /usr/lib/libc.so.6
#8  0xb5f0fc54 in getaddrinfo () at /usr/lib/libc.so.6
#9  0x001053ac in init_system_name () at sysdep.c:1793
#10 0x0015c518 in init_editfns () at editfns.c:152
#11 0x0001b050 in main (argc=<optimized out>, argv=0xbefffa04) at emacs.c:1747
--8<---------------cut here---------------end--------------->8---

This is the patch that solves the getaddrinfo issue:

,---- [ patch ]
| 003_ignore_getaddrinfo_on_sacsa.patch
`----
--8<---------------cut here---------------start------------->8---
--- emacs-23.4/configure.in.orig
+++ emacs-23.4/configure.in
@@ -2377,7 +2377,7 @@
 rename closedir mkdir rmdir sysinfo getrusage get_current_dir_name \
 random lrand48 bcopy bcmp logb frexp fmod rint cbrt ftime setsid \
 strerror fpathconf select mktime euidaccess getpagesize tzset setlocale \
-utimes getrlimit setrlimit setpgid getcwd getwd shutdown getaddrinfo \
+utimes getrlimit setrlimit setpgid getcwd getwd shutdown \
 __fpending mblen mbrlen mbsinit strsignal setitimer ualarm index rindex \
 sendto recvfrom getsockopt setsockopt getsockname getpeername \
 gai_strerror mkstemp getline getdelim mremap memmove fsync sync bzero \

Diff finished.  Fri Mar 18 15:46:54 2022
--8<---------------cut here---------------end--------------->8---

After applying the getaddrinfo patch We got a second segfault with the function gethostbyname. See the backtrace below.

Second issue:

--8<---------------cut here---------------start------------->8---
Starting program: /usr/local/bin/emacs-23
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/usr/lib/libthread_db.so.1".

Program received signal SIGSEGV, Segmentation fault.
0xb5ec4360 in malloc_usable_size () from /usr/lib/libc.so.6
(gdb) bt
#0  0xb5ec4360 in malloc_usable_size () at /usr/lib/libc.so.6
#1  0xb2cca4c8 in  () at /usr/lib/libnss_resolve.so.2
#2  0xb2cd3e34 in  () at /usr/lib/libnss_resolve.so.2
#3  0xb2cd4988 in  () at /usr/lib/libnss_resolve.so.2
#4  0xb2cd8e00 in  () at /usr/lib/libnss_resolve.so.2
#5  0xb2cd9eac in  () at /usr/lib/libnss_resolve.so.2
#6  0xb2cc35b4 in _nss_resolve_gethostbyname3_r () at /usr/lib/libnss_resolve.so.2
#7  0xb2cc4720 in _nss_resolve_gethostbyname_r () at /usr/lib/libnss_resolve.so.2
#8  0xb5f43cd0 in gethostbyname_r@@GLIBC_2.4 () at /usr/lib/libc.so.6
#9  0xb5f43270 in gethostbyname () at /usr/lib/libc.so.6
#10 0x0010537c in init_system_name () at sysdep.c:1828
#11 0x0015c488 in init_editfns () at editfns.c:152
#12 0x0001b050 in main (argc=<optimized out>, argv=0xbefff9e4) at emacs.c:1747
--8<---------------cut here---------------end--------------->8---

For solving the gethostbyname issue we got the next patch.

,---- [ patch ]
| 004_avoid_gethostbyname_on_sacsa.patch
`----
--8<---------------cut here---------------start------------->8---
--- emacs-23.4/src/sysdep.c.orig
+++ emacs-23.4/src/sysdep.c
@@ -1825,7 +1825,7 @@
 #ifdef TRY_AGAIN
            h_errno = 0;
 #endif
-           hp = gethostbyname (hostname);
+           //hp = gethostbyname (hostname);
 #ifdef TRY_AGAIN
            if (! (hp == 0 && h_errno == TRY_AGAIN))
 #endif

Diff finished.  Fri Mar 18 22:24:56 2022
--8<---------------cut here---------------end--------------->8---

After solving this couple of particular issues when running the emacs-23 binary on our always on SBC. The emacs-23 binary start working without any other issue. Having completed the emacs-23 re-installation on our SBC. Next article is going to be about comparing emacs-23 vs emacs-with-native-compilation.

Bonus: A couple of pics of emacs-23 running on opi+2e SBC.

Last change: 25.03.2022 17:31

blog comments powered by Disqus