This restores d0649a6ad8be778abf7569f502148d577f8bc6f1 (reverted in commit 03bf59d275a16815dc5a2e3f279815554f7cd0ca), with fixes for bot failures. Confirmed that gcc, which reproduced both failures, now builds it fine. Differential Revision: https://reviews.llvm.org/D140949