I tried doing a stage3 build on SystemZ/s390 but ran into the unfortunate problem that LLD does not support SystemZ, so the stage3 build can't use LLD and also can't use LTO.
Implementing the logic to only use LTO/LLD on non-SystemZ system inside the 3-stage-base.cmake was not possible however since none of the variables to check are set at that point. According to https://cmake.org/cmake/help/latest/manual/cmake.1.html#options, a cache file passed to cmake -C should consist of set() calls to populate the cache.
I'm not sure if the previous if (APPLE) check worked on apple systems at all. I'm also not sure if setting any of the BOOTSTRAP_ variables inside a non-cache cmake file should happen at all.
I did test this patch on x86_64, s390, ppc64le and aarch64, but I'm not sure if SystemZ/s390 is the only problematic architecture and if there is a better way of checking whether we're on a non-lld-supported arch.
Anyway, happy to hear comments on this patch. Thanks!