Building the Development Version of Emacs on Windows (mingw edition)

Some days ago, I gave a brief write-up on how to build the development version of Emacs on Windows under Cygwin. Cygwin is all well and nice, but some prefer the fully native mingw-w64 version, so here’s the howto for that.

The first four steps are identical with the previous recipe, so let’s just skip to 5):

5) Install msys2 by clicking the “Download the installer” link, and then going through the installer.

6) You can now go back to the sofa where you’re no doubt lounging with your Linux laptop (I may just be speaking for myself here), and ssh in:

You can copy and paste the rest of this into your ssh session:

c:\msys64\usr\bin\bash
sed -i -E 's/^Match Group administrators|AuthorizedKeysFile __PROGRAMDATA__/#&/' c:/ProgramData/ssh/sshd_config
powershell -command "restart-service sshd"
pacman -Syu --noconfirm
# Will exit, so restart:
c:\msys64\usr\bin\bash
pacman --noconfirm -Su 
pacman --noconfirm -S git make autoconf
pacman --noconfirm -S --needed base-devel mingw-w64-x86_64-toolchain
pacman --noconfirm -S `pacman -Si mingw-w64-i686-emacs | sed -E ':a ; $!N ; s/\n\s+/ / ; ta ; P ; D' | grep Dep | sed 's/^[^:]*://'`
MSYSTEM=MINGW64 bash -l
git clone https://git.savannah.gnu.org/git/emacs.git
cd emacs
make -j4
./src/emacs

Man, that was painful to figure out, because apparently nobody has ever tried to build anything via ssh before, because all the recipes say “and then you start the mingw shell” (C:\msys64\mingw64.exe), which pops up a window on the Window machine, and is therefore useless. But the MSYSTEM=MINGW64 thing seems to work fine? I’m not sure, though — I don’t know nothing from no Windows.

In any case, a different way to start the shell in MINGW mode is:

c:\msys64\usr\bin\env MSYSTEM=MINGW64 c:\msys64\usr\bin\bash

OK, do this in Powershell:

$oldpath = (Get-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment' -Name PATH).path
$newpath = "$oldpath;c:\msys64\mingw64\bin"
Set-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment' -Name PATH -Value $newPath

Now search for “runemacs.exe”, and click it, and then Emacs starts as it should, and you can edit c:\foo.bar. So I guess it worked! It’s a native Emacs.

That’s still a whole bunch of steps… anybody know a shorter recipe? I really can’t believe that pacman is this primitive… no equivalent of “apt build-dep”? All the build dependencies are kept in PKGBUILD scripts instead of a database?

Dude.

But look!

But more importantly, it works via ssh, too:

./src/emacs -nw

MCMXXXIX VIII: Wife, Husband and Friend

Wife, Husband and Friend. Gregory Ratoff. 1939.

What! There were no lanes in New York in 1939? Just total anarchy? I love it!

This movie’s got a whole bunch of gags… but none of them really land? I mean, very few do. I almost feel bad at not enjoying this movie, because it’s puttering along very nicely, but it’s… not… actually… funny… for some reason or other.

It isn’t really the over misogyny that’s sinking this movie. It just doesn’t have any zing. I mean, the plot is fine: It’s kooky and unexpected, but the performances are so dialled back. I mean: Picture Edward Everett Horton in Warner Baxter’s role. See? Just thinking about it makes you want to smile, right. It’d have been glorious.

Instead these scenes just sit there, making you scratch your chin thinking “yes, I see how this could have been amusing”.

This blog post is part of the 1939
series
.

Building the Development Version of Emacs on Macos (Macports Edition)

A while back, I wrote a how-to for building Emacs on Macos (for people who have no interest in using Macos), but I based that recipe on HomeBrew. There was recently a Macports-related bug report, so I set up a VM with Macports, and I thought I might as well write that up, too.

It turns out that this is even easier than using HomeBrew.

1) Open a Terminal window (by clicking on the spy-glass at the top there and write “Terminal” and then clicking on the icon).

2) Type “gcc” in the terminal. It’ll pop up a dialogue — just answer “yes” to everything.

3) Go to the Macports web page in Safari (it’s the icon that looks vaguely like a compass) and click on the installer for your version of Macos. Then click on the box icon again a couple of times, and answer “yes” some more.

4) Turn on the ssh server by typing “remote login” in the spyglass thing. Switch “Remote login” on for all users.

5) Now you can go back to your free OS, and do the rest via ssh.

sudo port selfupdate
sudo port -N install git `port deps emacs | sed 's/^.*://' | sed 's/,//g' | tail -n 2`
git clone https://git.savannah.gnu.org/git/emacs.git
cd emacs
make -j8
./src/emacs -nw

Presto!

How To Build the Development Version of Emacs on Windows

I think I’ve probably spent… more than an hour? but less than three hours? My entire life? on a Windows machine, so I’m the most qualified person ever to explain how to get started developing Emacs on Windows.

Because people who’ve used Windows before don’t really know what other people don’t know. It’s about the unknown unknowns.

So here’s a guide to get this working anyway, if you’re a Linux-ey person, and for some inexplicable reason you want to build the development version of Emacs on Windows.

