Bug 1821221 - Switch Android builds to compiler-rt + libunwind. r=firefox-build-system-reviewers,andi

Differential Revision: https://phabricator.services.mozilla.com/D172076
This commit is contained in:
Mike Hommey 2023-03-16 21:39:24 +00:00
Родитель 79403e1620
Коммит c53db6818d
8 изменённых файлов: 257 добавлений и 13 удалений

1
build/android/libgcc.a Normal file
Просмотреть файл

@ -0,0 +1 @@
INPUT(-lunwind)

Просмотреть файл

@ -8,7 +8,8 @@ AC_DEFUN([MOZ_ANDROID_NDK],
case "$target" in
*-android*|*-linuxandroid*)
dnl $extra_android_flags will be set for us by Python configure.
LDFLAGS="$extra_android_flags $LDFLAGS"
dnl $_topsrcdir/build/android is a hack for versions of rustc < 1.68
LDFLAGS="$extra_android_flags -L$_topsrcdir/build/android $LDFLAGS"
CPPFLAGS="$extra_android_flags $CPPFLAGS"
CFLAGS="-fno-short-enums $CFLAGS"
CXXFLAGS="-fno-short-enums $CXXFLAGS"

Просмотреть файл

@ -1398,22 +1398,16 @@ def compiler(
)
if host_or_target.os == "Android":
# Need at least clang 8 for support for __ANDROID_API__ and versioned
# library directories from the NDK.
if info.type == "clang" and info.version < "8.0":
# Need at least clang 13 for compiler-rt/libunwind being the default.
if info.type == "clang" and info.version < "13.0":
raise FatalCheckError(
"Only clang/llvm 8.0 or newer is supported for %s (found version %s)."
"Only clang/llvm 13.0 or newer is supported for %s (found version %s)."
% (host_or_target.alias, info.version)
)
if info.flags:
raise FatalCheckError("Unknown compiler or compiler not supported.")
# Recent clang defaults to compiler-rt, but we want libgcc for compat
# with the older NDKs we use.
if host_or_target.os == "Android":
flags.append("--rtlib=libgcc")
return namespace(
wrapper=wrapper,
compiler=compiler,

Просмотреть файл

@ -244,9 +244,13 @@ linux64-clang-15:
- linux64-cctools-port
- linux64-clang-15-raw
- android-aarch64-compiler-rt-15
- android-aarch64-libunwind-15
- android-arm-compiler-rt-15
- android-arm-libunwind-15
- android-x64-compiler-rt-15
- android-x64-libunwind-15
- android-x86-compiler-rt-15
- android-x86-libunwind-15
- linux64-aarch64-compiler-rt-15
- linux64-x64-compiler-rt-15
- linux64-x86-compiler-rt-15
@ -308,9 +312,13 @@ macosx64-clang-15:
- linux64-cctools-port
- macosx64-clang-15-raw
- android-aarch64-compiler-rt-15
- android-aarch64-libunwind-15
- android-arm-compiler-rt-15
- android-arm-libunwind-15
- android-x64-compiler-rt-15
- android-x64-libunwind-15
- android-x86-compiler-rt-15
- android-x86-libunwind-15
- linux64-aarch64-compiler-rt-15
- linux64-x64-compiler-rt-15
- linux64-x86-compiler-rt-15
@ -372,9 +380,13 @@ macosx64-aarch64-clang-15:
- linux64-cctools-port
- macosx64-aarch64-clang-15-raw
- android-aarch64-compiler-rt-15
- android-aarch64-libunwind-15
- android-arm-compiler-rt-15
- android-arm-libunwind-15
- android-x64-compiler-rt-15
- android-x64-libunwind-15
- android-x86-compiler-rt-15
- android-x86-libunwind-15
- linux64-aarch64-compiler-rt-15
- linux64-x64-compiler-rt-15
- linux64-x86-compiler-rt-15
@ -461,9 +473,13 @@ win64-clang-15:
- linux64-cctools-port
- win64-clang-15-raw
- android-aarch64-compiler-rt-15
- android-aarch64-libunwind-15
- android-arm-compiler-rt-15
- android-arm-libunwind-15
- android-x64-compiler-rt-15
- android-x64-libunwind-15
- android-x86-compiler-rt-15
- android-x86-libunwind-15
- linux64-aarch64-compiler-rt-15
- linux64-x64-compiler-rt-15
- linux64-x86-compiler-rt-15
@ -632,9 +648,13 @@ linux64-clang-trunk:
- linux64-cctools-port
- linux64-clang-trunk-raw
- android-aarch64-compiler-rt-trunk
- android-aarch64-libunwind-trunk
- android-arm-compiler-rt-trunk
- android-arm-libunwind-trunk
- android-x64-compiler-rt-trunk
- android-x64-libunwind-trunk
- android-x86-compiler-rt-trunk
- android-x86-libunwind-trunk
- linux64-aarch64-compiler-rt-trunk
- linux64-x64-compiler-rt-trunk
- linux64-x86-compiler-rt-trunk
@ -698,9 +718,13 @@ macosx64-clang-trunk:
- linux64-cctools-port
- macosx64-clang-trunk-raw
- android-aarch64-compiler-rt-trunk
- android-aarch64-libunwind-trunk
- android-arm-compiler-rt-trunk
- android-arm-libunwind-trunk
- android-x64-compiler-rt-trunk
- android-x64-libunwind-trunk
- android-x86-compiler-rt-trunk
- android-x86-libunwind-trunk
- linux64-aarch64-compiler-rt-trunk
- linux64-x64-compiler-rt-trunk
- linux64-x86-compiler-rt-trunk
@ -764,9 +788,13 @@ macosx64-aarch64-clang-trunk:
- linux64-cctools-port
- macosx64-aarch64-clang-trunk-raw
- android-aarch64-compiler-rt-trunk
- android-aarch64-libunwind-trunk
- android-arm-compiler-rt-trunk
- android-arm-libunwind-trunk
- android-x64-compiler-rt-trunk
- android-x64-libunwind-trunk
- android-x86-compiler-rt-trunk
- android-x86-libunwind-trunk
- linux64-aarch64-compiler-rt-trunk
- linux64-x64-compiler-rt-trunk
- linux64-x86-compiler-rt-trunk
@ -857,9 +885,13 @@ win64-clang-trunk:
- linux64-cctools-port
- win64-clang-trunk-raw
- android-aarch64-compiler-rt-trunk
- android-aarch64-libunwind-trunk
- android-arm-compiler-rt-trunk
- android-arm-libunwind-trunk
- android-x64-compiler-rt-trunk
- android-x64-libunwind-trunk
- android-x86-compiler-rt-trunk
- android-x86-libunwind-trunk
- linux64-aarch64-compiler-rt-trunk
- linux64-x64-compiler-rt-trunk
- linux64-x86-compiler-rt-trunk

Просмотреть файл

@ -36,6 +36,7 @@ jobs-from:
- geckodriver.yml
- gn.yml
- grcov.yml
- libunwind.yml
- llvm-symbolizer.yml
- macos-sdk.yml
- mingw.yml

Просмотреть файл

@ -0,0 +1,171 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
---
job-defaults:
worker-type: b-linux-gcp
worker:
max-run-time: 1800
run:
using: toolchain-script
script: build-libunwind.sh
android-aarch64-libunwind-15:
description: "android aarch64 libunwind for Clang 15 toolchain build"
treeherder:
symbol: TA(aarch64-unwind-15)
run:
arguments:
- build/build-clang/clang-15.json
resources:
- build/build-clang/clang-15.json
- taskcluster/scripts/misc/build-llvm-common.sh
toolchain-artifact: public/build/libunwind-aarch64-linux-android.tar.zst
fetches:
fetch:
- clang-15
toolchain:
- android-aarch64-compiler-rt-15
- linux64-clang-15-stage1
- linux64-android-ndk-linux-repack
android-arm-libunwind-15:
description: "android arm libunwind for Clang 15 toolchain build"
treeherder:
symbol: TA(arm-unwind-15)
run:
arguments:
- build/build-clang/clang-15.json
resources:
- build/build-clang/clang-15.json
- taskcluster/scripts/misc/build-llvm-common.sh
toolchain-artifact: public/build/libunwind-armv7-linux-android.tar.zst
fetches:
fetch:
- clang-15
toolchain:
- android-arm-compiler-rt-15
- linux64-clang-15-stage1
- linux64-android-ndk-linux-repack
android-x86-libunwind-15:
description: "android x86 libunwind for Clang 15 toolchain build"
treeherder:
symbol: TA(x86-unwind-15)
run:
arguments:
- build/build-clang/clang-15.json
resources:
- build/build-clang/clang-15.json
- taskcluster/scripts/misc/build-llvm-common.sh
toolchain-artifact: public/build/libunwind-i686-linux-android.tar.zst
fetches:
fetch:
- clang-15
toolchain:
- android-x86-compiler-rt-15
- linux64-clang-15-stage1
- linux64-android-ndk-linux-repack
android-x64-libunwind-15:
description: "android x64 libunwind for Clang 15 toolchain build"
treeherder:
symbol: TA(x64-unwind-15)
run:
arguments:
- build/build-clang/clang-15.json
resources:
- build/build-clang/clang-15.json
- taskcluster/scripts/misc/build-llvm-common.sh
toolchain-artifact: public/build/libunwind-x86_64-linux-android.tar.zst
fetches:
fetch:
- clang-15
toolchain:
- android-x64-compiler-rt-15
- linux64-clang-15-stage1
- linux64-android-ndk-linux-repack
android-aarch64-libunwind-trunk:
description: "android aarch64 libunwind for Clang trunk toolchain build"
attributes:
cached_task: false
treeherder:
symbol: TA(aarch64-unwind-trunk)
run:
arguments:
- build/build-clang/clang-trunk.json
resources:
- build/build-clang/clang-trunk.json
- taskcluster/scripts/misc/build-llvm-common.sh
toolchain-artifact: public/build/libunwind-aarch64-linux-android.tar.zst
fetches:
fetch:
- clang-trunk
toolchain:
- android-aarch64-compiler-rt-trunk
- linux64-clang-trunk-stage1
- linux64-android-ndk-linux-repack
android-arm-libunwind-trunk:
description: "android arm libunwind for Clang trunk toolchain build"
attributes:
cached_task: false
treeherder:
symbol: TA(arm-unwind-trunk)
run:
arguments:
- build/build-clang/clang-trunk.json
resources:
- build/build-clang/clang-trunk.json
- taskcluster/scripts/misc/build-llvm-common.sh
toolchain-artifact: public/build/libunwind-armv7-linux-android.tar.zst
fetches:
fetch:
- clang-trunk
toolchain:
- android-arm-compiler-rt-trunk
- linux64-clang-trunk-stage1
- linux64-android-ndk-linux-repack
android-x86-libunwind-trunk:
description: "android x86 libunwind for Clang trunk toolchain build"
attributes:
cached_task: false
treeherder:
symbol: TA(x86-unwind-trunk)
run:
arguments:
- build/build-clang/clang-trunk.json
resources:
- build/build-clang/clang-trunk.json
- taskcluster/scripts/misc/build-llvm-common.sh
toolchain-artifact: public/build/libunwind-i686-linux-android.tar.zst
fetches:
fetch:
- clang-trunk
toolchain:
- android-x86-compiler-rt-trunk
- linux64-clang-trunk-stage1
- linux64-android-ndk-linux-repack
android-x64-libunwind-trunk:
description: "android x64 libunwind for Clang trunk toolchain build"
attributes:
cached_task: false
treeherder:
symbol: TA(x64-unwind-trunk)
run:
arguments:
- build/build-clang/clang-trunk.json
resources:
- build/build-clang/clang-trunk.json
- taskcluster/scripts/misc/build-llvm-common.sh
toolchain-artifact: public/build/libunwind-x86_64-linux-android.tar.zst
fetches:
fetch:
- clang-trunk
toolchain:
- android-x64-compiler-rt-trunk
- linux64-clang-trunk-stage1
- linux64-android-ndk-linux-repack

Просмотреть файл

@ -0,0 +1,43 @@
#!/bin/sh
set -e -x
artifact=$(basename $TOOLCHAIN_ARTIFACT)
dir=${artifact%.tar.*}
target=${dir#libunwind-}
# Make the android compiler-rt available to clang.
env UPLOAD_DIR= $GECKO_PATH/taskcluster/scripts/misc/repack-clang.sh
case "$target" in
armv7-linux-android)
unwind_arch=arm
;;
aarch64-linux-android)
unwind_arch=aarch64
;;
i686-linux-android)
unwind_arch=i386
;;
x86_64-linux-android)
unwind_arch=x86_64
;;
*)
echo $target is not supported. >&2
exit 1
;;
esac
EXTRA_CMAKE_FLAGS="
$EXTRA_CMAKE_FLAGS
-DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=OFF
-DCMAKE_C_COMPILER_WORKS=1
-DCMAKE_CXX_COMPILER_WORKS=1
-DLLVM_ENABLE_RUNTIMES=libunwind
-DLIBUNWIND_LIBDIR_SUFFIX=/linux/$unwind_arch
-DLIBUNWIND_ENABLE_SHARED=OFF
"
export EXTRA_CMAKE_FLAGS
$(dirname $0)/build-llvm-common.sh runtimes install $target "$@"

Просмотреть файл

@ -9,14 +9,15 @@ 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
clang_dir=$(echo clang/lib/clang/*/include)
clang_dir=${clang_dir%/include}
[ -n "$clang_dir" ] && for c in compiler-rt*; do
[ -n "$clang_dir" ] && for c in compiler-rt* libunwind*; do
find $c -mindepth 1 -type d | while read d; do
mkdir -p "$clang_dir/${d#compiler-rt-*/}"
mkdir -p "$clang_dir/${d#$c/}"
find $d -mindepth 1 -maxdepth 1 -not -type d | while read f; do
target_file="$clang_dir/${f#compiler-rt-*/}"
target_file="$clang_dir/${f#$c/}"
case $d in
compiler-rt-*/lib/darwin)
if [ -f "$target_file" ]; then