Void-packages: [Package Request] GccEmacs

Created on 12 Aug 2020  路  13Comments  路  Source: void-linux/void-packages

Package Name

GCCemacs (http://akrl.sdf.org/gccemacs.html)

Linux-related link

https://www.emacswiki.org/emacs/GccEmacs
http://akrl.sdf.org/gccemacs.html#org248e6b1
http://akrl.sdf.org/gccemacs.html#orgec98bb2

Practical Rationale

This (slowness) comes up often. The first thing folks fresh off the boat from other editors will notice is that Emacs has a low threshold for performance issues. It doesn鈥檛 take much to get it to scroll like molasses... There is an unfortunate but necessary adjustment of expectations new users must undergo, when they adopt Emacs. Doom has inherited this curse. It鈥檚 raison d鈥檈tre is to improve the situation, but I can only go so far, especially if you choose to enable all the most expensive features. You will unavoidable find cases where Emacs is just slow.

Reference:
https://github.com/hlissner/doom-emacs/blob/fd3b89854eb13ddb2c8ecc2da68a9cbb0dcdb836/docs/faq.org#why-is-emacsdoom-slow

One of the things that irritated me the most about emacs was how slow it was when the text in one of the files got very long. If a line (paragraphs are considered one line in emacs) gets too long, emacs starts to slow down till you start a new paragraph. As someone who does writing for a living, taking notes, inserting citations, this starts to get very annoying. Upon conversation with the creator of DOOM emacs, I installed GCC emacs. There are a bunch of different ways to do this, but I followed the amazing gist written by mjlbach. When I ran into trouble he took time out to help me figure it out. Much thanks to him. As a result, my emacs runs as fast as it ever has.

Reference:
https://github.com/sunnyhasija/DOOMEmacs/blob/master/README.org#move-to-gcc-emacs

Manual installation in Void

Tried to install in voidlinux without success as follows:

$ git clone https://git.savannah.gnu.org/emacs.git
$ cd emacs
$ git checkout feature/native-comp
$ ./autogen.sh
$ ./configure --with-nativecomp
...
configure: error: Installed libgccjit has failed passing the smoke test.
You can verify it yourself compiling:
<https://gcc.gnu.org/onlinedocs/jit/intro/tutorial01.html>.
Please report the issue to your distribution.
Here instructions on how to compile and install libgccjit from source:
<https://gcc.gnu.org/wiki/JIT>.

ATTN: @leahneukirchen (the emacs package maintainer)

request wontfix

Most helpful comment

I have made packages for both libgccjit and emacs-28.0.50 with nativecomp build option. You can grab patches here:

All 13 comments

Hi,

we only package released software, and gccemacs is still in heavy development. The build probably fails, because we don't have libgccjit packaged at all, so you would need to start with that.

WONTFIXing for now, but feel free to ask on this thread for help.

Hi,

we only package released software, and gccemacs is still in heavy development. The build probably fails, because we don't have libgccjit packaged at all, so you would need to start with that.

@leahneukirchen Thanks. As you are onto academics yourself as seen in https://leahneukirchen.org/talks/, GccEmacs could be of your interest?!

Anyway, ould you mind briefing the ideal void way to build libgccjit as well as GccEmacs without conflicting other void file structures for maintaining compatibility with void Emacs packages in the future?

Two resources I found useful are:

  1. https://gcc.gnu.org/wiki/JIT which points to https://gcc.gnu.org/onlinedocs/jit/internals/index.html#working-on-the-jit-library for non-standard linux distros
  1. https://www.emacswiki.org/emacs/GccEmacs#toc5 (for manual build of GccEmacs)

WONTFIXing for now, but feel free to ask on this thread for help.

Appreciate that.

Cheers, and stay safe,
/z

Hey @zenny, here is a template for libgccjit that I got working today on my machine (x86-64 glibc). I hope this could serve as a starting point for a real libgccjit template for void:

https://gist.github.com/Javyre/2578176bf09638733c08586e654fb04d

I used this as reference: https://aur.archlinux.org/cgit/aur.git/tree/PKGBUILD?h=libgccjit

I tried modifying the existing gcc template to have a subpackage for libgccjit, but I couldn't get it to work as I'd keep getting errors telling me to add -fPIC although I had already added it to the flags. Either way, it is not recommended to use the same ./configure call for the gcc compilers as for libgccjit since -fPIC and --enable-host-shared come at a performance cost: https://gcc.gnu.org/onlinedocs/gcc-8.3.0/jit/internals/index.html#packaging-notes

Hey @zenny, here is a template for libgccjit that I got working today on my machine (x86-64 glibc). I hope this could serve as a starting point for a real libgccjit template for void:

https://gist.github.com/Javyre/2578176bf09638733c08586e654fb04d

I used this as reference: https://aur.archlinux.org/cgit/aur.git/tree/PKGBUILD?h=libgccjit

I tried modifying the existing gcc template to have a subpackage for libgccjit, but I couldn't get it to work as I'd keep getting errors telling me to add -fPIC although I had already added it to the flags. Either way, it is not recommended to use the same ./configure call for the gcc compilers as for libgccjit since -fPIC and --enable-host-shared come at a performance cost: https://gcc.gnu.org/onlinedocs/gcc-8.3.0/jit/internals/index.html#packaging-notes

@Javyre Thanks for help, I shall test and get back with my results.

Meanwhile, would you mind taking some time to explain the steps you took to build libgccjit? Appreciate that. Fyi, I am new to xbps package build.

Cheers and stay safe,
/z

I basically just looked at the arch packagebuild and the packaging notes on the gccjit website and I transcribed the parts of the gcc void template that were relevant to libgccjit and x86-64.

I'm not sure whether libgccjit should have it's own package template or be yet another subpackage of gcc. I think the best choice would be to have it as a subpackage of gcc and add an extra ./configure and make call in do_configure() and do_build() so that libgccjit could be built with --enable-host-shared and not the rest of the packages.

@zenny Assuming you're familiar enough with shell scripts, I suggest just starting and Ctrl-Fing through the manual whenever you're confused. (worked for me)

Also, I updated the gist with a terrible (but working) template for gccemacs that I am not proud of.
Worth noting:

  • I had to add libgccjit.so.0 libgccjit-9.3.0_6 to common/shlibs to get my gccemacs to install since xbps couldn't find the provider of that .so.
  • I had to disable the hooks/post-install/11-pkglint-elf-in-usrshare.sh hook since gccemacs (at least for the time being) stores eln files in /usr/share. If I understand correctly, this was fine before since they would be el or elc files which are portable, but with native-comp, now those files are actual binaries. This would definitely need to be fixed and discussed with andrea or another gccemacs dev. (It is unclear from the mailing list what the eln search path is or where it is even defined)

I have made packages for both libgccjit and emacs-28.0.50 with nativecomp build option. You can grab patches here:

@ap4y is this currently working on musl? I needed this patch:

Fix poisoned calloc errors when building libgccjit

---
 gcc/jit/jit-playback.c  | 4 ++--
 gcc/jit/jit-recording.c | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/gcc/jit/jit-playback.c b/gcc/jit/jit-playback.c
index b74495c58..070463d71 100644
--- a/gcc/jit/jit-playback.c
+++ b/gcc/jit/jit-playback.c
@@ -18,6 +18,8 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */

+#include <pthread.h>
+
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
@@ -40,8 +42,6 @@ along with GCC; see the file COPYING3.  If not see
 #include "gcc.h"
 #include "diagnostic.h"

-#include <pthread.h>
-
 #include "jit-playback.h"
 #include "jit-result.h"
 #include "jit-builtins.h"
diff --git a/gcc/jit/jit-recording.c b/gcc/jit/jit-recording.c
index a332fe875..7184a481a 100644
--- a/gcc/jit/jit-recording.c
+++ b/gcc/jit/jit-recording.c
@@ -18,6 +18,8 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */

+#include <pthread.h>
+
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
@@ -25,8 +27,6 @@ along with GCC; see the file COPYING3.  If not see
 #include "pretty-print.h"
 #include "toplev.h"

-#include <pthread.h>
-
 #include "jit-builtins.h"
 #include "jit-recording.h"
 #include "jit-playback.h"
-- 
2.28.0

Tried to compile libgccjit first with the patches provided by @ap4y in https://github.com/void-linux/void-packages/issues/24240#issuecomment-699700450, but failed with the following error:

...
checking whether to enable maintainer-specific portions of Makefiles... no
configure: creating ./config.status
config.status: creating Makefile
mv: cannot move './confxaxD9R/out' to 'Makefile': No such file or directory
config.status: error: could not create Makefile
=> ERROR: libgccjit-9.3.0_1: do_configure: '${configure_script} ${configure_args}' exited with 1
=> ERROR:   in do_configure() at common/build-style/gnu-configure.sh:7

Same with while running ./xbps-src pkg emacs:

...
=> emacs-28.0.50.e5b052d_1: running do_configure ...
/void-packages/srcpkgs/emacs/template: line 60: ./configure: No such file or directory
=> ERROR: emacs-28.0.50.e5b052d_1: do_configure: './configure --without-x $(vopt_with
dbus) ${configure_args}' exited with 127
=> ERROR:   in do_configure() at srcpkgs/emacs/template:60

