[LLVMdev] Representing the dependencies of a bitcode module
Talin
viridia at gmail.com
Mon Apr 28 20:21:15 PDT 2008
I've been using SCons as the build tool for my frontend application, and
I'm getting to the point where it would be useful to create a custom
scanner for my generated bitcode files so that SCons can do proper
dependency analysis. At the moment, SCons has no way to know which
source files a particular bitcode file depends on, so the only way to do
a "correct" build is to rebuild everything. Mostly I've been getting by
with doing "incorrect" builds, meaning that I only build the files that
actually changed. However, this has tripped me up one or two times and
I'd like to solve it.
SCons has the ability to write custom scanners in Python, but I'm
thinking that it will be easier in the long run to do this work in C++.
So the idea would be to write a command-line tool that would spit out
the list of dependencies, and then write a Python wrapper to call it
from SCons.
My code generator keeps a list of what source files were imported during
compilation, and at the moment what it does is it creates an
internal-linkage array of strings, one string per import. The
command-line tool can then load the bitcode file and read the string
array. Since the strings are internally linked, and since nothing else
in the bitcode file refers to them, they ought to be dropped during
optimization (I hope.)
However, I notice that getting access to the strings from within the
command-line tool is a little complicated, since I have to decompose the
various constant getElementPtr expressions in order to get at the actual
string. I'm wondering if there's a better way to represent this
information. Maybe using the debug API, or perhaps annotation intrinsics?
-- Talin
More information about the llvm-dev
mailing list