clang on WinXP + MinGW

I'm having a horrible time trying to get clang to work on Windows. I'm
on WinXP and have installed the latest version of MinGW
http://voxel.dl.sourceforge.net/project/mingw/Installer/mingw-get-inst/mingw-get-inst-20111118/mingw-get-inst-20111118.exe

Are there any prebuilt binaries of clang 3.0 or 3.1 that work with WinXP?

I tried downloading from

but Windows complains that they're not valid executables (presumably
win64).

Then I tried downloading the 2.9 prebuilt binaries from
LLVM Download Page and the C compiler with no
options seems to work OK:

--- begin file test.cpp ---
#include <stdio.h>

int main(int argc, char **argv)
{
  printf("hi there\n");
  return 0;
}
--- end file test.cpp ---

but when I go to emit LLVM output, I get this error:

C:\appl\llvm\2.9\clang\bin>clang -I c:\appl\mingw\20111118\include test.cpp

C:\appl\llvm\2.9\clang\bin>clang -I c:\appl\mingw\20111118\include
test.cpp -emit-llvm
clang: error:
      'i386-pc-mingw32':
      unable
      to
      pass
      LLVM
      bit-code
      files
      to
      linker

How do I fix this? There's nothing I could find online that describes
what to do about this error; I don't know which environment variables
I need to set up propertly, if any.

--Jason

Never mind, I figured out how to use -emit-llvm properly. Would be
nice if the error message for -emit-llvm said something to the effect
of "this is just supposed to be used with the compiler and the -S
flag, not the linker."

C:\tmp\llvm>clang -S -emit-llvm -I c:\appl\mingw\20111118\include test.cpp

C:\tmp\llvm>type test.s
; ModuleID = 'test.cpp'
target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f
2:32:32-f64:64:64-f80:128:128-v64:64:64-v128:128:128-a0:0:64-f80:32:32-n8:16:32

target triple = "i386-pc-mingw32"

@.str = private unnamed_addr constant [10 x i8] c"hi there\0A\00"

define i32 @main(i32 %argc, i8** %argv) nounwind {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i8**, align 4
  store i32 0, i32* %1
  store i32 %argc, i32* %2, align 4
  store i8** %argv, i8*** %3, align 4
  %4 = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([10 x i8]* @.st
, i32 0, i32 0))
  ret i32 0
}

declare i32 @printf(i8*, ...) nounwind

This error happens because you are telling clang to compile, link, and produce an executable, but you are also telling it to emit LLVM bitcode. These two options are incompatible. If you want bitcode, you should add -c. If you want LLVM assembly, you should use -S. If you want a binary, then you should not use -emit-llvm.

David