This reapplies bb27e456 (SimpleRemoteEPC support) and 2269a941 (#include <mutex> fix) with further fixes to support building with LLVM_ENABLE_THREADS=Off.