Skip to content

Commit

Permalink
Bug 1821221 - Switch Android builds to compiler-rt + libunwind. r=fir…
Browse files Browse the repository at this point in the history
…efox-build-system-reviewers,andi

Differential Revision: https://phabricator.services.mozilla.com/D172076
  • Loading branch information
glandium committed Mar 21, 2023
1 parent f72b442 commit 405ec47
Show file tree
Hide file tree
Showing 9 changed files with 258 additions and 13 deletions.
1 change: 1 addition & 0 deletions build/android/libgcc.a
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
INPUT(-lunwind)
3 changes: 2 additions & 1 deletion build/autoconf/android.m4
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
12 changes: 3 additions & 9 deletions build/moz.configure/toolchain.configure
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
32 changes: 32 additions & 0 deletions taskcluster/ci/toolchain/clang.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions taskcluster/ci/toolchain/kind.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ jobs-from:
- geckodriver.yml
- gn.yml
- grcov.yml
- libunwind.yml
- llvm-symbolizer.yml
- macos-sdk.yml
- mingw.yml
Expand Down
171 changes: 171 additions & 0 deletions taskcluster/ci/toolchain/libunwind.yml
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions taskcluster/scripts/misc/build-compiler-rt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ case "$target" in
EXTRA_CMAKE_FLAGS="
-DCOMPILER_RT_BUILD_LIBFUZZER=OFF
-DCOMPILER_RT_BUILD_ORC=OFF
-DCOMPILER_RT_BUILTINS_HIDE_SYMBOLS=OFF
"
;;
*-apple-darwin)
Expand Down
43 changes: 43 additions & 0 deletions taskcluster/scripts/misc/build-libunwind.sh
Original file line number Diff line number Diff line change
@@ -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 "$@"
Loading

0 comments on commit 405ec47

Please sign in to comment.