clang-built binary freeze with _FORTIFY_SOURCE=2

Hello,

Playing with my rebuilds of Debian, I noticed that 149 packages timeout
during the build (packages
like gcc, firefox / iceweasel, llvm, mysql).

I have been able to produce a small test case which shows the freeze.
clang++ -o conftest -g -O2 -D_FORTIFY_SOURCE=2 conftest.cpp
(note that _FORTIFY_SOURCE=2 are added by Debian & Ubuntu build systems)

--- conftest.cpp ---
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>

int main ()
{
    char *data;
    int pagesize;
    int fd, foo;
    pagesize = getpagesize ();
    fd = open ("conftest.mmap", O_RDWR);
    data = (char *) malloc (pagesize);
    foo = read (fd, data, pagesize);
}

We don't have a fix. It looks like we have all that is needed in llvm
to get most cases implemented (see comment 15). It would still be
medium sized patch for clang. A bug compatible with gcc implementation
would be fairly hard given its strange semantics (only used if
inlined, never used if function pointer is used, etc). Hopefully these
are really just bugs and a saner implementation would work for
_FORTIFY_SOURCE=2.

Cheers,
Rafael