ldmd2 requires -lpthread and -lcurses, too.

This is a change to the LLVM CMake files from LLVM 3.5.
Cache result of DtoFunctionType.