[LLVMdev] Getting started (Windows)

Adrian Boeing aboeing at gmail.com
Sat May 30 00:09:18 PDT 2009


Hi,

I'm just trying to get started with a simple example with LLVM under
windows. I downloaded the mingw binaries from the website and would
like to compile a program. (PS: The mingw binaries did not come with
any documentation on what they are and how to use them)

I used the online code generator (http://llvm.org/demo/index.cgi) to
compile hello world:
#include <stdio.h>
int main() {
  printf("hello world\n");
  return 0;
}

Copied it's output
; ModuleID = '/tmp/webcompile/_3997_0.bc'
target datalayout =
"e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:32:32"
target triple = "i386-pc-linux-gnu"
@.str = internal constant [12 x i8] c"hello world\00"		; <[12 x i8]*> [#uses=1]

define i32 @main() nounwind {
entry:
	%0 = tail call i32 @puts(i8* getelementptr ([12 x i8]* @.str, i32 0,
i32 0)) nounwind		; <i32> [#uses=0]
	ret i32 0
}

declare i32 @puts(i8*)

into a bc file, and tried to run it with lli, but I get this error:

"lli: error loading program 'hello.bc': Bitcode stream should be a multiple of 4
bytes in length"

(I'm guessing I also need to change the 'target' type to something
non-linux...?)

How can I get LLVM to compile, assemble, link and generate a simple exe?

Thanks.



More information about the llvm-dev mailing list