Copied from what the llvm-shlib build is doing. This reverts commit 0b1b567d9f84e67124c58d69b5aa375357d68c9e.