[LLVMdev] n00b question: From module/bitcode to Mach-O dylib file directly?

Luke Evans luke at eversosoft.com
Sun Mar 15 15:20:28 PDT 2009


I'm a total LLVM n00b, and have just started to work through some of  
the tutorials with the intention of gathering a clear picture of what  
LLVM does and doesn't do for a possible project.

I'm on the Mac, and would like to have my code dynamically create and  
load new functions into a process.  I believe I can do this, but I'm  
not sure yet how 'direct' things will be in terms of both the tool  
chain, and how much I need to emit intermediate files.

I think I will have to ultimately dynamically load from a Mach-O dylib  
file (dopen), but in any case I'm interested in whether I can go  
straight from my in-memory linked module(s) to a Mach-O file that I  
can dynamically load, using the LLVM API as it exists at V2.5.

Before I even worry about coding this up directly, I've been playing  
with doing this the available tools to see what the various steps are  
likely to be.  From comments on this list, it looks like going from  
bitfile to a native Mach-O file ought to be possible, but I've tried  
"llc -filetype=dynlib" (and indeed -filetype=obj) and get the message  
"target does not support generation of this file type!".  BTW, I  
compiled the LLVM stuff myself, but assume it does the right thing  
w.r.t. building in appropriate knowledge of the native platform.

I can see how to generate an assembly file, then use the platform  
tools to compile and link this, but I get the impression this is  
unnecessary with the current state-of-play.

Would anyone be kind enough to provide clue?  I couldn't find any  
samples or docs that directly speak to this - probably because it's a  
minor part of the overall LLVM system.

Cheers

Luke




More information about the llvm-dev mailing list