Installed Emacs 25.2

Emacs 25.2 is mostly a bug-fix release and I haven’t had any problems so I didn’t bother installing it as soon as it was released. Still, Irreal likes to be up-to-date on all things Emacs so I finally got around to compiling and installing it. Really, compiling it from source isn’t much harder than using homebrew or one of its siblings.

Here’s the recipe for compiling and installing it on macOS:

cd path-to-untared-source
configure --with-ns CFLAGS="-g3 -O2 -I /usr/local/include/libxml2"
make
make install
sudo mv nextstep/Emacs.app /Applications

I always mv my current Emacs to a backup version but that’s probably just irrational paranoia. The above recipe builds Emacs with EWW support. If you have additional needs, you may have to adjust the configure.

UPDATE [2017-04-27 Thu]: John Mastro commented that he thought specifying the CFLAGS variable to configure overroad the default value, which turns on some optimization. After some investigation, which you can read about in the comments, I discovered that that was indeed the case. I rebuilt Emacs with the new configure invocation shown above. If you followed the old recipe, you may want to do the same.

This entry was posted in General and tagged . Bookmark the permalink.
  • John Mastro

    I'm not 100% sure about this, so someone correct me if I'm wrong, but I think specifying CFLAGS completely overrides the default CFLAGS rather than being e.g. appended to them. If so, doing it as above would result in an unoptimized build.

    Assuming I'm right, to retain optimizations (and get better debugging info), you could use something like CFLAGS="-pipe -march=nocona -O2 -g3 -I /usr/local/include/libxml2".

    • jcs

      Looking at the generated Makefile it appears that the CFLAGS values are added to many others that are either default or specified by other variables.

      • John Mastro

        Here's the thread on emacs-devel that gave me the impression I described. I'll admit I never really checked, so it's very possible I misunderstood (or there's been a change since then) and I've been cargo-culting.

        https://lists.gnu.org/archive/html/emacs-devel/2016-11/msg00271.html

        • jcs

          After digging around fruitlessly in the horror that is autoconfig, I reran configure and checked the report at the end of configure's output. It said the it would build Emacs with gcc -I /usr/local/include/libxml2. Then I reran it without the CFLAGS variable and it said it would build Emacs with gcc -O2 -g3. So I rebuilt Emacs with configure --with-ns CFLAGS="-g3 -O2 -I /usr/local/include/libxml2". Everything seems fine so far.

          The TL;DR is that you were right. Setting CFLAGS does override the default. Thanks for setting me straight on this. I will add an update to the post.

  • Perry Metzger

    BTW, on the mac, I don't think you need --with-ns any more. I think configure finds that on its own as of 25. I also tend to build --without-dbus (because macports can accidentally tickle that one since I have some X apps) and --without-compress-install (because I don't need to save the trivial amount of space). Oh, and "make install-info" as well as "make install" may be of use.

    • jcs

      I've been using the same recipe for the last several versions. It's obviously time for me to take a new look at the building Emacs process. Nice hint about make install-info.

      My (almost) decade of Emacs use pales on comparison to your 30+ but it seems like we both find that there's always more to learn.

      • Perry Metzger

        There are other targets useful in the Makefile, like for building and installing the html and pdf documentation and the refcards and the like. It's worth giving it a read.

        As for learning, I think I discover something new about Emacs about every couple of weeks. :)

        • jcs

          As for learning, I think I discover something new about Emacs about every couple of weeks.

          That's the difference between 30+ years and (almost) a decade. It seems like I learn something new every couple of days. Or at least once a week.

      • Perry Metzger

        Oh, one other hint: on almost any modern machine with multiple cores, be sure to use "-jN" with make when building, where N is your number of cores/hyperthreads (e.g. "make -j4 install install-info"). It will parallelize the build and finish far faster. -j is of course a feature of modern make, and not emacs specific.