Build LLVM and clang!

I’ve talked about the LLVM Compiler Infrastructure in the past, but what I haven’t talked about yet is just how easy and quickly you can build it on your own Mac running Leopard! This is a great way to get into hacking on compiler lexical analyzers and parsers, code generators, optimizers, and so on.

What’s more, you can build both LLVM and the new C front-end clang very easily and in five to ten minutes.

First, create a work area to check them out into, wherever you normally create your projects.

[~]% cd /Projects
[/Projects]% mkdir LLVM
[/Projects]% cd LLVM

Then check out LLVM itself and clang from the LLVM Subversion repository.

[/Projects/LLVM]% svn checkout llvm
[/Projects/LLVM]% cd llvm/tools
[/Projects/LLVM/llvm/tools]% svn checkout clang
[/Projects/LLVM/llvm/tools]% cd ../..

Then edit the PARALLEL_DIRS definition in llvm/tools/Makefile to tell it about clang. Just add clang onto the end, like this:

PARALLEL_DIRS := llvm-config  \
                 opt llvm-as llvm-dis \
                 llc llvm-ranlib llvm-ar llvm-nm \
                 llvm-ld llvm-prof llvm-link \
                 lli gccas gccld llvm-extract llvm-db \
                 bugpoint llvm-bcanalyzer llvm-stub llvmc2 \

Now create a directory to build into, next to your llvm directory, and change into it.

[/Projects/LLVM]% mkdir build
[/Projects/LLVM]% cd build

This is where you’ll actually run configure. This will ensure your source tree isn’t polluted with build products, and that everything stays self-contained while you hack.

[/Projects/LLVM/build]% ../llvm/configure --enable-targets=host-only
# lots of logging

You’ll note that above I passed an argument to configure. This ensures that LLVM is only built to target the architecture I’m running on, to speed up the build process; this is generally fine for simple front-end development.

Now, to build LLVM as well as clang all I have to do is invoke make. LLVM is set up to correctly do parallel builds, so I’ll pass the number of CPUs I have in my machine via make -j 4.

[/Projects/LLVM/build]% make -j 4
# lots of logging

That’s it! LLVM is now (hopefully) successfully built. All of the pieces are in the build directory under Debug/bin and Debug/lib and so on; see the LLVM web site for details about what the various components are.

Copyright canonical form

One thing that’s nagged at me lately has been the series of applications I’ve seen lately with copyright statements that appear to be from the Bizarro universe. I don’t mean that they have weird license restrictions; rather, they have a copyright statement in their standard About panel that’s formatted strangely. It’s a minor pet peeve to be sure, but it’s a simple thing to get right and getting it wrong looks silly.

Note that the following is not legal advice on asserting or protecting your copyright — you’ll have to go to a lawyer for that — it’s just a suggestion on how to concisely format your statement that your work is covered under copyright.

In a Cocoa application, the standard About panel will show the copyright statement specified under the NSHumanReadableCopyright of its Info.plist file. This should generally be of the form

> Copyright © «YEARS» «HOLDERS». All rights reserved.

where «YEARS» represents the individual year, set of years, or range of years during which the application was authored and «HOLDERS» represent the authors of the application.

Thus if I were to start writing an application in 2007 and finish it in 2008, I would put

> Copyright © 2007–2008 Chris Hanson. All rights reserved.

in the NSHumanReadableCopyright key of its Info.plist file. (Yes, that’s an en-dash between the years, option-hyphen gets you one.) It wouldn’t have the year at the end, or random commas after things, or random abbreviations. Just one simple statement.

Someday I’ll figure out how to add

> Copyright © 2002–2008 Chris Hanson. All rights reserved.

to the bottom of my weblog, too. Hopefully in such a way that I can actually update it easily when the year rolls over…

CocoaHeads Silicon Valley at Apple on Thursday, Apple 17, 2008

The next CocoaHeads Silicon Valley meeting will be on Thursday, April 17, 2008 — that’s tonight! — at 7:30 in the De Anza 3 auditorium at Apple. That’s just inside the south side of De Anza 3, right across Mariani Avenue from Apple’s Infinite Loop campus in Cupertino. See the web site for directions.

This month’s presentation is all about designing and implementing your human interface. User experience and human interface design are critical for Mac OS X software to get right. To that end, there’s even going to be a UI makeover as Scott describes in his post on the meeting!

Thanks a ton to Scott Stevenson, Steve Zyszkiewicz, Michael Jurewitz and Joar Wingfors for organizing!

In general, at a CocoaHeads meeting we do some introductions, have a presentation including Q&A time with the presenter, and then have an open Q&A and demo-your-cool-app period. After the meeting there’s more independent mingling and discussion until it’s time to go at 9:30. Often a subset of the meeting moves to BJ’s Brewhouse in Cupertino, which is right in front of the Apple Infinite Loop campus on De Anza Boulevard.

NeXTstation Color: Free to good (local) home

I have a complete 25MHz NeXTstation Color that I want to get rid of to a good home — in other words, you should want to use in some capacity as a NeXT workstation, not make its case into art or something. This isn’t some crappy PC of which there are millions with tiny variations among them, it’s a workstation of which only a relatively small number were made.


  • NeXTstation Color
  • 17-inch NeXT Color Display
  • 16MB RAM
  • 400MB SCSI HD
  • NeXT Keyboard (non-ADB)
  • NeXT Mouse (non-ADB)
  • NeXT Sound Box
  • Appropriate cabling.

It worked the last time I turned it on, which was probably 2003. It’s been in a box in my closet — the box the movers put it in when I moved out here four years ago. I don’t see why it wouldn’t work, but I wouldn’t guarantee it. The motherboard battery will probably need replacing, for one thing.

Want it, and reasonably local to Cupertino? Ping me and we’ll talk.

Update: The NeXTstation is claimed! Thanks for the impressive response — who knew so many people would want a workstation that’s old enough to drive?