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 = [
"source/config",
platform_include_dir,
"source/libaom",
platform_include_dir,
]
# Private configuration used in building libaom.
@ -73,6 +73,10 @@ config("libaom_config") {
# This config is applied to targets that depend on libaom.
config("libaom_public_config") {
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",
platform_include_dir,
]
@ -384,7 +388,7 @@ test("test_libaom") {
deps = [
":libaom",
"//third_party/googletest:gtest",
"//testing/gtest",
]
defines = [ "CHROMIUM" ]

View file

@ -36,6 +36,7 @@ export LC_ALL=C
BASE=$(pwd)
SRC="${BASE}/source/libaom"
CFG="${BASE}/source/config"
TMP="$(mktemp -d "${BASE}/build.XXXX")"
function cleanup() {
rm -rf "${TMP}"
@ -114,7 +115,6 @@ git -C "${SRC}" fetch --tags
# Scope 'trap' error reporting to configuration generation.
(
TMP=$(mktemp -d "${BASE}/build.XXXX")
cd "${TMP}"
trap '{
@ -186,12 +186,12 @@ gen_config_files linux/arm-neon \
reset_dirs 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}"
reset_dirs 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}"
# 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("//testing/test.gni")
import("//third_party/libvpx/libvpx_srcs.gni")
import("//third_party/libvpx/libvpx_test_srcs.gni")
import("//third_party/nasm/nasm_assemble.gni")
# Sets the architecture name for building libvpx.
@ -66,13 +67,20 @@ if (is_nacl) {
libvpx_include_dirs = [
"source/config",
platform_include_dir,
"source/libvpx",
platform_include_dir,
]
# Private configuration used in building libvpx.
config("libvpx_config") {
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
# 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.
config("libvpx_public_config") {
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",
platform_include_dir,
]
}
source_set("libvpx_test_generic_headers") {
deps = [ ":libvpx" ]
sources = libvpx_test_srcs_generic_headers
}
config("gtest_config") {
include_dirs = [
"source/libvpx/third_party/googletest/src/include/",
"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 = libvpx_include_dirs + [
"source/libvpx/third_party/libwebm/",
"source/libvpx/third_party/googletest/src/include/",
"source/libvpx/third_party/googletest/src/",
]
include_dirs = [ "source/libvpx/third_party/libwebm/" ]
testonly = true
sources = [
@ -121,7 +158,6 @@ executable("decode_encode_profile_test") {
"source/libvpx/test/test_libvpx.cc",
"source/libvpx/test/test_vectors.cc",
"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/mkvreader.cc",
"source/libvpx/tools_common.h",
@ -129,15 +165,11 @@ executable("decode_encode_profile_test") {
"source/libvpx/y4minput.c",
"tests/pgo/decode_encode_profile_test.cc",
]
deps = [ ":libvpx" ]
# 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",
]
}
deps = [
":gtest",
":libvpx",
":libvpx_test_generic_headers",
]
}
if (current_cpu == "x86" || (current_cpu == "x64" && !is_msan)) {
@ -461,10 +493,6 @@ source_set("libvpx_x86_64_headers") {
sources = libvpx_srcs_x86_64_headers
}
source_set("libvpx_loongarch_headers") {
sources = libvpx_srcs_loongarch_headers
}
source_set("libvpx_arm_headers") {
sources = libvpx_srcs_arm_headers
}
@ -493,6 +521,14 @@ source_set("libvpx_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") {
sources = libvpx_srcs_nacl_headers
}
@ -548,6 +584,7 @@ static_library("libvpx") {
}
} else if (current_cpu == "ppc64") {
sources = libvpx_srcs_ppc64
public_deps = [ ":libvpx_ppc64_headers" ]
} else if (current_cpu == "riscv64") {
sources = libvpx_srcs_generic
public_deps = [ ":libvpx_generic_headers" ]
@ -648,3 +685,30 @@ test("vp9_encoder_fuzz_test") {
"//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 os
import platform
import tempfile
import shutil
import subprocess
import sys
import urllib.request
import zipfile
from dataclasses import dataclass, field
_HEADER = '''
# Copyright 2022 The Chromium Authors
# 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",
]
}
if (current_cpu == "x86" || current_cpu == "x64") {
defines += [
"XNN_ENABLE_AVXVNNI=1",
]
}
}
'''.strip()
@ -117,6 +124,8 @@ source_set("xnnpack") {
configs += [ "//build/config/sanitizers:cfi_icall_generalize_pointers" ]
sources = [
"src/include/xnnpack.h",
"build_identifier.c",
%SRCS%
]
@ -139,6 +148,8 @@ source_set("xnnpack_standalone") {
configs += [ "//build/config/sanitizers:cfi_icall_generalize_pointers" ]
sources = [
"src/include/xnnpack.h",
"build_identifier.c",
%SRCS%
]
@ -164,6 +175,7 @@ source_set("%TARGET_NAME%") {
]
%ASMFLAGS%
sources = [
"src/include/xnnpack.h",
%SRCS%
]
@ -188,6 +200,7 @@ source_set("%TARGET_NAME%_standalone") {
]
%ASMFLAGS%
sources = [
"src/include/xnnpack.h",
%SRCS%
]
@ -481,7 +494,9 @@ def _run_bazel_cmd(args):
Runs a bazel command in the form of bazel <args...>. Returns the stdout,
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:
raise Exception(
"bazel is not installed. Please run `sudo apt-get install " +
@ -519,6 +534,10 @@ def GenerateObjectBuilds(cpu):
cpu: aarch64 or k8
"""
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)
crosstool_top = f'//{basename}:cc_suite'
logs = _run_bazel_cmd([
@ -631,17 +650,36 @@ def MakeXNNPACKDepsList(target_sss):
return deps_list
def EnsureAndroidNDK():
"""
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:
return
logging.info('Downloading a copy of the Android NDK for bazel')
resp = urllib.request.urlopen('https://dl.google.com/android/repository/android-ndk-r19c-linux-x86_64.zip')
tempdir = tempfile.mkdtemp()
zipdownload = os.path.join(tempdir, 'android-ndk-r25b-linux.zip')
extractdir = os.path.join(tempdir, 'android-ndk-r25b')
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')
zipfile.ZipFile(io.BytesIO(resp.read())).extractall(path='/tmp/')
os.environ['ANDROID_NDK_HOME'] = '/tmp/android-ndk-r19c'
subprocess.check_call(
['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):
"""
@ -654,6 +692,16 @@ def MakeXNNPACKSourceSet(ss):
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():
logging.basicConfig(level=logging.INFO)
@ -717,6 +765,8 @@ def main():
f.write('\n\n')
f.write('}\n')
GenerateBuildIdentifier()
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;
+ top -= Th24StrokeOffset;
+ //bottom -= Th24StrokeOffset;