Add llvm-libunwind libraries for armv7a/aarch64/x86_64 cross targets.
llvm-libunwind is required for using compiler-rt with c++ or asan.
Add it in a way that adding more llvm packages in future is easy
e.g. libcxx etc.
Also enable compiler-rt packages for aarch64.
BUG=chromium:708794
TEST=sudo cros_setup_toolchains --reconfig -t {armv7a, aarch64, x86_64}-cros-linux-gnu
installed llvm-libunwind libraries.
Change-Id: Id18c872cbdcb19b3c72e2abfffaaa5acd9cc9168
Reviewed-on: https://chromium-review.googlesource.com/476091
Commit-Ready: Manoj Gupta <manojgupta@chromium.org>
Tested-by: Manoj Gupta <manojgupta@chromium.org>
Reviewed-by: Yunlian Jiang <yunlian@chromium.org>
diff --git a/scripts/cros_setup_toolchains.py b/scripts/cros_setup_toolchains.py
index 9107421..24f8a97 100644
--- a/scripts/cros_setup_toolchains.py
+++ b/scripts/cros_setup_toolchains.py
@@ -53,6 +53,7 @@
'gdb' : PACKAGE_NONE,
'ex_go' : PACKAGE_NONE,
'ex_compiler-rt': PACKAGE_NONE,
+ 'ex_llvm-libunwind': PACKAGE_NONE,
},
}
@@ -66,9 +67,20 @@
# Enable llvm's compiler-rt for these targets.
TARGET_COMPILER_RT_ENABLED = (
'armv7a-cros-linux-gnueabi',
+ 'aarch64-cros-linux-gnu',
)
CROSSDEV_COMPILER_RT_ARGS = ['--ex-pkg', 'sys-libs/compiler-rt']
+TARGET_LLVM_PKGS_ENABLED = (
+ 'armv7a-cros-linux-gnueabi',
+ 'aarch64-cros-linux-gnu',
+ 'x86_64-cros-linux-gnu',
+)
+
+LLVM_PKGS_TABLE = {
+ 'ex_llvm-libunwind' : ['--ex-pkg', 'sys-libs/llvm-libunwind'],
+}
+
# Overrides for {gcc,binutils}-config, pick a package with particular suffix.
CONFIG_TARGET_SUFFIXES = {
'binutils' : {
@@ -130,6 +142,9 @@
cmd.extend(CROSSDEV_GO_ARGS)
if target in TARGET_COMPILER_RT_ENABLED:
cmd.extend(CROSSDEV_COMPILER_RT_ARGS)
+ if target in TARGET_LLVM_PKGS_ENABLED:
+ for pkg in LLVM_PKGS_TABLE:
+ cmd.extend(LLVM_PKGS_TABLE[pkg])
cmd.extend(['-t', target_tuple])
# Catch output of crossdev.
out = cros_build_lib.RunCommand(cmd, print_cmd=False,
@@ -188,6 +203,8 @@
cmd.extend(CROSSDEV_GO_ARGS)
elif pkg == 'ex_compiler-rt':
cmd.extend(CROSSDEV_COMPILER_RT_ARGS)
+ elif pkg in LLVM_PKGS_TABLE:
+ cmd.extend(LLVM_PKGS_TABLE[pkg])
elif pkg in cls.MANUAL_PKGS:
pass
else:
@@ -1204,6 +1221,13 @@
boards_wanted = (set(options.include_boards.split(','))
if options.include_boards else set())
+ # pylint: disable=global-statement
+ # Disable installing llvm pkgs till binary package is available
+ global TARGET_LLVM_PKGS_ENABLED
+ global TARGET_COMPILER_RT_ENABLED
+ if options.usepkg:
+ TARGET_LLVM_PKGS_ENABLED = ()
+ TARGET_COMPILER_RT_ENABLED = ('armv7a-cros-linux-gnueabi',)
if options.cfg_name:
ShowConfig(options.cfg_name)
elif options.create_packages: