Merge upstream commit that fixes build with LLVM on ppc64* (also affects other systems) and add patch which fixes build specifically on FreeBSD (PR currently waiting for acceptance).