1#!/bin/bash 2set -x -e -v 3 4# This script is for building clang for macOS targets on a Linux host, 5# including native macOS Compiler-RT libraries. 6 7cd $MOZ_FETCHES_DIR 8 9# We have a native linux64 toolchain in $MOZ_FETCHES_DIR/clang 10# We have a native aarch64 macos compiler-rt in $MOZ_FETCHES_DIR/aarch64/compiler-rt 11# We have a native x86_64 macos compiler-rt in $MOZ_FETCHES_DIR/x86_64/compiler-rt 12clang_lib=$(echo clang/lib/clang/*/lib) 13mkdir -p $clang_lib/darwin 14find {aarch64,x86_64}/compiler-rt/lib/darwin -type f -printf '%f\n' | sort -u | while read f; do 15 f=compiler-rt/lib/darwin/$f 16 if [ -f aarch64/$f -a -f x86_64/$f ]; then 17 # For compiler-rt files that exist on both ends, merge them 18 $MOZ_FETCHES_DIR/cctools/bin/lipo -create {aarch64,x86_64}/$f -output $clang_lib/darwin/${f##*/} 19 elif [ -f aarch64/$f ]; then 20 # For compiler-rt files that exist on either end, copy the existing one 21 cp aarch64/$f $clang_lib/darwin 22 else 23 cp x86_64/$f $clang_lib/darwin 24 fi 25done 26 27tar caf clang.tar.zst clang 28 29mkdir -p $UPLOAD_DIR 30mv clang.tar.zst $UPLOAD_DIR 31