I am on gcc and used proot, fyi. Thanks

Hey, I managed to make @ap4y 's changes work for me: https://github.com/void-linux/void-packages/compare/master...Javyre:emacs-nativecomp

The libgccjit template is unchanged from his, but his emacs template was missing the compiled .eln and .pdmp files in /usr/lib/.
(I also updated the git sha to the latest on the nativecomp branch)

To compile emacs I use ./xbps-src -o ~gtk2,~x11,cairo,harfbuzz,nativecomp pkg emacs

Hey, I managed to make @ap4y 's changes work for me: master...Javyre:emacs-nativecomp

The libgccjit template is unchanged from his, but his emacs template was missing the compiled .eln and .pdmp files in /usr/lib/.
(I also updated the git sha to the latest on the nativecomp branch)

To compile emacs I use ./xbps-src -o ~gtk2,~x11,cairo,harfbuzz,nativecomp pkg emacs

Thanks @Javyre . I pulled your revised emacs template and appended related files, yet no go :-(

Reports emacs-common missing and thereafter some missing support with libgccjit and finally fails to create Makefile

$ ./xbps-src -o ~gtk2,~x11,cairo,harfbuzz,nativecomp pkg emacs
...
   [runtime] emacs-common-28.0.50.3e3843512bfae0b7a532f633e45d4c140807ec9b_1: not found (subpkg, ignored)
   [runtime] emacs-common-28.0.50.3e3843512bfae0b7a532f633e45d4c140807ec9b_1: not found (subpkg, ignored)
   [runtime] emacs-common-28.0.50.3e3843512bfae0b7a532f633e45d4c140807ec9b_1: not found (subpkg, ignored)
   [runtime] desktop-file-utils-0.26_1: found (https://alpha.de.repo.voidlinux.org/current)
   [runtime] hicolor-icon-theme-0.17_2: found (https://alpha.de.repo.voidlinux.org/current)
...
checking for isl 0.15 or later... no
required isl version is 0.15 or later
The following languages will be built: c,jit
*** This configuration is not supported in the following subdirectories:
     gnattools gotools target-libada target-libhsail-rt target-libstdc++-v3 target-libphobos target-zlib target-libbacktrace target-libgfortran target-libgo target-libffi target-libobjc target-liboffloadmic target-libitm target-libsanitizer target-libvtv
    (Any other directories should still work fine.)
checking for default BUILD_CONFIG...
checking for --enable-vtable-verify... no
checking for bison... no
checking for byacc... no
checking for yacc... no
checking for bison... no
checking for gm4... no
checking for gnum4... no
checking for m4... no
checking for flex... no
checking for lex... no
checking for flex... no
checking for makeinfo... no
/builddir/gcc-9.3.0/missing: line 81: makeinfo: command not found
checking for expect... no
checking for runtest... no
...
checking whether to enable maintainer-specific portions of Makefiles... no
configure: creating ./config.status
config.status: creating Makefile
mv: cannot move './conf30zSA8/out' to 'Makefile': No such file or directory
config.status: error: could not create Makefile
=> ERROR: libgccjit-9.3.0_1: do_configure: '${configure_script} ${configure_args}' exited with 1
=> ERROR:   in do_configure() at common/build-style/gnu-configure.sh:7

Looks like it's missing texinfo when building libgccjit. I just pushed
to my branch again, this should be fixed.

(make sure to ./xbps-src clean libgccjit)

Looks like it's missing texinfo when building libgccjit. I just pushed to my branch again, this should be fixed. (make sure to ./xbps-src clean libgccjit)

Not yet!

Even after appending texinfo in the https://github.com/void-linux/void-packages/blob/b378df45dbf113ac181aa5c9a45143dfb5974f2a/srcpkgs/libgccjit/template#L12 and the cleaned the source, still fails to build and compile:

...
   [runtime] emacs-common-28.0.50.3e3843512bfae0b7a532f633e45d4c140807ec9b_1: not found (subpkg, ignored)
   [runtime] emacs-common-28.0.50.3e3843512bfae0b7a532f633e45d4c140807ec9b_1: not found (subpkg, ignored)
   [runtime] emacs-common-28.0.50.3e3843512bfae0b7a532f633e45d4c140807ec9b_1: not found (subpkg, ignored)
...
bsdtar: Failed to set default locale
...
checking whether to enable maintainer-specific portions of Makefiles... no
configure: creating ./config.status
config.status: creating Makefile
mv: cannot move './conf8CQSPW/out' to 'Makefile': No such file or directory
config.status: error: could not create Makefile
=> ERROR: libgccjit-9.3.0_1: do_configure: '${configure_script} ${configure_args}' exited with 1
=> ERROR:   in do_configure() at common/build-style/gnu-configure.sh:7

Even after installing isl15 and isl15-devel which is at v 0.19 :

[*] isl15-0.19_1             Integer Set Library
[*] isl15-devel-0.19_1       Integer Set Library - development files

It gives out the following error (thogh does not seem inevitable):

checking for isl 0.15 or later... no
required isl version is 0.15 or later
The following languages will be built: c,jit
*** This configuration is not supported in the following subdirectories:
     gnattools gotools target-libada target-libhsail-rt target-libstdc++-v3 target-libphobos target-zlib target-libbacktrace target-libgfortran target-libgo target-libffi target-libobjc target-liboffloadmic target-libitm target-libsanitizer target-libvtv
    (Any other directories should still work fine.)
checking for default BUILD_CONFIG...

Thanks to user natrys in the voidlinux IRC for pointing out not to use proot. Actually using proot was causing the compilation and build issue stated above.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

surafel911 picture surafel911  路  3Comments

emacsomancer picture emacsomancer  路  5Comments

Johnnynator picture Johnnynator  路  3Comments

sburris0 picture sburris0  路  4Comments

Seeder101 picture Seeder101  路  5Comments