mxcl/homebrew — pull request #11261 by quarnster (2012-03-28 19:15:18+00:00)
Title: Moved setting ENV['LD'] = ENV['CXX'] to after ENV.llvm is (possibly) set...

.... Otherwise ENV['LD'] might end up as llvm-gcc rather than the expected CXX version. Verified that this fixed the issue I had installing QT on my machine. Fixes issue #11202. See also #11198.

By the comment above where ENV.llvm is set, maybe it was supposed to be using clang rather than llvm-gcc though because my Xcode is 3.2.6. clang is "Apple clang version 1.7 (tags/Apple/clang-77) (based on LLVM 2.9svn)", and llvm-gcc is "i686-apple-darwin10-llvm-gcc-4.2 (GCC) 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.6)".

In any case, moving these two lines made it compile and install fine on my system.