Commit 7e545610 authored by Nico Weber's avatar Nico Weber Committed by Commit Bot

android/asan: Don't depend on llvm version number at test time.

Instead, copy the runtime to the build dir at build time and find it there
at test time.

Matches how things work on other platforms with the asan runtime in a shared
library (mac/ios/win).

This also makes things do the right thing with a custom clang_base_path.

Bug: 872278
Change-Id: I930bd88206f973c10eb47bfd2f132e70167235f4
Reviewed-on: https://chromium-review.googlesource.com/1167465Reviewed-by: default avatarHans Wennborg <hans@chromium.org>
Commit-Queue: Nico Weber <thakis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#581682}
parent b50e7239
...@@ -4,7 +4,6 @@ ...@@ -4,7 +4,6 @@
# pylint: disable=R0201 # pylint: disable=R0201
import glob
import logging import logging
import os.path import os.path
import subprocess import subprocess
...@@ -12,7 +11,8 @@ import sys ...@@ -12,7 +11,8 @@ import sys
from devil.android import device_errors from devil.android import device_errors
from devil.android.valgrind_tools import base_tool from devil.android.valgrind_tools import base_tool
from pylib.constants import DIR_SOURCE_ROOT from pylib import constants
def SetChromeTimeoutScale(device, scale): def SetChromeTimeoutScale(device, scale):
...@@ -42,17 +42,15 @@ class AddressSanitizerTool(base_tool.BaseTool): ...@@ -42,17 +42,15 @@ class AddressSanitizerTool(base_tool.BaseTool):
@classmethod @classmethod
def CopyFiles(cls, device): def CopyFiles(cls, device):
"""Copies ASan tools to the device.""" """Copies ASan tools to the device."""
libs = glob.glob(os.path.join(DIR_SOURCE_ROOT, # build/config/sanitizers/BUILD.gn puts the runtime in the build dir.
'third_party/llvm-build/Release+Asserts/', lib = os.path.join(constants.GetOutDirectory(),
'lib/clang/*/lib/linux/', 'libclang_rt.asan-arm-android.so')
'libclang_rt.asan-arm-android.so'))
assert len(libs) == 1
subprocess.call( subprocess.call(
[os.path.join( [os.path.join(
DIR_SOURCE_ROOT, constants.DIR_SOURCE_ROOT,
'tools/android/asan/third_party/asan_device_setup.sh'), 'tools/android/asan/third_party/asan_device_setup.sh'),
'--device', str(device), '--device', str(device),
'--lib', libs[0], '--lib', lib,
'--extra-options', AddressSanitizerTool.EXTRA_OPTIONS]) '--extra-options', AddressSanitizerTool.EXTRA_OPTIONS])
device.WaitUntilFullyBooted() device.WaitUntilFullyBooted()
......
...@@ -45,7 +45,7 @@ group("deps") { ...@@ -45,7 +45,7 @@ group("deps") {
# ASAN is supported on iOS but the runtime library depends on the compiler # ASAN is supported on iOS but the runtime library depends on the compiler
# used (Chromium version of clang versus Xcode version of clang). Only copy # used (Chromium version of clang versus Xcode version of clang). Only copy
# the ASAN runtime on iOS if building with Chromium clang. # the ASAN runtime on iOS if building with Chromium clang.
if (is_win || is_mac || (is_ios && !use_xcode_clang)) { if (is_android || is_mac || is_win || (is_ios && !use_xcode_clang)) {
data_deps = [ data_deps = [
":copy_asan_runtime", ":copy_asan_runtime",
] ]
...@@ -58,8 +58,13 @@ group("deps") { ...@@ -58,8 +58,13 @@ group("deps") {
} }
} }
if ((is_mac || is_win || (is_ios && !use_xcode_clang)) && using_sanitizer) { if ((is_android || is_mac || is_win || (is_ios && !use_xcode_clang)) &&
if (is_mac) { using_sanitizer) {
if (is_android) {
# All asan bots currently use 32-bit arm.
# If you change this, also change build/android/pylib/valgrind_tools.py.
_clang_rt_dso_path = "linux/libclang_rt.asan-arm-android.so"
} else if (is_mac) {
_clang_rt_dso_path = "darwin/libclang_rt.asan_osx_dynamic.dylib" _clang_rt_dso_path = "darwin/libclang_rt.asan_osx_dynamic.dylib"
} else if (is_ios) { } else if (is_ios) {
_clang_rt_dso_path = "darwin/libclang_rt.asan_iossim_dynamic.dylib" _clang_rt_dso_path = "darwin/libclang_rt.asan_iossim_dynamic.dylib"
...@@ -74,9 +79,14 @@ if ((is_mac || is_win || (is_ios && !use_xcode_clang)) && using_sanitizer) { ...@@ -74,9 +79,14 @@ if ((is_mac || is_win || (is_ios && !use_xcode_clang)) && using_sanitizer) {
if (!is_ios) { if (!is_ios) {
copy("copy_asan_runtime") { copy("copy_asan_runtime") {
# The android runtime path contains "linux", which by default gets
# filtered out. Temporarily deactivate the filename filter.
set_sources_assignment_filter([])
sources = [ sources = [
_clang_rt_dso_full_path, _clang_rt_dso_full_path,
] ]
set_sources_assignment_filter(sources_assignment_filter)
outputs = [ outputs = [
"$root_out_dir/{{source_file_part}}", "$root_out_dir/{{source_file_part}}",
] ]
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment