Building Swift compiler as a universal binary on macOS

Hi folks, how can I build the compiler (and all the binaries/libraries) as a universal binary?

I tried forcefully overriding CMAKE_OSX_ARCHITECTURES to accept x86_64;arm64, but getting an error enable_language: multiple values for CMAKE_OSX_ARCHITECTURES not supported with Swift .
I considered compiling for x86 and cross-compiling for arm64 (or vice versa) and them merging things, but cannot see such options for the build-script. It also feels like a hack workaround, but that's a different story :smile:

Any hints are highly appreciated :raised_hands:

To cross-compile Swift on macOS the following worked for me:

# build for the host (macosx-x86_64)
$ ./swift/utils/build-script
# cross-compile for the target (macosx-arm64)
$ ./swift/utils/build-script --cross-compile-hosts=macosx-arm64

You should see the following under the build folder:

$ ls -1 build/Ninja-DebugAssert
cmark-macosx-arm64
cmark-macosx-x86_64
earlyswiftdriver-macosx-x86_64
llvm-macosx-arm64
llvm-macosx-x86_64
swift-macosx-arm64
swift-macosx-x86_64