[cfe-dev] Maintaining a consistant path across two clang instances

Mike Miller michael.g.miller at gmail.com
Wed Apr 21 17:48:02 PDT 2010

Hi cfe-dev,

I'm working on a distributed compiler project using clang(see
more information). One issue I am coming across is that the "master"
must have the same working directory as the client it is preprocessing for,
so that relative paths resolve correctly. My first intuition was to send the
output of getcwd on the slave to the master, and use chdir on the master to
set the appropriate working directory, before invoking the preprocessor.
However, this brings to mind two concerns:

1. The cache in the FileManager might get confused(e.g. it might cache
/u/mike/dir1/test/test.c while /u/mike/dir1 is the cwd, and attempt to
access /u/mike/dir2/test/test.c while the cwd is /u/mike/dir2).

2. Since setting the cwd would affect the whole process, it would not be
possible to preprocess multiple files simultaneously with different threads.

Are these two concerns valid? If so, how would you recommend resolving them?

Additionally, I have two more questions:

1. Is the preprocessor threadsafe? Specifically, I want to know if I can
invoke multiple, completely disjoint preprocessors on different threads,
without negative consequence.

2. Is the FileManager threadsafe? Specifically, I want to know if I can
invoke multiple preprocessors using the same FileManager without negative
consequence. If not, would you imagine it to be better to have a single
preprocessor with a very large cache, or multiple preprocessors running in
parallel with separate, disjoint, but smaller caches?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20100421/e51b34d3/attachment.html>

More information about the cfe-dev mailing list