[LLVMdev] [LLVM] What has happened to LLVM bitcode archive support?
Rafael EspĂndola
rafael.espindola at gmail.com
Fri Dec 20 13:58:13 PST 2013
> So I guess if I want mimic linking in archives built by llvm-ar that
> contain bitcode files, using code in LLVM trunk, my only choice at the
> moment is to...
>
> 1. Collect a set of undefined symbols from the destination module.
> 2. Load **all** the `llvm::Module`s in the archive into memory
> 3. Iterate over each module's GlobalValues (does the list starting
> with llvm::Module::global_begin() include the module's functions
> too??) and if a GlobalValue in a module is not a declaration and is in
> the set of undefined symbols then link that module into the
> destination module using Linker::LinkModules()
> 4. Update the set of undefined symbols
> 5. repeat 1 and 2 until a fixed point (the set of undefined symbols
> does not change) is reached.
I would suggest for now building the archive with gnu ar and the
plugin, that way you have an index and don't need to read all members.
It looks like the algorithm you want is something like
while (there are undefined symbols)
if we can find a member defining one of the undefined symbols
load it
else
print error about undefined symbol.
Cheers,
Rafael
More information about the llvm-dev
mailing list