osx - How to generate executable from LLVM IR -


i reading http://www.stephendiehl.com/llvm/#llvm-introduction there piece of llvm ir this:

declare i32 @putchar(i32)  define i32 @add(i32 %a, i32 %b) {   %1 = add i32 %a, %b   ret i32 %1 }  define void @main() {   %1 = call i32 @add(i32 0, i32 97)   call i32 @putchar(i32 %1)   ret void } 

i wanted try running using llvm , nasm failed:

llc -march=x86-64 h1.bc -o h1.s nasm -f macho -o h1.o h1.s # failed here 

first lines of errors are:

h1.s:1: error: attempt define local label before non-local labels h1.s:1: error: parser: instruction expected h1.s:2: error: attempt define local label before non-local labels h1.s:2: error: parser: instruction expected h1.s:3: error: attempt define local label before non-local labels h1.s:3: error: parser: instruction expected h1.s:4: error: attempt define local label before non-local labels 

the code generated llc not seem native os x assembly code described @ http://peter.michaux.ca/articles/assembly-hello-world-for-os-x

what's right commands generate executable?

nasm not support at&t assembly syntax hence error. on os x need use "as" assemble (and forget nasm in 99% cases except when explicitly requested)


Comments

Popular posts from this blog

c++ - Delete matches in OpenCV (Keypoints and descriptors) -

java - Could not locate OpenAL library -

sorting - opencl Bitonic sort with 64 bits keys -