Problems building three-stage LLVM 10.0.0 on macOS


I am working on a three stage LLVM on macOS based on LLVM 10.0.0. The
first stage is just clang, libc++ and compiler-rt built with Xcode, no

The second stage in this case is a clang that's instrumented built
with the first stage.

The third stage is a clang built with the first stage but with PGO
data from the second stage. In this version I enable LTO and

This builds clang fine - but compiler-rt fails in the lipo stage:

llvm-lipo: error:
The file was not recognized as a valid object file

This happened first with the system lipo - I thought that was because
Xcode lipo didn't understand newer bitcode for LTO so I switched to
llvm-lipo (by a symlink) but I still get the same error.

Any ideas on how to fix this except turning of LTO? Should I build
compiler-rt separately without LTO?