[Git][ghc/ghc][master] hadrian: implement and use writeFileAtomic to fix race condition