1) Install Windows in a VM. Download the ISO from here. Then open virt-manager on your GNU/Linux machine, create a new machine, and point it at the ISO. You’ll be faced with a whole bunch of questions from Windows when installing, but answer “no” to as many as possible. Less surveillance is better.

2) After it’s up and running, search for “powershell” in the search field at the bottom of the screen. Start the “for administrators” version.

3) Type this:

Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0

Yes, those tildes and the numbers and all. And then:

Start-Service sshd
Set-Service -Name sshd -StartupType Automatic
ssh localhost

The latter should give you a login, so just try that to see whether it works.

4) From your GNU/Linux machine, say

scp ~/.ssh/authorized_keys windblows:.ssh/

This will later enable you to ssh to the machine without passwords, but first we have to do more confing, so we might as well just start installing the Linux-ey prerequisites already, because that makes things easier.

5) Install Cygwin by clicking on the “setup-x64_64.exe” link. It’ll ask you more questions, but just answer yes to everything.

6) Done! You don’t need to do anything more on the console, so get back to the couch and do the rest via ssh from a GNU/Linux machine, like a proper human being.

You can copy and paste the rest of this into your ssh session:

C:\cygwin64\bin\bash -l sed -i -E 's/^Match Group administrators|AuthorizedKeysFile __PROGRAMDATA__/#&/' /cygdrive/c/ProgramData/ssh/sshd_config
powershell -command "restart-service sshd"
curl -O https://raw.githubusercontent.com/transcode-open/apt-cyg/master/apt-cyg
install apt-cyg /bin
sed -i 's/lynx -source/curl/' /bin/apt-cyg
apt-cyg install wget
apt-cyg install gcc-core git automake autoconf libgnutls30 make gnutls libncurses-devel gnutls-devel libjpeg-devel libpng-devel libharfbuzz-devel libXpm-noX-devel libgif-devel libxml2-devel libjansson-devel libdbus1-devel librsvg2-devel libtiff-devel libXpm-devel
git clone https://git.savannah.gnu.org/git/emacs.git
cd emacs
./autogen.sh
./configure --with-native-image-api --with-w32
make -j8
./src/emacs

Presto! This should now be displaying in the VM, if you run over to it and have a look:

But you’d normally say

./src/emacs -nw

when working remotely from the sofa, of course.

Additional tweaks: Windows only uses one CPU by default (?), and qemu/virt-manager will tell the Windows client that it has many CPUs. To make it say that it has a lot of cores instead, say:

# virsh edit win10

Find the bit that says:

<cpu mode='host-model' check='partial'>

and edit that into:

<cpu mode='host-model' check='partial'>
    <topology sockets='1' dies='1' cores='8' threads='2'/>
</cpu>

Or however many cores/cpus you have. This will make building Emacs a lot quicker.

(Tips for improving the installation recipe are welcome, of course.)

The Best Albums of 2020

It’s that time of year again: December. Unlike other people who come up with “best of” lists, I use a totally scientific method, and therefore my list is more correct: Emacs tallies which albums I’ve listened to the most in 2020, and those are ipso facto cogito alea jacta hoc the best albums of the year.

ARE YOU DOUBTING SCIENCE

Irreversible Entanglements

Who Sent You?

Sacred Paws

Run Around The Sun

Gil Scott-Heron

We’re New Here (a Reimagining by Makaya McCraven)

Nihiloxica

Kaloli

75 Dollar Bill

I Was Real

Adult.

Perception is-as-of Deception

Joan as Police Woman

Cover Two

Max de Wardener

Music For Detuned Pianos

Peter Broderick & Friends

Play More Arthur Russell

Yves Tumor

Heaven To A Tortured Mind

Aksak Maboul

Figures

Four Tet

Sixteen Oceans

Shirley Collins

Heart’s Ease

Shopping

All Or Nothing

The Soft Pink Truth

Shall We Go On Sinning So That Grace May Increase

So there you have it: Irreversible Entanglements released the best album this year. I hope somebody notifies the AP of these developments.

But I didn’t just buy new music this year. No. I’ve never been discoging more. It’s almost like I was spending more time on the couch this year than previous years. I don’t know why. (I seem to have acquired about 450-ish releases this year.) So here’s the best old music that I discovered this year. It’s slightly less scientific because of the selection criteria.

Fad Gadget

Fireside Favourites

Trash Kit

Confidence

Severed Heads

Clifford Darling, Please Don’t Live In The Past

Tuxedomoon

Live At The Palms (1978)

Biting Tongues

Don’t Heal

Brian Auger & Julie Tippetts

Encore

Don Armando’s 2nd Avenue Band

Don Armando’s 2nd Avenue Band

Mike Rutherford

Smallcreep’s Day

Aksak Maboul

Before and After Bandits

David Allred

Alone on Friendship Island

Jerry Harrison

The Red And The Black

Jim Black Trio

Reckon

Keith Tippett, Julie Tippett, Trevor Watts, Colin McKenzie

Warm Spirits, Cool Spirits

Kid Creole & The Coconuts

Off the Coast of Me

Mars

3E

It’s been the best year ever, both for new and old music.

Except for some other years.

There. I said it.