forked from mirrors/gecko-dev
Before clang 16, the libunwind install only contained the libunwind.a library. Since clang 16, however, it also contains header files, including a unwind.h file that conflicts with the unwind.h file that is also shipped alongside compiler-rt. When building clang itself with compiler-rt and libunwind (i.e. not building everything separately like we do), however, that's not a problem because it puts libunwind in a different directory than compiler-rt. So we change the clang repacking to follow a similar convention. But because clang doesn't look for libraries under clang/lib/$arch, but looks under clang/lib/$target instead, we also need to enable per-target directories for libunwind. But because clang also looks for libraries under clang/lib/$exact_target rather than clang/lib/$relaxed_target (in Android's case, exact_target might be aarch64-unknown-linux-android21, relaxed_target aarch64-unknown-linux-android), we patch clang to apply the same kind of fallbacks it does for runtimes for clang/lib. Differential Revision: https://phabricator.services.mozilla.com/D173363
52 lines
1.5 KiB
Bash
Executable file
52 lines
1.5 KiB
Bash
Executable file
#!/bin/bash
|
|
set -x -e -v
|
|
|
|
shopt -s nullglob
|
|
|
|
# This script is for repacking clang for cross targets on a Linux host.
|
|
|
|
cd $MOZ_FETCHES_DIR
|
|
|
|
# We have a clang toolchain in $MOZ_FETCHES_DIR/clang
|
|
# We have some compiler-rts in $MOZ_FETCHES_DIR/compiler-rt*
|
|
# We have some libunwinds in $MOZ_FETCHES_DIR/libunwind*
|
|
# We copy everything from the compiler-rts into clang/lib/clang/$version/
|
|
# and everything from the libunwinds into clang/
|
|
clang_ver_dir=$(echo clang/lib/clang/*/include)
|
|
clang_ver_dir=${clang_ver_dir%/include}
|
|
[ -n "$clang_ver_dir" ] && for c in compiler-rt* libunwind*; do
|
|
case $c in
|
|
compiler-rt*)
|
|
clang_dir=$clang_ver_dir
|
|
;;
|
|
libunwind*)
|
|
clang_dir=clang
|
|
;;
|
|
esac
|
|
find $c -mindepth 1 -type d | while read d; do
|
|
mkdir -p "$clang_dir/${d#$c/}"
|
|
find $d -mindepth 1 -maxdepth 1 -not -type d | while read f; do
|
|
target_file="$clang_dir/${f#$c/}"
|
|
case $d in
|
|
compiler-rt-*/lib/darwin)
|
|
if [ -f "$target_file" ]; then
|
|
# Unify overlapping files for darwin/
|
|
$MOZ_FETCHES_DIR/cctools/bin/lipo -create "$f" "$target_file" -output "$target_file.new"
|
|
mv "$target_file.new" "$target_file"
|
|
continue
|
|
fi
|
|
;;
|
|
esac
|
|
if [ -f "$target_file" ] && ! diff -q "$f" "$target_file" 2>/dev/null; then
|
|
echo "Cannot copy $f because it is already in ${target_file%/*}" >&2 && exit 1
|
|
fi
|
|
cp "$f" "$target_file"
|
|
done
|
|
done
|
|
done
|
|
|
|
if [ -n "$UPLOAD_DIR" ]; then
|
|
tar caf clang.tar.zst clang
|
|
mkdir -p $UPLOAD_DIR
|
|
mv clang.tar.zst $UPLOAD_DIR
|
|
fi
|