Skip to content

Commit

Permalink
Reland "Update bots' NDK to r26b"
Browse files Browse the repository at this point in the history
This is a reland of commit 063e339

Original change's description:
> Update bots' NDK to r26b
>
> Our NDK was several years out of date, so it was missing newer APIs.
> The last time we tried an update, it caused ASAN issues on the tree:
>     https://skia-review.googlesource.com/c/skia/+/439336
>
> Like that attempt, this changes the Mac create script, because the
> NDK is now distributed as a DMG.
>
> Critically, this moves our Android bots from clang 9 (!) to 17.
>
> Change-Id: I2bc4204e63dc1d3b41b4f04bd1d2e62713fdedc9
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/793577
> Reviewed-by: Ben Wagner <[email protected]>

Change-Id: I86a0ca47d2b4daa5fc52cdf9153dd399c72a787e
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/795778
Reviewed-by: Leandro Lovisolo <[email protected]>
  • Loading branch information
brianosman authored and harry75369 committed Jul 25, 2024
1 parent 18571aa commit c752b80
Show file tree
Hide file tree
Showing 13 changed files with 94 additions and 73 deletions.
18 changes: 4 additions & 14 deletions BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -3086,23 +3086,13 @@ if (skia_enable_tools) {
}
}

if (is_android && defined(ndk) && ndk != "") {
copy("gdbserver") {
sources = [ "$ndk/$ndk_gdbserver" ]
outputs = [ "$root_out_dir/gdbserver" ]
if (is_linux || is_win || is_mac) {
test_app("editor") {
is_shared_library = is_android
deps = [ "modules/skplaintexteditor:editor_app" ]
}
}

test_app("editor") {
is_shared_library = is_android
deps = [ "modules/skplaintexteditor:editor_app" ]
}

test_app("text_editor") {
is_shared_library = is_android
deps = [ "experimental/sktext:text_editor" ]
}

skia_executable("image_diff_metric") {
sources = [ "tools/image_diff_metric.cpp" ]
deps = [ ":skia" ]
Expand Down
5 changes: 0 additions & 5 deletions gn/BUILDCONFIG.gn
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ if (!is_clang && !is_win) {
if (is_android) {
ndk_host = ""
ndk_target = ""
ndk_gdbserver = ""

if (host_os == "linux") {
ndk_host = "linux-x86_64"
Expand All @@ -117,16 +116,12 @@ if (is_android) {

if (target_cpu == "arm64") {
ndk_target = "aarch64-linux-android"
ndk_gdbserver = "prebuilt/android-arm64/gdbserver/gdbserver"
} else if (target_cpu == "arm") {
ndk_target = "armv7a-linux-androideabi"
ndk_gdbserver = "prebuilt/android-arm/gdbserver/gdbserver"
} else if (target_cpu == "x64") {
ndk_target = "x86_64-linux-android"
ndk_gdbserver = "prebuilt/android-x86_64/gdbserver/gdbserver"
} else if (target_cpu == "x86") {
ndk_target = "i686-linux-android"
ndk_gdbserver = "prebuilt/android-x86/gdbserver/gdbserver"
}
}

Expand Down
2 changes: 1 addition & 1 deletion infra/bots/assets/android_ndk_darwin/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
10
12
54 changes: 45 additions & 9 deletions infra/bots/assets/android_ndk_darwin/create.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,61 @@


import argparse
import glob
import os.path
import os
import platform
import shutil
import subprocess
import sys


NDK_VER = "android-ndk-r21d"
NDK_VER = "android-ndk-r26b"
NDK_URL = \
"https://dl.google.com/android/repository/%s-darwin-x86_64.zip" % NDK_VER
"https://dl.google.com/android/repository/%s-darwin.dmg" % NDK_VER
DMG = "ndk.dmg"
MOUNTED_NAME_START = '/Volumes/Android NDK'

def find_ndk(volume):
"""Find the NDK within the mounted volume."""
for f in os.listdir(volume):
if f.endswith('.app'):
return os.path.join(volume, f, 'Contents/NDK')

def create_asset(target_dir):
"""Create the asset."""
subprocess.check_call(["curl", NDK_URL, "-o", "ndk.zip"])
subprocess.check_call(["unzip", "ndk.zip", "-d", target_dir])
for f in glob.glob(os.path.join(target_dir, NDK_VER, "*")):
shutil.move(f, target_dir)
subprocess.check_call(["rm", "ndk.zip"])
if platform.system() != 'Darwin':
print("This script can only be run on a Mac!")
sys.exit(1)

subprocess.check_call(["curl", NDK_URL, "-o", DMG])
output = subprocess.check_output(['hdiutil', 'attach', DMG])

# hdiutil mounted the DMG somewhere - find where it was mounted.
lines = output.decode('utf-8').split('\n')
found = False
for line in lines:
words = line.split('\t')
if len(words) == 3:
if words[2].startswith(MOUNTED_NAME_START):
found = True

# copytree (in python2, and by default in python3) requires that the
# dst does not exist. Remove it so that is the case.
if os.path.isdir(target_dir):
os.rmdir(target_dir)

shutil.copytree(find_ndk(words[2]), target_dir)

# Unmount the volume, now that we're done with it.
subprocess.check_call(['hdiutil', 'detach', words[0].strip()])

subprocess.check_call(["rm", DMG])
break

if not found:
print("Could not find mount point! Output from hdiutil attach:")
for line in lines:
print(line)
sys.exit(2)

def main():
parser = argparse.ArgumentParser()
Expand Down
2 changes: 1 addition & 1 deletion infra/bots/assets/android_ndk_linux/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
16
18
4 changes: 2 additions & 2 deletions infra/bots/assets/android_ndk_linux/create.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
import subprocess


NDK_VER = "android-ndk-r21d"
NDK_VER = "android-ndk-r26b"
NDK_URL = \
"https://dl.google.com/android/repository/%s-linux-x86_64.zip" % NDK_VER
"https://dl.google.com/android/repository/%s-linux.zip" % NDK_VER


def create_asset(target_dir):
Expand Down
2 changes: 1 addition & 1 deletion infra/bots/assets/android_ndk_windows/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
11
13
4 changes: 2 additions & 2 deletions infra/bots/assets/android_ndk_windows/create.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
import subprocess


NDK_VER = "android-ndk-r21d"
NDK_VER = "android-ndk-r26b"
NDK_URL = \
"https://dl.google.com/android/repository/%s-windows-x86_64.zip" % NDK_VER
"https://dl.google.com/android/repository/%s-windows.zip" % NDK_VER


def create_asset(target_dir):
Expand Down
2 changes: 1 addition & 1 deletion infra/bots/gen_tasks_logic/gen_tasks_logic.go
Original file line number Diff line number Diff line change
Expand Up @@ -1572,7 +1572,7 @@ func (b *jobBuilder) codesize() {
if strings.Contains(compileTaskName, "Android") {
b.asset("android_ndk_linux")
cmd = append(cmd, "--strip_binary",
"android_ndk_linux/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-strip")
"android_ndk_linux/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-strip")
} else {
b.asset("binutils_linux_x64")
cmd = append(cmd, "--strip_binary", "binutils_linux_x64/strip")
Expand Down
2 changes: 1 addition & 1 deletion infra/bots/recipe_modules/flavor/android.py
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ def wait_for_device(attempt):
def _asan_setup_path(self):
return self.m.vars.workdir.join(
'android_ndk_linux', 'toolchains', 'llvm', 'prebuilt', 'linux-x86_64',
'lib64', 'clang', '9.0.8', 'bin', 'asan_device_setup')
'lib', 'clang', '17', 'bin', 'asan_device_setup')


def install(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@
"python",
"\nimport os\nimport subprocess\nimport sys\nimport time\nADB = sys.argv[1]\nASAN_SETUP = sys.argv[2]\n\ndef wait_for_device():\n while True:\n time.sleep(5)\n print('Waiting for device')\n subprocess.check_call([ADB, 'wait-for-device'])\n bit1 = subprocess.check_output([ADB, 'shell', 'getprop',\n 'dev.bootcomplete']).decode('utf-8')\n bit2 = subprocess.check_output([ADB, 'shell', 'getprop',\n 'sys.boot_completed']).decode('utf-8')\n if '1' in bit1 and '1' in bit2:\n print('Device detected')\n break\n\nlog = subprocess.check_output([ADB, 'root']).decode('utf-8')\n# check for message like 'adbd cannot run as root in production builds'\nprint(log)\nif 'cannot' in log:\n raise Exception('adb root failed')\n\noutput = subprocess.check_output([ADB, 'disable-verity']).decode('utf-8')\nprint(output)\n\nif 'already disabled' not in output:\n print('Rebooting device')\n subprocess.check_call([ADB, 'reboot'])\n wait_for_device()\n\ndef installASAN(revert=False):\n # ASAN setup script is idempotent, either it installs it or\n # says it's installed. Returns True on success, false otherwise.\n out = subprocess.check_output([ADB, 'wait-for-device']).decode('utf-8')\n print(out)\n cmd = [ASAN_SETUP]\n if revert:\n cmd = [ASAN_SETUP, '--revert']\n process = subprocess.Popen(cmd, env={'ADB': ADB},\n stdout=subprocess.PIPE, stderr=subprocess.PIPE)\n\n # this also blocks until command finishes\n (stdout, stderr) = process.communicate()\n print(stdout.decode('utf-8'))\n print('Stderr: %s' % stderr.decode('utf-8'))\n return process.returncode == 0\n\nif not installASAN():\n print('Trying to revert the ASAN install and then re-install')\n # ASAN script sometimes has issues if it was interrupted or partially applied\n # Try reverting it, then re-enabling it\n if not installASAN(revert=True):\n raise Exception('reverting ASAN install failed')\n\n # Sleep because device does not reboot instantly\n time.sleep(10)\n\n if not installASAN():\n raise Exception('Tried twice to setup ASAN and failed.')\n\n# Sleep because device does not reboot instantly\ntime.sleep(10)\nwait_for_device()\n# Sleep again to hopefully avoid error \"secure_mkdirs failed: No such file or\n# directory\" when pushing resources to the device.\ntime.sleep(60)\n",
"/opt/infra-android/tools/adb",
"[START_DIR]/android_ndk_linux/toolchains/llvm/prebuilt/linux-x86_64/lib64/clang/9.0.8/bin/asan_device_setup"
"[START_DIR]/android_ndk_linux/toolchains/llvm/prebuilt/linux-x86_64/lib/clang/17/bin/asan_device_setup"
],
"env": {
"CHROME_HEADLESS": "1",
Expand Down Expand Up @@ -1507,7 +1507,7 @@
},
{
"cmd": [
"[START_DIR]/android_ndk_linux/toolchains/llvm/prebuilt/linux-x86_64/lib64/clang/9.0.8/bin/asan_device_setup",
"[START_DIR]/android_ndk_linux/toolchains/llvm/prebuilt/linux-x86_64/lib/clang/17/bin/asan_device_setup",
"--revert"
],
"env": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
"python",
"\nimport os\nimport subprocess\nimport sys\nimport time\nADB = sys.argv[1]\nASAN_SETUP = sys.argv[2]\n\ndef wait_for_device():\n while True:\n time.sleep(5)\n print('Waiting for device')\n subprocess.check_call([ADB, 'wait-for-device'])\n bit1 = subprocess.check_output([ADB, 'shell', 'getprop',\n 'dev.bootcomplete']).decode('utf-8')\n bit2 = subprocess.check_output([ADB, 'shell', 'getprop',\n 'sys.boot_completed']).decode('utf-8')\n if '1' in bit1 and '1' in bit2:\n print('Device detected')\n break\n\nlog = subprocess.check_output([ADB, 'root']).decode('utf-8')\n# check for message like 'adbd cannot run as root in production builds'\nprint(log)\nif 'cannot' in log:\n raise Exception('adb root failed')\n\noutput = subprocess.check_output([ADB, 'disable-verity']).decode('utf-8')\nprint(output)\n\nif 'already disabled' not in output:\n print('Rebooting device')\n subprocess.check_call([ADB, 'reboot'])\n wait_for_device()\n\ndef installASAN(revert=False):\n # ASAN setup script is idempotent, either it installs it or\n # says it's installed. Returns True on success, false otherwise.\n out = subprocess.check_output([ADB, 'wait-for-device']).decode('utf-8')\n print(out)\n cmd = [ASAN_SETUP]\n if revert:\n cmd = [ASAN_SETUP, '--revert']\n process = subprocess.Popen(cmd, env={'ADB': ADB},\n stdout=subprocess.PIPE, stderr=subprocess.PIPE)\n\n # this also blocks until command finishes\n (stdout, stderr) = process.communicate()\n print(stdout.decode('utf-8'))\n print('Stderr: %s' % stderr.decode('utf-8'))\n return process.returncode == 0\n\nif not installASAN():\n print('Trying to revert the ASAN install and then re-install')\n # ASAN script sometimes has issues if it was interrupted or partially applied\n # Try reverting it, then re-enabling it\n if not installASAN(revert=True):\n raise Exception('reverting ASAN install failed')\n\n # Sleep because device does not reboot instantly\n time.sleep(10)\n\n if not installASAN():\n raise Exception('Tried twice to setup ASAN and failed.')\n\n# Sleep because device does not reboot instantly\ntime.sleep(10)\nwait_for_device()\n# Sleep again to hopefully avoid error \"secure_mkdirs failed: No such file or\n# directory\" when pushing resources to the device.\ntime.sleep(60)\n",
"/usr/bin/adb.1.0.35",
"[START_DIR]/android_ndk_linux/toolchains/llvm/prebuilt/linux-x86_64/lib64/clang/9.0.8/bin/asan_device_setup"
"[START_DIR]/android_ndk_linux/toolchains/llvm/prebuilt/linux-x86_64/lib/clang/17/bin/asan_device_setup"
],
"env": {
"CHROME_HEADLESS": "1",
Expand Down Expand Up @@ -1283,7 +1283,7 @@
},
{
"cmd": [
"[START_DIR]/android_ndk_linux/toolchains/llvm/prebuilt/linux-x86_64/lib64/clang/9.0.8/bin/asan_device_setup",
"[START_DIR]/android_ndk_linux/toolchains/llvm/prebuilt/linux-x86_64/lib/clang/17/bin/asan_device_setup",
"--revert"
],
"env": {
Expand Down
Loading

0 comments on commit c752b80

Please sign in to comment.