fix arm builds

This commit is contained in:
Alexander Frick 2024-10-19 13:58:22 -05:00
parent 15f86ca239
commit 738449abe0
6 changed files with 517 additions and 66 deletions

View file

@ -61,8 +61,8 @@ if (is_nacl) {
libaom_include_dirs = [ libaom_include_dirs = [
"source/config", "source/config",
platform_include_dir,
"source/libaom", "source/libaom",
platform_include_dir,
] ]
# Private configuration used in building libaom. # Private configuration used in building libaom.
@ -73,6 +73,10 @@ config("libaom_config") {
# This config is applied to targets that depend on libaom. # This config is applied to targets that depend on libaom.
config("libaom_public_config") { config("libaom_public_config") {
include_dirs = [ include_dirs = [
# libaom_public_config does not have "source/config" (which gives access to
# the private header config/aom_version.h) because code outside the libaom
# library should use the aom_codec_version*() functions and macros declared
# in the public header aom_codec.h.
"source/libaom", "source/libaom",
platform_include_dir, platform_include_dir,
] ]
@ -384,7 +388,7 @@ test("test_libaom") {
deps = [ deps = [
":libaom", ":libaom",
"//third_party/googletest:gtest", "//testing/gtest",
] ]
defines = [ "CHROMIUM" ] defines = [ "CHROMIUM" ]

View file

@ -36,6 +36,7 @@ export LC_ALL=C
BASE=$(pwd) BASE=$(pwd)
SRC="${BASE}/source/libaom" SRC="${BASE}/source/libaom"
CFG="${BASE}/source/config" CFG="${BASE}/source/config"
TMP="$(mktemp -d "${BASE}/build.XXXX")"
function cleanup() { function cleanup() {
rm -rf "${TMP}" rm -rf "${TMP}"
@ -114,7 +115,6 @@ git -C "${SRC}" fetch --tags
# Scope 'trap' error reporting to configuration generation. # Scope 'trap' error reporting to configuration generation.
( (
TMP=$(mktemp -d "${BASE}/build.XXXX")
cd "${TMP}" cd "${TMP}"
trap '{ trap '{
@ -186,12 +186,12 @@ gen_config_files linux/arm-neon \
reset_dirs linux/arm-neon-cpu-detect reset_dirs linux/arm-neon-cpu-detect
gen_config_files linux/arm-neon-cpu-detect \ gen_config_files linux/arm-neon-cpu-detect \
"${toolchain}/armv7-linux-gcc.cmake -DCONFIG_RUNTIME_CPU_DETECT=1 -DENABLE_ARM_CRC32=0 -DENABLE_NEON_DOTPROD=0 -DENABLE_NEON_I8MM=0 \ "${toolchain}/armv7-linux-gcc.cmake -DENABLE_ARM_CRC32=0 -DENABLE_NEON_DOTPROD=0 -DENABLE_NEON_I8MM=0 \
${all_platforms}" ${all_platforms}"
reset_dirs linux/arm64-cpu-detect reset_dirs linux/arm64-cpu-detect
gen_config_files linux/arm64-cpu-detect \ gen_config_files linux/arm64-cpu-detect \
"${toolchain}/arm64-linux-gcc.cmake -DCONFIG_RUNTIME_CPU_DETECT=1 -DENABLE_ARM_CRC32=0 -DENABLE_NEON_DOTPROD=0 -DENABLE_NEON_I8MM=0 \ "${toolchain}/arm64-linux-gcc.cmake -DENABLE_ARM_CRC32=0 -DENABLE_NEON_DOTPROD=0 -DENABLE_NEON_I8MM=0 \
${all_platforms}" ${all_platforms}"
# Copy linux configurations and modify for Windows. # Copy linux configurations and modify for Windows.

View file

@ -7,6 +7,7 @@ import("//build/config/arm.gni")
import("//build/config/chromeos/ui_mode.gni") import("//build/config/chromeos/ui_mode.gni")
import("//testing/test.gni") import("//testing/test.gni")
import("//third_party/libvpx/libvpx_srcs.gni") import("//third_party/libvpx/libvpx_srcs.gni")
import("//third_party/libvpx/libvpx_test_srcs.gni")
import("//third_party/nasm/nasm_assemble.gni") import("//third_party/nasm/nasm_assemble.gni")
# Sets the architecture name for building libvpx. # Sets the architecture name for building libvpx.
@ -66,13 +67,20 @@ if (is_nacl) {
libvpx_include_dirs = [ libvpx_include_dirs = [
"source/config", "source/config",
platform_include_dir,
"source/libvpx", "source/libvpx",
platform_include_dir,
] ]
# Private configuration used in building libvpx. # Private configuration used in building libvpx.
config("libvpx_config") { config("libvpx_config") {
include_dirs = libvpx_include_dirs include_dirs = libvpx_include_dirs
defines = [
"CHROMIUM",
# Maximum allowed for a direct mapping,
# see partition_alloc::internal::MaxDirectMapped()
"VPX_MAX_ALLOCABLE_MEMORY=((1ULL << 31) - (1 << 21))",
]
# gn orders flags on a target before flags from configs. The default config # gn orders flags on a target before flags from configs. The default config
# adds -Wall, and these flags have to be after -Wall -- so they need to come # adds -Wall, and these flags have to be after -Wall -- so they need to come
@ -99,19 +107,48 @@ config("libvpx_config") {
# This config is applied to targets that depend on libvpx. # This config is applied to targets that depend on libvpx.
config("libvpx_public_config") { config("libvpx_public_config") {
include_dirs = [ include_dirs = [
# libvpx_public_config does not have "source/config" (which gives access to
# the private header vpx_version.h) because code outside the libvpx library
# should use the vpx_codec_version*() functions and macros declared in the
# public header vpx_codec.h.
"source/libvpx", "source/libvpx",
platform_include_dir, platform_include_dir,
] ]
} }
executable("decode_encode_profile_test") { source_set("libvpx_test_generic_headers") {
configs -= [ "//build/config/compiler:chromium_code" ] deps = [ ":libvpx" ]
configs += [ "//build/config/compiler:no_chromium_code" ] sources = libvpx_test_srcs_generic_headers
include_dirs = libvpx_include_dirs + [ }
"source/libvpx/third_party/libwebm/",
config("gtest_config") {
include_dirs = [
"source/libvpx/third_party/googletest/src/include/", "source/libvpx/third_party/googletest/src/include/",
"source/libvpx/third_party/googletest/src/", "source/libvpx/third_party/googletest/src/",
] ]
}
source_set("gtest") {
sources = [ "source/libvpx/third_party/googletest/src/src/gtest-all.cc" ]
configs -= [ "//build/config/compiler:chromium_code" ]
configs += [ "//build/config/compiler:no_chromium_code" ]
public_configs = [ ":gtest_config" ]
# gtest-death-test dependency on fdio for fuchsia builds
if (is_fuchsia) {
deps = [
"//third_party/fuchsia-sdk/sdk/pkg/fdio",
"//third_party/fuchsia-sdk/sdk/pkg/zx",
]
}
}
executable("decode_encode_profile_test") {
configs -= [ "//build/config/compiler:chromium_code" ]
configs += [ "//build/config/compiler:no_chromium_code" ]
include_dirs = [ "source/libvpx/third_party/libwebm/" ]
testonly = true testonly = true
sources = [ sources = [
@ -121,7 +158,6 @@ executable("decode_encode_profile_test") {
"source/libvpx/test/test_libvpx.cc", "source/libvpx/test/test_libvpx.cc",
"source/libvpx/test/test_vectors.cc", "source/libvpx/test/test_vectors.cc",
"source/libvpx/test/test_vectors.h", "source/libvpx/test/test_vectors.h",
"source/libvpx/third_party/googletest/src/src/gtest-all.cc",
"source/libvpx/third_party/libwebm/mkvparser/mkvparser.cc", "source/libvpx/third_party/libwebm/mkvparser/mkvparser.cc",
"source/libvpx/third_party/libwebm/mkvparser/mkvreader.cc", "source/libvpx/third_party/libwebm/mkvparser/mkvreader.cc",
"source/libvpx/tools_common.h", "source/libvpx/tools_common.h",
@ -129,16 +165,12 @@ executable("decode_encode_profile_test") {
"source/libvpx/y4minput.c", "source/libvpx/y4minput.c",
"tests/pgo/decode_encode_profile_test.cc", "tests/pgo/decode_encode_profile_test.cc",
] ]
deps = [ ":libvpx" ] deps = [
":gtest",
# gtest-death-test dependency on fdio for fuchsia builds ":libvpx",
if (is_fuchsia) { ":libvpx_test_generic_headers",
deps += [
"//third_party/fuchsia-sdk/sdk/pkg/fdio",
"//third_party/fuchsia-sdk/sdk/pkg/zx",
] ]
} }
}
if (current_cpu == "x86" || (current_cpu == "x64" && !is_msan)) { if (current_cpu == "x86" || (current_cpu == "x64" && !is_msan)) {
nasm_assemble("libvpx_asm") { nasm_assemble("libvpx_asm") {
@ -461,10 +493,6 @@ source_set("libvpx_x86_64_headers") {
sources = libvpx_srcs_x86_64_headers sources = libvpx_srcs_x86_64_headers
} }
source_set("libvpx_loongarch_headers") {
sources = libvpx_srcs_loongarch_headers
}
source_set("libvpx_arm_headers") { source_set("libvpx_arm_headers") {
sources = libvpx_srcs_arm_headers sources = libvpx_srcs_arm_headers
} }
@ -493,6 +521,14 @@ source_set("libvpx_mips_headers") {
sources = libvpx_srcs_mips_headers sources = libvpx_srcs_mips_headers
} }
source_set("libvpx_loongarch_headers") {
sources = libvpx_srcs_loongarch_headers
}
source_set("libvpx_ppc64_headers") {
sources = libvpx_srcs_ppc64_headers
}
source_set("libvpx_nacl_headers") { source_set("libvpx_nacl_headers") {
sources = libvpx_srcs_nacl_headers sources = libvpx_srcs_nacl_headers
} }
@ -548,6 +584,7 @@ static_library("libvpx") {
} }
} else if (current_cpu == "ppc64") { } else if (current_cpu == "ppc64") {
sources = libvpx_srcs_ppc64 sources = libvpx_srcs_ppc64
public_deps = [ ":libvpx_ppc64_headers" ]
} else if (current_cpu == "riscv64") { } else if (current_cpu == "riscv64") {
sources = libvpx_srcs_generic sources = libvpx_srcs_generic
public_deps = [ ":libvpx_generic_headers" ] public_deps = [ ":libvpx_generic_headers" ]
@ -648,3 +685,30 @@ test("vp9_encoder_fuzz_test") {
"//third_party/fuzztest:fuzztest_gtest_main", "//third_party/fuzztest:fuzztest_gtest_main",
] ]
} }
test("test_libvpx") {
sources = libvpx_test_srcs_generic
sources += libvpx_test_srcs_generic_cc
include_dirs = [ "source/libvpx/third_party/libwebm/" ]
deps = [
":gtest",
":libvpx",
":libvpx_test_generic_headers",
]
if (is_android) {
use_raw_android_executable = true
defines = [ "LIBVPX_TEST_DATA_PATH=/data/local/tmp/chromium_tests_root/third_party/libvpx/testdata" ]
data = [ "testdata/" ]
} else {
defines = [ string_join("",
[
"LIBVPX_TEST_DATA_PATH=",
rebase_path("testdata", root_build_dir),
]) ]
}
configs -= [ "//build/config/compiler:chromium_code" ]
configs += [ "//build/config/compiler:no_chromium_code" ]

File diff suppressed because it is too large Load diff

View file

@ -41,14 +41,15 @@ import json
import logging import logging
import os import os
import platform import platform
import tempfile
import shutil import shutil
import subprocess import subprocess
import sys import sys
import urllib.request import urllib.request
import zipfile
from dataclasses import dataclass, field from dataclasses import dataclass, field
_HEADER = ''' _HEADER = '''
# Copyright 2022 The Chromium Authors # Copyright 2022 The Chromium Authors
# Use of this source code is governed by a BSD-style license that can be # Use of this source code is governed by a BSD-style license that can be
@ -105,6 +106,12 @@ config("xnnpack_config") {
"XNN_ENABLE_ARM_I8MM=1", "XNN_ENABLE_ARM_I8MM=1",
] ]
} }
if (current_cpu == "x86" || current_cpu == "x64") {
defines += [
"XNN_ENABLE_AVXVNNI=1",
]
}
} }
'''.strip() '''.strip()
@ -117,6 +124,8 @@ source_set("xnnpack") {
configs += [ "//build/config/sanitizers:cfi_icall_generalize_pointers" ] configs += [ "//build/config/sanitizers:cfi_icall_generalize_pointers" ]
sources = [ sources = [
"src/include/xnnpack.h",
"build_identifier.c",
%SRCS% %SRCS%
] ]
@ -139,6 +148,8 @@ source_set("xnnpack_standalone") {
configs += [ "//build/config/sanitizers:cfi_icall_generalize_pointers" ] configs += [ "//build/config/sanitizers:cfi_icall_generalize_pointers" ]
sources = [ sources = [
"src/include/xnnpack.h",
"build_identifier.c",
%SRCS% %SRCS%
] ]
@ -164,6 +175,7 @@ source_set("%TARGET_NAME%") {
] ]
%ASMFLAGS% %ASMFLAGS%
sources = [ sources = [
"src/include/xnnpack.h",
%SRCS% %SRCS%
] ]
@ -188,6 +200,7 @@ source_set("%TARGET_NAME%_standalone") {
] ]
%ASMFLAGS% %ASMFLAGS%
sources = [ sources = [
"src/include/xnnpack.h",
%SRCS% %SRCS%
] ]
@ -481,7 +494,9 @@ def _run_bazel_cmd(args):
Runs a bazel command in the form of bazel <args...>. Returns the stdout, Runs a bazel command in the form of bazel <args...>. Returns the stdout,
raising an Exception if the command failed. raising an Exception if the command failed.
""" """
exec_path = shutil.which("bazel")
# Use standard Bazel install instead of the one included with depot_tools.
exec_path = "/usr/bin/bazel"
if not exec_path: if not exec_path:
raise Exception( raise Exception(
"bazel is not installed. Please run `sudo apt-get install " + "bazel is not installed. Please run `sudo apt-get install " +
@ -519,6 +534,10 @@ def GenerateObjectBuilds(cpu):
cpu: aarch64 or k8 cpu: aarch64 or k8
""" """
logging.info(f'Querying xnnpack compile commands for {cpu} with bazel...') logging.info(f'Querying xnnpack compile commands for {cpu} with bazel...')
# Make sure we have a clean start, this is important if the Android NDK
# version changed.
_run_bazel_cmd(['clean'])
basename = os.path.basename(_TOOLCHAIN_DIR) basename = os.path.basename(_TOOLCHAIN_DIR)
crosstool_top = f'//{basename}:cc_suite' crosstool_top = f'//{basename}:cc_suite'
logs = _run_bazel_cmd([ logs = _run_bazel_cmd([
@ -631,17 +650,36 @@ def MakeXNNPACKDepsList(target_sss):
return deps_list return deps_list
def EnsureAndroidNDK(): def EnsureAndroidNDK():
""" """
Ensures that the Android NDK is available and bazel can find it later. Ensures that the Android NDK is available and bazel can find it later.
This must use command line utilities instead of native Python as a workaround
for https://github.com/python/cpython/issues/59999.
""" """
if 'ANDROID_NDK_HOME' in os.environ: tempdir = tempfile.mkdtemp()
return zipdownload = os.path.join(tempdir, 'android-ndk-r25b-linux.zip')
logging.info('Downloading a copy of the Android NDK for bazel') extractdir = os.path.join(tempdir, 'android-ndk-r25b')
resp = urllib.request.urlopen('https://dl.google.com/android/repository/android-ndk-r19c-linux-x86_64.zip') logging.info('Downloading a copy of the Android NDK')
subprocess.check_call(
[
'curl',
'https://dl.google.com/android/repository/android-ndk-r25b-linux.zip',
'-o',
zipdownload,
],
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL,
)
logging.info('Unpacking the Android NDK') logging.info('Unpacking the Android NDK')
zipfile.ZipFile(io.BytesIO(resp.read())).extractall(path='/tmp/') subprocess.check_call(
os.environ['ANDROID_NDK_HOME'] = '/tmp/android-ndk-r19c' ['unzip', zipdownload, '-d', extractdir],
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL,
)
os.environ['ANDROID_NDK_HOME'] = os.path.join(extractdir, 'android-ndk-r25b')
def MakeXNNPACKSourceSet(ss): def MakeXNNPACKSourceSet(ss):
""" """
@ -654,6 +692,16 @@ def MakeXNNPACKSourceSet(ss):
return target return target
# Generates the `build_identifier.c` using bazel and copies to the correct directory.
def GenerateBuildIdentifier():
_run_bazel_cmd(['build', 'generate_build_identifier'])
bazel_bin_dir =_run_bazel_cmd(['info', 'bazel-bin']).strip()
build_identifier_src = os.path.join(bazel_bin_dir, 'src', 'build_identifier.c')
assert os.path.exists(build_identifier_src)
build_identifier_dst = os.path.join(_xnnpack_dir(), 'build_identifier.c')
logging.info(f'Copying {build_identifier_src} to {build_identifier_dst}')
shutil.copyfile(build_identifier_src, build_identifier_dst)
def main(): def main():
logging.basicConfig(level=logging.INFO) logging.basicConfig(level=logging.INFO)
@ -717,6 +765,8 @@ def main():
f.write('\n\n') f.write('\n\n')
f.write('}\n') f.write('}\n')
GenerateBuildIdentifier()
logging.info('Done! Please run `git cl format`') logging.info('Done! Please run `git cl format`')

View file

@ -1329,7 +1329,7 @@ index 65676013fece9..8041d18f35745 100644
} }
} }
+ if (features::IsThorium2024()) { + if (features::IsThorium2024() && !is_win) {
+ constexpr int Th24StrokeOffset = 1; + constexpr int Th24StrokeOffset = 1;
+ top -= Th24StrokeOffset; + top -= Th24StrokeOffset;
+ //bottom -= Th24StrokeOffset; + //bottom -= Th24StrokeOffset;