strace clang refers files from lib/tls/x86_64 multiple times


Sample program:

int main(int argc, char **argv)


int myLocal=0xAA;

return 0;


Command: clang t.c –o a.o –c

With above simple program we are observing that clang is stat-ing and trying to open various files from lib/tls location. Eventually all calls to “lib/tls” leads to ENOENT (No such file or directory)!


open(“path/lib/tls/x86_64/”, O_RDONLY) = -1 ENOENT (No such file or directory)

open(“path/lib/tls/”, O_RDONLY) = -1 ENOENT (No such file or directory)


The same behavior is not observed with GCC. With gcc we could build above sample program under 30 seconds while it takes more than 100 seconds when using clang!!!

Any pointer on how to reduce unnecessary stat/open is appreciated.

My local installation paths are…




In above installation path we don’t have “tls” directory.

In this regards I have following questions…

  • We are not seeing present of “tls” directory under “somepath/llvm-3.7.1/{bin,lib}” – is anything missing in our installation?

  • Why clang refers to “lib/tls”?

  • Why clang refers to “lib/x86_64” ? And why not just using “lib/”

Thank you in advance for your help.



Are you saying that these “find something in a directory that doesn’t exist” steps are taking a majority of the difference between 30 and 100 seconds? That does seem very unlikely to me, as stat in Linux/Unix is a fairly well optimised function, and a lot of caching is done to ensure that it doesn’t take much time.

I’m not sure what the difference is, and nor what project you are working on, but I doubt the searching through various paths for shared libraries is the big problem.


Are you sure your situation isn’t similar to this:

$ which gcc
$ which clang

In other words, your gcc uses ccache, but clang doesn’t?

That can indeed make a BIG difference in compile-time.