Wednesday 2 March 2011

Hard-linked chrome now supported on Windows

If you pass --enable-chrome-format=symlink in as an option to configure, any chrome files that don’t need to be preprocessed are symlinked instead1. This is really useful because it allows for a much quicker edit-test cycle – you don’t need to run make every time you edit a file. However, the option only works on platforms that have historically supported symlinks, i.e. Mac and Linux.

… until now. I checked in a patch to the build-system repository yesterday adding support for the option on Windows. Instead of symlinks, though, the option creates hard links2. This isn’t a big deal: the edit-test cycle is as quick as it would be with symlinks.

mozilla-central is in lockdown mode right now, so the patch will only be merged into it after it branches for Firefox 4. You don’t need to wait, though – grab the patch from bug 634596 and apply it to your tree.

Note that

  1. Your source and object directories need to be on the same NTFS partition.
  2. If you use an editor that breaks hard links by default, you will need to configure it to not do so. For Emacs, add the line (setq backup-by-copying-when-linked t) to your .emacs.

1 Yet another reason preprocessed chrome files suck.
2 Why? Firstly, symlinks aren’t supported on Windows XP or 2003. Secondly, even though they are supported on Windows Vista and 7, creating them requires you to be an elevated administrator. Even if you grant yourself the required SeCreateSymbolicLinkPrivilege, if you’re an administrator UAC takes it away.

5 comments:

bsmedberg said...

I'm not sure telling people to disable hardlink-breaking by default in emacs is a good idea. I'm pretty sure that Mercurial uses hardlinks when you do local repository clones, and relies on editors breaking the hardlinks before editing (it certainly does on Linux). If you ever do local clones, you could end up making changes to trees you didn't expect.

Sid said...

Ben: At least on Windows, when you clone a local repository hg only hardlinks its internal store, not the working directory.

WeirdAl said...

Symbolic links for everybody!
http://weblogs.mozillazine.org/weirdal/archives/020645.html

(Actually, I'd take any advice on creating hard links from Python, if they really are recommended for WinXP.)

Sid said...

Alex: well, Python doesn't even support creating hard links on Windows before 3.2. I had to dig in to win32 using ctypes to do this.

neil.rashbrook said...

I tried to teach nsinstall to use hard links, but quickly ran into a problem when it tried to reinstall itself for a depend build; when nsinstall tried to break the existing link it failed because you can't break a hard link to a running executable. Oops.