Hacker News new | past | comments | ask | show | jobs | submit login

I would strongly recommend everyone try the native-comp Emacs 28 branch. Native compilation of Elisp files has greatly improved performance and start-up time, with no downside.

Though it's bleeding edge, I haven't experienced any issues: everything just works.. faster!

It always amazes me that some people are willing to put in such hard work, alone, for open source. The fact that one guy managed to speed up all of Emacs 2x-20x in his spare time for no pay is frankly amazing. Certainly puts my side-projects to shame.

I second every single line of this comment.

Here's the update log of the project.


With https://akrl.sdf.org/gccemacs.html#orgfc80a25 being the relevant starting point in that sea of text (the PKGBUILD is also handy for seeing what's going on: https://aur.archlinux.org/cgit/aur.git/tree/PKGBUILD?h=emacs... )

> It always amazes me that some people are willing to put in such hard work, alone, for open source.

For many people this is about scratching an itch, their own itch.

They improve upon it not for the sake of "open source", but for the sake of making the very same tools they rely on to be better tools.

This is how open-source used to work, and this is how it grew.

Thanks for this! I use Emacs but haven’t invested any time in my setup for a long time. After I get back from my morning hike, I am going to invest some time on this. Thanks again.

> It always amazes me that some people are willing to put in such hard work, alone, for open source.

Apart of a few well known projects, the open source world is not so rosy.

I'm building an app that exports GPX files (XML file where you can store GPS positions, POIs, routes etc).

All the examples files on the official website ( https://www.topografix.com/gpx.asp ) are broken (they return a blank page) and to validate that your file is compliant you have to compile a 15 years old C++ library first (for some reason they refuse to release a binary).

Have a look at https://gdal.org/index.html

Solved a lot of weird open formats issue we had

Thanks but I already wrote the code and after catching a couple gotchas with the validation tool it's fully compliant now.

My point was not that GPX is hard (it's not) but that when something is open source most of the time you have to put some elbow grease in it because no one is paid to make it polished.

FWIW, it took me less time to write the GPX export code than to look for a binary of the validation tool, fail, then launch WSL and compile the goddam tool.

What does your app do? That's an area I'm pretty interested in.

It's a desktop (Windows) map viewer.

I have built my own OSM server to pre-generate tiles so my app has offline capabilities (I have a very slow internet connection so online maps are quite laggy).

I use it mostly to build routes that I export as gpx files to my Android phone (vehicle nav with Osmand and trekking with Iphigénie).

this sounds super useful to me (I have been in similar situations in the past @ various formats that aren’t super popular).

What sounds useful ? The app ? If you don't have complex requirements there's surely something available for your platform.

How do cool kids install Emacs with native-comp support on OSX these days? emacs-plus formula doesn't support it yet and neither does the Mitsuharu's port.

I'm not sure if I'm cool or not, but I built mine from source. Took a bit of doing. I found a helpful tutorial here:


Oh, you're amazing! This is awesome, thank you. I just built it. Running smoothly.

I spoke too soon. I missed a step in the instructions. It's not working as expected. I'm gonna have to try again. Combining things from that gist and using some bits from here: https://gist.github.com/mikroskeem/0a5c909c1880408adf732ceba...

Me too, actually. Just found out today that it's not actually doing native comp. >:-( I haven't been able to build GCC with libjit support. (Used Clang while building; that solves some problems with GCC.) I've tried testing GCC/libjit on a smoketest and it hasn't worked. Please let me know what you get working!

Daamn... I've been building it with clang for the past hour (I dunno why the heck this taking soooo long, I think on Linux it builds much faster). I guess it won't work for me either :(

upd: Looks like the proper way of building is with gcc, but it builds without GUI. I need GUI.

Dude, if you can get it built, please either send me all the instructions or just post the binary.

Thanks for all your great tips on Twitter, btw. :)

Thank you for the kind words, I'm happy you find the tips useful. I stopped experimenting with native-comp in OSX for now. Sadly, I have only one Mac. Every attempt to compile it takes way too long, and getting Catalina running in VM is similarly challenging. But If I learn anything new I will definitely try again, and of course I will keep you posted.


I might try compiling it on my personal machine this week while I’m at work. I’ll keep you informed as well if anything interesting happens.

Is anybody distributing debian packages of builds off this branch? It's been some years since I built emacs from source...

Have you ever tried flatpak. If so this may be helpful https://github.com/fejfighter/pgtk-emacs-flatpak Pre-configured flatpak manifest to build an emacs branch with libjanson, libgccjit and dependencies

edit: formatting

The only tricky part for me was having to build gcc (for newer libgccjit). But it wasn't too bad. And you might not have to do that at all depending on your Debian version. Hour effort approx.

There was some minor brokenness native comp caused to my setup so still not using this branch. But most stuff did surprisingly work perfectly well.

Yeah I just ran through the checkout and configure process and found: configure: "error: Installed libgccjit has failed passing the smoke test."

FWIW this is libgccjit-10-dev, the most recently available package I could find in my install (debian based Google gLinux).

Not sure if I have the motivation to go build it, but who knows! Beats writing design docs, which is the other thing I could be doing ;-)

Yea was same for me. It's really not that bad.

   mkdir gcc
   cd gcc
   git clone git://gcc.gnu.org/git/gcc.git src
   mkdir build
   mkdir install
   cd build
   ../src/configure \
   --enable-host-shared \
   --enable-languages=jit,c++ \
   --disable-bootstrap \
   --enable-checking=release \
   --prefix=$PREFIX \
   nice make -j4 # altering the "4" to however many cores you have

May need to install some prerequisites listed here https://gcc.gnu.org/install/prerequisites.html (the error message from the configure might not be obvious so better go through the list first, think I needed MPC and MPFR, whatever I found with apt-cache search libmpc and libmpfr worked).

And then configure and make emacs with PATH, LIBRARY_PATH, LD_LIBRARY_PATH including your gcc build (install/bin and install/lib).

[0] taken and modified from https://gcc.gnu.org/onlinedocs/gcc-6.4.0/jit/internals/index...

I just build this from source on my macbook. I noticed significantly higher CPU usage while scrolling. (30%! Non-native comp Emacs 28 w/GUI is around 10–20% when scrolling through a file with lsp mode turned on.) Is this expected? The scrolling seems to stutter at times for me. What am I doing wrong?

Did you compile all of the Elisp files using a high optimization level?

If so, you might want to get in contact with the author. I imagine that OSX isn't as well tested as Linux.

I might try setting that. I’m pretty new to all this; could you point me to where I can find instructions on how to set the optimization level?

I think you can just do:

  (setq comp-speed 3)
Then you should tell it to recompile all of your elisp files:

  (native-compile-async "~/.emacs.d/elpa/" <n> t)
  (native-compile-async "<path/to/system/elisp/files>" <n> t)
Where <n> is the number of threads you want. It's also possible than you have deferred compilation and that's the problem?

Darn it. When I try running the `native-compile-async` function, I get thrown into the debugger with a message telling me that Emacs wasn't compiled with native compiler support.

I did have to use clang instead of gcc to get past some errors about not finding Appkit.h. I'll have to do more digging and try and get gcc working. Thanks for your help though!

Thank you! I’ll give this all a try.

oss will have to mature a bit like good ol corporate programming did

an OSS project will do so much and may die, the next one will try a new branch (from scratch, influenced a bit by the other or fully reusing the old ones)

to save energy it's good to think and plan for continuations.. your project will be much more useful if kept clear so other can jump in and extend or rewrite it without struggle

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact