[LLVMdev] clang searching for many linux directories that do not exist on FreeBSD host

Eli Friedman eli.friedman at gmail.com
Thu Jul 18 18:14:56 PDT 2013

On Thu, Jul 18, 2013 at 11:04 AM, Kurt Lidl <lidl at pix.net> wrote:
> Greetings -
> I'm a user of clang (3.3), as it is the system compiler for my
> installation of FreeBSD.  (In FreeBSD 10, it will be the default
> compiler, but that's not my point.)  My system identifies itself
> as:
> FreeBSD 9.2-PRERELEASE #0: Tue Jul 16 13:00:08 EDT 2013
> lidl at nine0:/usr/obj/usr/src/sys/GENERIC
> Recently, in preparation for the upcoming 9.2 release, they
> imported the llvm 3.3 tree.  That works fine for me.
> I did notice (while looking at an unrelated problem), that
> clan looks around for a bunch of linux directories every time it
> is started.  And those directories are never going to be found,
> at least not on a FreeBSD system.
> It was suggested that I take the issue here, rather than attempting
> to fix it with a locally maintained FreeBSD patch.
> I've included my trivial test program, and the ktrace output.
> I trimmed output to be the legitimate accesses to shared libraries,
> etc that clang must make - leaving most of the extraneous accesses.
> It was easy to trace these patterns back to the file:
>         tools/clang/lib/Driver/ToolChains.cpp
> So my question is this:  Is there any easy modification to make that
> will allow clang to skip doing all this work for no gain?  It seems
> silly to me, when its being used as the system compiler, to have it
> call stat() a little over two hundred times, each time
> the compiler is started up.

It's straightforward: you just need to make toolchains::FreeBSD
inherit directly from ToolChain and implement all the methods it would
otherwise inherit from Generic_ELF (which in turn inherits from


More information about the llvm-dev mailing list