diff --git a/other/AVX2/third_party/ffmpeg/chromium/scripts/build_ffmpeg.py b/other/AVX2/third_party/ffmpeg/chromium/scripts/build_ffmpeg.py deleted file mode 100755 index a1f444b1..00000000 --- a/other/AVX2/third_party/ffmpeg/chromium/scripts/build_ffmpeg.py +++ /dev/null @@ -1,1080 +0,0 @@ -#!/usr/bin/env python3 -# -# Copyright 2023 The Chromium Authors, Alex313031, and Midzer. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -from __future__ import print_function - -import atexit -import collections -import functools -import glob -import optparse -import os -import platform -import re -import shlex -import shutil -import signal -import subprocess -import sys -import tempfile - -SCRIPTS_DIR = os.path.abspath(os.path.dirname(__file__)) -FFMPEG_DIR = os.path.abspath(os.path.join(SCRIPTS_DIR, '..', '..')) -CHROMIUM_ROOT_DIR = os.path.abspath(os.path.join(FFMPEG_DIR, '..', '..')) -NDK_ROOT_DIR = os.path.abspath( - os.path.join(CHROMIUM_ROOT_DIR, 'third_party', 'android_ndk')) -SUCCESS_TOKEN = 'THIS_BUILD_WORKED' - -sys.path.append(os.path.join(CHROMIUM_ROOT_DIR, 'build')) -import gn_helpers - -BRANDINGS = [ - 'Chrome', - 'ChromeOS', - 'Chromium', -] - -ARCH_MAP = { - 'android': ['ia32', 'x64', 'arm-neon', 'arm64'], - 'linux': [ - 'ia32', 'x64', 'noasm-x64', 'arm', 'arm-neon', 'arm64' - ], - 'mac': ['x64', 'arm64'], - 'win': ['ia32', 'x64', 'arm64'], -} - -USAGE_BEGIN = """Usage: %prog TARGET_OS TARGET_ARCH [options] -- [configure_args]""" -USAGE_END = """ -Valid combinations are android [%(android)s] - linux [%(linux)s] - mac [%(mac)s] - win [%(win)s] - -If no target architecture is specified all will be built. - -Platform specific build notes: - android: - Script can be run on a normal x64 Ubuntu box with an Android-ready Chromium - checkout: https://chromium.googlesource.com/chromium/src/+/master/docs/android_build_instructions.md - - linux ia32/x64: - Script can run on a normal Ubuntu box. - - linux arm/arm-neon/arm64/mipsel/mips64el: - Script can run on a normal Ubuntu with ARM/ARM64 or MIPS32/MIPS64 ready Chromium checkout: - build/linux/sysroot_scripts/install-sysroot.py --arch=arm - build/linux/sysroot_scripts/install-sysroot.py --arch=arm64 - build/linux/sysroot_scripts/install-sysroot.py --arch=mips - build/linux/sysroot_scripts/install-sysroot.py --arch=mips64el - - mac: - Script must be run on Linux or macOS. Additionally, ensure the Chromium - (not Apple) version of clang is in the path; usually found under - src/third_party/llvm-build/Release+Asserts/bin - - The arm64 version has to be built with an SDK that can build mac/arm64 - binaries -- currently Xcode 12 beta and its included 11.0 SDK. You must - pass --enable-cross-compile to be able to build ffmpeg for mac/arm64 on an - Intel Mac. On a Mac, run like so: - PATH=$PWD/../../third_party/llvm-build/Release+Asserts/bin:$PATH \ - SDKROOT=/Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.0.sdk \ - chromium/scripts/build_ffmpeg.py mac arm64 -- --enable-cross-compile - - On Linux, the normal robosushi flow will work for arm64. - - win: - Script may be run unders Linux or Windows; if cross-compiling you will need - to follow the Chromium instruction for Cross-compiling Chrome/win: - https://chromium.googlesource.com/chromium/src/+/master/docs/win_cross.md - - Once you have a working Chromium build that can cross-compile, you'll also - need to run $chrome_dir/tools/clang/scripts/update.py --package=objdump to - pick up the llvm-ar and llvm-nm tools. You can then build as normal. - - If not cross-compiling, script must be run on Windows with VS2015 or higher - under Cygwin (or MinGW, but as of 1.0.11, it has serious performance issues - with make which makes building take hours). - - Additionally, ensure you have the correct toolchain environment for building. - The x86 toolchain environment is required for ia32 builds and the x64 one - for x64 builds. This can be verified by running "cl.exe" and checking if - the version string ends with "for x64" or "for x86." - - Building on Windows also requires some additional Cygwin packages plus a - wrapper script for converting Cygwin paths to DOS paths. - - Add these packages at install time: diffutils, nasm, make, python. - - Copy chromium/scripts/cygwin-wrapper to /usr/local/bin - -Resulting binaries will be placed in: - build.TARGET_ARCH.TARGET_OS/Chrome/ - build.TARGET_ARCH.TARGET_OS/ChromeOS/ - build.TARGET_ARCH.TARGET_OS/Chromium/ - """ - - -def PrintAndCheckCall(argv, *args, **kwargs): - print('Running %s' % '\n '.join(argv)) - subprocess.check_call(argv, *args, **kwargs) - - -def DetermineHostOsAndArch(): - if platform.system() == 'Linux': - host_os = 'linux' - elif platform.system() == 'Darwin': - host_os = 'mac' - elif platform.system() == 'Windows' or 'CYGWIN_NT' in platform.system(): - host_os = 'win' - else: - return None - - if re.match(r'i.86', platform.machine()): - host_arch = 'ia32' - elif platform.machine() == 'x86_64' or platform.machine() == 'AMD64': - host_arch = 'x64' - elif platform.machine() == 'aarch64': - host_arch = 'arm64' - elif platform.machine() == 'mips32': - host_arch = 'mipsel' - elif platform.machine() == 'mips64': - host_arch = 'mips64el' - elif platform.machine().startswith('arm'): - host_arch = 'arm' - else: - return None - - return (host_os, host_arch) - - -def GetDsoName(target_os, dso_name, dso_version): - if target_os in ('linux', 'linux-noasm', 'android'): - return 'lib%s.so.%s' % (dso_name, dso_version) - elif target_os == 'mac': - return 'lib%s.%s.dylib' % (dso_name, dso_version) - elif target_os == 'win': - return '%s-%s.dll' % (dso_name, dso_version) - else: - raise ValueError('Unexpected target_os %s' % target_os) - - -def RewriteFile(path, search_replace): - with open(path) as f: - contents = f.read() - with open(path, 'w') as f: - for search, replace in search_replace: - contents = re.sub(search, replace, contents) - f.write(contents) - - -# Class for determining the 32-bit and 64-bit Android API levels that Chromium -# uses. Since @functools.cache is not available for easy memoization of the -# determination result, we use a lazy singleton instance constructed by calling -# Get(). -class AndroidApiLevels: - __instance = None - - # Extracts the Android API levels from the Chromium Android GN config. - # Before Q1 2021, these were grep'able from build/config/android/config.gni. - # With conditional logic introduced in that gni file, we seek to avoid fragility - # going forwards, at the cost of creating a full temporary GN Chromium Android - # build configuration just to extract the API levels here. Caches the results - # in api32 and api64 instance variables. - def Setup(self): - print('Creating a temporary GN config to retrieve Android API levels:') - - # Make a temporary GN build output folder - # No tempfile.TemporaryDirectory until python 3.2, so instead: - tmp_dir = tempfile.mkdtemp(prefix = 'android_build_ffmpeg_for_api_level_config') - print('Created temporary directory ' + tmp_dir) - - # Populate that GN build output folder with generated config for Android as - # target OS. - with open(os.path.join(tmp_dir, 'args.gn'), 'w') as args_gn_file: - args_gn_file.write('target_os = "android"\n') - print('Created ' + os.path.realpath(args_gn_file.name)) - - # Ask GN to generate build files. - PrintAndCheckCall(['gn', 'gen', tmp_dir], cwd=CHROMIUM_ROOT_DIR) - - # Query the API levels in the generated build config. - print('Retrieving config vars') - config_output = subprocess.check_output( - ['gn', 'args', tmp_dir, '--short', '--list'], - cwd=CHROMIUM_ROOT_DIR).decode('utf-8') - - # Remove the temporary GN build output folder - print('removing temp dir ' + tmp_dir) - shutil.rmtree(tmp_dir, ignore_errors=False) - - api64_match = re.search(r'android64_ndk_api_level\s*=\s*(\d{2})', - config_output) - api32_match = re.search(r'android32_ndk_api_level\s*=\s*(\d{2})', - config_output) - if not api32_match or not api64_match: - raise Exception('Failed to find the android api levels') - - self.api32 = api32_match.group(1) - self.api64 = api64_match.group(1) - - def ApiLevels(self): - return (self.api32, self.api64) - - @classmethod - def Get(cls): - if cls.__instance is None: - cls.__instance = AndroidApiLevels() - cls.__instance.Setup() - return cls.__instance.ApiLevels() - - -# Sets up cross-compilation (specific to host being linux-x64_64) for compiling -# Android. -# Returns the necessary configure flags as a list. -# See also https://developer.android.com/ndk/guides/other_build_systems -# As of M90, //third_party/android_ndk no longer includes mipsel or mips64el -# toolchains; they were not previously supported by default by this script, and -# currently are unsupported due to lack of toolchain in checkout. -def SetupAndroidToolchain(target_arch): - api_level, api64_level = AndroidApiLevels.Get() - print('Determined Android API levels: 32bit=' + api_level + - ', 64bit=' + api64_level) - - # Toolchain prefix misery, for when just one pattern is not enough :/ - toolchain_level = api_level - toolchain_bin_prefix = target_arch - - if target_arch == 'arm-neon' or target_arch == 'arm': - toolchain_bin_prefix = 'arm-linux-androideabi' - elif target_arch == 'arm64': - toolchain_level = api64_level - toolchain_bin_prefix = 'aarch64-linux-android' - elif target_arch == 'ia32': - toolchain_bin_prefix = 'i686-linux-android' - elif target_arch == 'x64': - toolchain_level = api64_level - toolchain_bin_prefix = 'x86_64-linux-android' - elif target_arch == 'mipsel': # Unsupported beginning in M90 - toolchain_bin_prefix = 'mipsel-linux-android' - elif target_arch == 'mips64el': # Unsupported beginning in M90 - toolchain_level = api64_level - toolchain_bin_prefix = 'mips64el-linux-android' - - clang_toolchain_dir = NDK_ROOT_DIR + '/toolchains/llvm/prebuilt/linux-x86_64/' - - # Big old nasty hack here, beware! The new android ndk has some foolery with - # libgcc.a -- clang still uses gcc for its linker when cross compiling. - # It can't just be that simple though - the |libgcc.a| file is actually a - # super secret linkerscript which links libgcc_real.a, because apparently - # someone decided that more flags are needed, including -lunwind; thats where - # our story begins. ffmpeg doesn't use linunwind, and we dont really have a - # good way to get a cross-compiled version anyway, but this silly linker - # script insists that we must link with it, or face all sorts of horrible - # consequences -- namely configure failures. Anyway, there is a way around it: - # the "big old nasty hack" mentioned what feels like forever ago now. It's - # simple, we uhh, kill tha batman. Actually we just make a fake libunwind.a - # linker script and drop it someplace nobody will ever find, like I dunno, say - # /tmp/fakelinkerscripts or something. Then we add that path to the ldflags - # flags and everything works again. - fakedir = '/tmp/fakelinkerscripts' - os.system('mkdir -p {fakedir} && touch {fakedir}/libunwind.a'.format( - fakedir=fakedir)) - - return [ - '--enable-pic', - '--cc=' + clang_toolchain_dir + 'bin/clang', - '--cxx=' + clang_toolchain_dir + 'bin/clang++', - '--ld=' + clang_toolchain_dir + 'bin/clang', - '--enable-cross-compile', - '--sysroot=' + clang_toolchain_dir + 'sysroot', - '--extra-cflags=-I' + clang_toolchain_dir + 'sysroot/usr/include', - '--extra-cflags=-I' + clang_toolchain_dir + 'sysroot/usr/include/' + - toolchain_bin_prefix, - '--extra-cflags=--target=' + toolchain_bin_prefix + toolchain_level, - '--extra-ldflags=--target=' + toolchain_bin_prefix + toolchain_level, - '--extra-ldflags=-L{}'.format(fakedir), - '--extra-ldflags=-L' + clang_toolchain_dir + toolchain_bin_prefix, - '--extra-ldflags=--gcc-toolchain=' + clang_toolchain_dir, - '--target-os=android', - ] - - -def SetupWindowsCrossCompileToolchain(target_arch): - # First retrieve various MSVC and Windows SDK paths. - output = subprocess.check_output([ - os.path.join(CHROMIUM_ROOT_DIR, 'build', 'vs_toolchain.py'), - 'get_toolchain_dir' - ]).decode('utf-8') - - new_args = [ - '--enable-cross-compile', - '--cc=clang-cl', - '--ld=lld-link', - '--nm=llvm-nm', - '--ar=llvm-ar', - - # Separate from optflags because configure strips it from msvc builds... - '--extra-cflags=-O3', - ] - - if target_arch == 'ia32': - new_args += ['--extra-cflags=-m32'] - if target_arch == 'ia32': - target_arch = 'x86' - if target_arch == 'arm64': - new_args += [ - # With ASM enabled, an ARCH must be specified. - '--arch=aarch64', - # When cross-compiling (from Linux), armasm64.exe is not available. - '--as=clang-cl', - # FFMPEG is not yet enlightened for ARM64 Windows. - # Imitate Android workaround. - '--extra-cflags=--target=arm64-windows' - ] - - # Turn this into a dictionary. - win_dirs = gn_helpers.FromGNArgs(output) - - # Use those paths with a second script which will tell us the proper lib paths - # to specify for ldflags. - output = subprocess.check_output([ - 'python3', - os.path.join(CHROMIUM_ROOT_DIR, 'build', 'toolchain', 'win', - 'setup_toolchain.py'), win_dirs['vs_path'], - win_dirs['sdk_path'], win_dirs['runtime_dirs'], 'win', target_arch, 'none' - ]).decode('utf-8') - - flags = gn_helpers.FromGNArgs(output) - - # Q1 2021 update to LLVM now lets us use a sysroot for cross-compilation - # targeting Windows, instead of specificying a variety of individual include - # folders which now include whitespace within paths within the SDK. Either - # injection of such paths into environment variable or using the new sysroot - # option is required, since using a /tmp symlink solution to avoid the spaces - # broke cross-compilation for win-arm64. For at least now, we'll use the - # sysroot approach, until and unless the environment variable injection - # approach is determined to be better or more consistent. - new_args += [ - '--extra-cflags=/winsysroot' + win_dirs['vs_path'], - '--extra-ldflags=/winsysroot:' + win_dirs['vs_path'], - ] - - # FFmpeg configure doesn't like arguments with spaces in them even if quoted - # or double-quoted or escape-quoted (whole argument and/or the internal - # spaces). To automate this for now, every path that has a space in it is - # replaced with a symbolic link created in the OS' temp folder to the real - # path. - def do_remove_temp_link(temp_name): - assert os.path.exists(temp_name) - assert os.path.islink(temp_name) - print('Removing temporary link ' + temp_name) - os.remove(temp_name) - - def do_make_temp_link(real_target): - temp_file = tempfile.NamedTemporaryFile(prefix='windows_build_ffmpeg') - temp_name = temp_file.name - # Destroy |temp_file|, but reuse its name for the symbolic link which - # survives this helper method. - temp_file.close() - os.symlink(real_target, temp_name) - assert os.path.exists(temp_name) - assert os.path.islink(temp_name) - atexit.register(do_remove_temp_link, temp_name) - return temp_name - - return new_args - - -def SetupMacCrossCompileToolchain(target_arch): - # First compute the various SDK paths. - mac_min_ver = '10.10' - developer_dir = os.path.join(CHROMIUM_ROOT_DIR, 'build', 'mac_files', - 'xcode_binaries', 'Contents', 'Developer') - sdk_dir = os.path.join(developer_dir, 'Platforms', 'MacOSX.platform', - 'Developer', 'SDKs', 'MacOSX.sdk') - - if target_arch == 'x64': - target_triple = 'x86_64-apple-macosx' - elif target_arch == 'arm64': - target_triple = 'arm64-apple-macosx' - else: - raise Exception("unknown arch " + target_arch) - - # We're guessing about the right sdk path, so warn if we don't find it. - if not os.path.exists(sdk_dir): - print (sdk_dir) - raise Exception("Can't find the mac sdk. Please see crbug.com/841826") - - frameworks_dir = os.path.join(sdk_dir, "System", "Library", "Frameworks") - libs_dir = os.path.join(sdk_dir, "usr", "lib") - - new_args = [ - '--enable-cross-compile', - '--cc=clang', - # This is replaced with fake_linker.py further down. We need a real linker - # at configure time for a few configure checks. These checks only link - # very basic programs, so it's ok to use ld64.lld, even though it's not - # generally production quality. - '--ld=ld64.lld', - '--nm=llvm-nm', - '--ar=llvm-ar', - '--target-os=darwin', - - '--extra-cflags=--target=' + target_triple, - '--extra-cflags=-F' + frameworks_dir, - '--extra-cflags=-mmacosx-version-min=' + mac_min_ver - ] - - # We need to pass -nostdinc so that clang does not pick up linux headers, - # but then it also can't find its own headers like stddef.h. So tell it - # where to look for those headers. - clang_dir = glob.glob(os.path.join(CHROMIUM_ROOT_DIR, 'third_party', - 'llvm-build', 'Release+Asserts', 'lib', 'clang', '*', 'include'))[0] - - new_args += [ - '--extra-cflags=-fblocks', - '--extra-cflags=-nostdinc', - '--extra-cflags=-isystem%s/usr/include' % sdk_dir, - '--extra-cflags=-isystem' + clang_dir, - '--extra-ldflags=-syslibroot', '--extra-ldflags=' + sdk_dir, - '--extra-ldflags=' + '-L' + libs_dir, - '--extra-ldflags=-lSystem', - '--extra-ldflags=-macosx_version_min', '--extra-ldflags=' + mac_min_ver, - '--extra-ldflags=-sdk_version', '--extra-ldflags=' + mac_min_ver, - # ld64.lld requires -platform_version - # - '--extra-ldflags=-platform_version', '--extra-ldflags=macos', - '--extra-ldflags=' + mac_min_ver, '--extra-ldflags=' + mac_min_ver] - - return new_args - - -def BuildFFmpeg(target_os, target_arch, host_os, host_arch, parallel_jobs, - config_only, config, configure_flags, options): - config_dir = 'build.%s.%s/%s' % (target_arch, target_os, config) - - # See if the token file exists, and skip building if '--fast' is given. - token_file = os.path.join(config_dir, SUCCESS_TOKEN) - if os.path.exists(token_file) and options.fast: - print('Success token exists, skipping build of %s' % config_dir) - return - - shutil.rmtree(config_dir, ignore_errors=True) - os.makedirs(config_dir) - - PrintAndCheckCall( - [os.path.join(FFMPEG_DIR, 'configure')] + configure_flags, cwd=config_dir) - - # These rewrites force disable various features and should be applied before - # attempting the standalone ffmpeg build to make sure compilation succeeds. - pre_make_rewrites = [ - (r'(#define HAVE_VALGRIND_VALGRIND_H [01])', - r'#define HAVE_VALGRIND_VALGRIND_H 0 /* \1 -- forced to 0. See ' - r'https://crbug.com/590440 */') - ] - pre_make_asm_rewrites = [ - (r'(%define HAVE_VALGRIND_VALGRIND_H [01])', - r'%define HAVE_VALGRIND_VALGRIND_H 0 ; \1 -- forced to 0. See ' - r'https://crbug.com/590440') - ] - - if target_os == 'android': - pre_make_rewrites += [ - (r'(#define HAVE_POSIX_MEMALIGN [01])', - r'#define HAVE_POSIX_MEMALIGN 0 /* \1 -- forced to 0. See ' - r'https://crbug.com/604451 */') - ] - - # Linux configs is also used on Fuchsia. They are mostly compatible with - # Fuchsia except that Fuchsia doesn't support sysctl(). On Linux sysctl() - # isn't actually used, so it's safe to set HAVE_SYSCTL to 0. Linux is also - # removing soon, so this is needed to silence a deprecation - # #warning which will be converted to an error via -Werror. - # There is also no prctl.h - if target_os in ['linux', 'linux-noasm']: - pre_make_rewrites += [ - (r'(#define HAVE_SYSCTL [01])', - r'#define HAVE_SYSCTL 0 /* \1 -- forced to 0 for Fuchsia */'), - (r'(#define HAVE_PRCTL [01])', - r'#define HAVE_PRCTL 0 /* \1 -- forced to 0 for Fuchsia */') - ] - - # Turn off bcrypt, since we don't have it on Windows builders, but it does - # get detected when cross-compiling. - if target_os == 'win': - pre_make_rewrites += [ - (r'(#define HAVE_BCRYPT [01])', - r'#define HAVE_BCRYPT 0') - ] - - # Sanitizers can't compile the h264 code when EBP is used. - # Pre-make as ffmpeg fails to compile otherwise. - if target_arch == 'ia32': - pre_make_rewrites += [ - (r'(#define HAVE_EBP_AVAILABLE [01])', - r'/* \1 -- ebp selection is done by the chrome build */') - ] - - RewriteFile(os.path.join(config_dir, 'config.h'), pre_make_rewrites) - asm_path = os.path.join(config_dir, 'config.asm') - if os.path.exists(asm_path): - RewriteFile(asm_path, pre_make_asm_rewrites) - - # Windows linking resolves external symbols. Since generate_gn.py does not - # need a functioning set of libraries, ignore unresolved symbols here. - # This is especially useful here to avoid having to build a local libopus for - # windows. We munge the output of configure here to avoid this LDFLAGS setting - # triggering mis-detection during configure execution. - if target_os == 'win': - RewriteFile( - os.path.join(config_dir, 'ffbuild/config.mak'), [(r'(LDFLAGS=.*)', - r'\1 -FORCE:UNRESOLVED')]) - - # TODO(https://crbug.com/840976): Linking when targetting mac on linux is - # currently broken. - # Replace the linker step with something that just creates the target. - if target_os == 'mac' and host_os == 'linux': - RewriteFile( - os.path.join(config_dir, 'ffbuild/config.mak'), [(r'LD=ld64.lld', - r'LD=' + os.path.join(SCRIPTS_DIR, 'fake_linker.py'))]) - - # The FFMPEG roll build hits a bug in lld-link that does not impact the - # overall Chromium build. - # Replace the linker step with something that just creates the target. - if target_os == 'win' and target_arch == 'arm64' and host_os == 'linux': - RewriteFile( - os.path.join(config_dir, 'ffbuild/config.mak'), [(r'LD=lld-link', - r'LD=' + os.path.join(SCRIPTS_DIR, 'fake_linker.py'))]) - - if target_os in (host_os, host_os + '-noasm', 'android', - 'win', 'mac') and not config_only: - PrintAndCheckCall( - ['make', '-j%d' % parallel_jobs], cwd=config_dir) - elif config_only: - print('Skipping build step as requested.') - else: - print('Skipping compile as host configuration differs from target.\n' - 'Please compare the generated config.h with the previous version.\n' - 'You may also patch the script to properly cross-compile.\n' - 'Host OS : %s\n' - 'Target OS : %s\n' - 'Host arch : %s\n' - 'Target arch : %s\n' % (host_os, target_os, host_arch, target_arch)) - - # These rewrites are necessary to faciliate various Chrome build options. - post_make_rewrites = [ - (r'(#define FFMPEG_CONFIGURATION .*)', - r'/* \1 -- elide long configuration string from binary */') - ] - - if target_arch in ('arm', 'arm-neon', 'arm64'): - post_make_rewrites += [ - (r'(#define HAVE_VFP_ARGS [01])', - r'/* \1 -- softfp/hardfp selection is done by the chrome build */') - ] - - RewriteFile(os.path.join(config_dir, 'config.h'), post_make_rewrites) - - # Yay! create the token file so that we can skip this in the future. - with open(token_file, 'w'): - pass - - -def main(argv): - clean_arch_map = {k: '|'.join(v) for k, v in ARCH_MAP.items()} - formatted_usage_end = USAGE_END % clean_arch_map - parser = optparse.OptionParser(usage=USAGE_BEGIN + formatted_usage_end) - parser.add_option( - '--branding', - action='append', - dest='brandings', - choices=BRANDINGS, - help='Branding to build; determines e.g. supported codecs') - parser.add_option( - '--config-only', - action='store_true', - help='Skip the build step. Useful when a given platform ' - 'is not necessary for generate_gn.py') - parser.add_option( - '--fast', - action='store_true', - help='Skip building (successfully) if the success token file exists') - options, args = parser.parse_args(argv) - - if len(args) < 1: - parser.print_help() - return 1 - - target_os = args[0] - target_arch = '' - if len(args) >= 2: - target_arch = args[1] - configure_args = args[2:] - - - if target_os not in ('android', 'linux', 'linux-noasm', 'mac', 'win', 'all'): - parser.print_help() - return 1 - - host_tuple = DetermineHostOsAndArch() - if not host_tuple: - print('Unrecognized host OS and architecture.', file=sys.stderr) - return 1 - - host_os, host_arch = host_tuple - parallel_jobs = 8 - - if target_os.split('-', 1)[0] != host_os and (host_os != 'linux' or - host_arch != 'x64'): - print('Cross compilation can only be done from a linux x64 host.') - return 1 - - for os in ARCH_MAP.keys(): - if os != target_os and target_os != 'all': - continue - for arch in ARCH_MAP[os]: - if target_arch and arch != target_arch: - continue - - print('System information:\n' - 'Host OS : %s\n' - 'Target OS : %s\n' - 'Host arch : %s\n' - 'Target arch : %s\n' % (host_os, os, host_arch, arch)) - ConfigureAndBuild( - arch, - os, - host_os, - host_arch, - parallel_jobs, - configure_args, - options=options) - - -def ConfigureAndBuild(target_arch, target_os, host_os, host_arch, parallel_jobs, - configure_args, options): - if target_os == 'linux' and target_arch == 'noasm-x64': - target_os = 'linux-noasm' - target_arch = 'x64' - - configure_flags = collections.defaultdict(list) - - # Common configuration. Note: --disable-everything does not in fact disable - # everything, just non-library components such as decoders and demuxers. - configure_flags['Common'].extend([ - '--disable-everything', - '--disable-all', - '--disable-doc', - '--disable-htmlpages', - '--disable-manpages', - '--disable-podpages', - '--disable-txtpages', - '--disable-static', - '--enable-avcodec', - '--enable-avformat', - '--enable-avutil', - '--enable-fft', - '--enable-rdft', - '--enable-static', - '--enable-libopus', - - # Disable features. - '--disable-debug', - '--disable-bzlib', - '--disable-error-resilience', - '--disable-iconv', - '--disable-network', - '--disable-schannel', - '--disable-sdl2', - '--disable-symver', - '--disable-xlib', - '--disable-zlib', - '--disable-securetransport', - '--disable-faan', - '--disable-alsa', - - # Disable automatically detected external libraries. This prevents - # automatic inclusion of things like hardware decoders. Each roll should - # audit new [autodetect] configure options and add any desired options to - # this file. - '--disable-autodetect', - - # Common codecs. - '--enable-decoder=vorbis,libopus,flac', - '--enable-decoder=pcm_u8,pcm_s16le,pcm_s24le,pcm_s32le,pcm_f32le,mp3', - '--enable-decoder=pcm_s16be,pcm_s24be,pcm_mulaw,pcm_alaw', - '--enable-demuxer=ogg,matroska,wav,flac,mp3,mov', - '--enable-parser=opus,vorbis,flac,mpegaudio,vp9', - - # Setup include path so Chromium's libopus can be used. - '--extra-cflags=-I' + os.path.join(CHROMIUM_ROOT_DIR, - 'third_party/opus/src/include'), - - # Disable usage of Linux Performance API. Not used in production code, but - # missing system headers break some Android builds. - '--disable-linux-perf', - - # Force usage of nasm. - '--x86asmexe=nasm', - ]) - - if target_os == 'android': - configure_flags['Common'].extend([ - # This replaces --optflags="-Os" since it implies it and since if it is - # also specified, configure ends up dropping all optflags :/ - '--enable-small', - ]) - - configure_flags['Common'].extend(SetupAndroidToolchain(target_arch)) - else: - configure_flags['Common'].extend([ - # --optflags doesn't append multiple entries, so set all at once. - '--optflags="-O3"', - '--extra-cflags=-mavx2', - '--extra-cflags=-maes', - '--extra-cflags=-mpclmul', - '--extra-cflags=-O3', - '--enable-decoder=theora,vp8', - '--enable-parser=vp3,vp8', - ]) - - if target_os in ('linux', 'linux-noasm', 'android'): - if target_arch == 'x64': - if target_os == 'android': - configure_flags['Common'].extend([ - '--arch=x86_64', - ]) - else: - configure_flags['Common'].extend([ - '--enable-lto', - '--extra-cflags=-O3', - '--extra-cflags=-mavx2', - '--extra-cflags=-maes', - '--extra-cflags=-mpclmul', - '--arch=x86_64', - '--target-os=linux', - ]) - - if host_arch != 'x64': - configure_flags['Common'].extend([ - '--enable-cross-compile', - '--cross-prefix=/usr/bin/x86_64-linux-gnu-', - '--extra-cflags=--target=x86_64-linux-gnu', - '--extra-ldflags=--target=x86_64-linux-gnu', - ]) - elif target_arch == 'ia32': - configure_flags['Common'].extend([ - '--arch=i686', - '--extra-cflags="-m32"', - '--extra-ldflags="-m32"', - ]) - # Android ia32 can't handle textrels and ffmpeg can't compile without - # them. http://crbug.com/559379 - if target_os == 'android': - configure_flags['Common'].extend([ - '--disable-x86asm', - ]) - elif target_arch == 'arm' or target_arch == 'arm-neon': - # TODO(ihf): ARM compile flags are tricky. The final options - # overriding everything live in chroot /build/*/etc/make.conf - # (some of them coming from src/overlays/overlay-/make.conf). - # We try to follow these here closely. In particular we need to - # set ffmpeg internal #defines to conform to make.conf. - # TODO(ihf): For now it is not clear if thumb or arm settings would be - # faster. I ran experiments in other contexts and performance seemed - # to be close and compiler version dependent. In practice thumb builds are - # much smaller than optimized arm builds, hence we go with the global - # CrOS settings. - configure_flags['Common'].extend([ - '--arch=arm', - '--enable-armv6', - '--enable-armv6t2', - '--enable-vfp', - '--enable-thumb', - '--extra-cflags=-march=armv7-a', - ]) - - if target_os == 'android': - configure_flags['Common'].extend([ - # Runtime neon detection requires /proc/cpuinfo access, so ensure - # av_get_cpu_flags() is run outside of the sandbox when enabled. - '--enable-neon', - '--extra-cflags=-mtune=generic-armv7-a', - # Enabling softfp lets us choose either softfp or hardfp when doing - # the chrome build. - '--extra-cflags=-mfloat-abi=softfp', - ]) - if target_arch == 'arm': - print('arm-neon is the only supported arm arch for Android.\n') - return 1 - - if target_arch == 'arm-neon': - configure_flags['Common'].extend([ - '--extra-cflags=-mfpu=neon', - ]) - else: - configure_flags['Common'].extend([ - '--extra-cflags=-mfpu=vfpv3-d16', - ]) - else: - if host_arch != 'arm': - configure_flags['Common'].extend([ - '--enable-cross-compile', - '--target-os=linux', - '--extra-cflags=--target=arm-linux-gnueabihf', - '--extra-ldflags=--target=arm-linux-gnueabihf', - '--sysroot=' + os.path.join(CHROMIUM_ROOT_DIR, - 'build/linux/debian_bullseye_armhf-sysroot'), - '--extra-cflags=-mtune=cortex-a8', - # NOTE: we don't need softfp for this hardware. - '--extra-cflags=-mfloat-abi=hard', - # For some reason configure drops this... - '--extra-cflags=-O3', - ]) - - if target_arch == 'arm-neon': - configure_flags['Common'].extend([ - '--enable-neon', - '--extra-cflags=-mfpu=neon', - ]) - else: - configure_flags['Common'].extend([ - '--disable-neon', - '--extra-cflags=-mfpu=vfpv3-d16', - ]) - elif target_arch == 'arm64': - if target_os != 'android': - if host_arch != 'arm64': - configure_flags['Common'].extend([ - '--enable-cross-compile', - '--cross-prefix=/usr/bin/aarch64-linux-gnu-', - '--extra-cflags=--target=aarch64-linux-gnu', - '--extra-ldflags=--target=aarch64-linux-gnu', - ]) - - configure_flags['Common'].extend([ - '--target-os=linux', - '--sysroot=' + os.path.join(CHROMIUM_ROOT_DIR, - 'build/linux/debian_bullseye_arm64-sysroot'), - ]) - configure_flags['Common'].extend([ - '--arch=aarch64', - '--enable-armv8', - '--extra-cflags=-march=armv8-a', - ]) - elif target_arch == 'mipsel': - # These flags taken from android chrome build with target_cpu='mipsel' - configure_flags['Common'].extend([ - '--arch=mipsel', - '--disable-mips32r6', - '--disable-mips32r5', - '--disable-mips32r2', - '--disable-mipsdsp', - '--disable-mipsdspr2', - '--disable-msa', - '--enable-mipsfpu', - '--extra-cflags=-march=mipsel', - '--extra-cflags=-mcpu=mips32', - # Required to avoid errors about dynamic relocation w/o -fPIC. - '--extra-ldflags=-z notext', - ]) - if target_os == 'linux': - configure_flags['Common'].extend([ - '--enable-cross-compile', - '--target-os=linux', - '--sysroot=' + os.path.join(CHROMIUM_ROOT_DIR, - 'build/linux/debian_bullseye_mips-sysroot'), - '--extra-cflags=--target=mipsel-linux-gnu', - '--extra-ldflags=--target=mipsel-linux-gnu', - ]) - elif target_arch == 'mips64el': - # These flags taken from android chrome build with target_cpu='mips64el' - configure_flags['Common'].extend([ - '--arch=mips64el', - '--enable-mipsfpu', - '--disable-mipsdsp', - '--disable-mipsdspr2', - '--extra-cflags=-march=mips64el', - # Required to avoid errors about dynamic relocation w/o -fPIC. - '--extra-ldflags=-z notext', - ]) - if target_os == 'android': - configure_flags['Common'].extend([ - '--enable-mips64r6', - '--extra-cflags=-mcpu=mips64r6', - '--disable-mips64r2', - '--enable-msa', - ]) - if target_os == 'linux': - configure_flags['Common'].extend([ - '--enable-cross-compile', - '--target-os=linux', - '--sysroot=' + os.path.join( - CHROMIUM_ROOT_DIR, 'build/linux/debian_bullseye_mips64el-sysroot'), - '--enable-mips64r2', - '--disable-mips64r6', - '--disable-msa', - '--extra-cflags=-mcpu=mips64r2', - '--extra-cflags=--target=mips64el-linux-gnuabi64', - '--extra-ldflags=--target=mips64el-linux-gnuabi64', - ]) - else: - print( - 'Error: Unknown target arch %r for target OS %r!' % (target_arch, - target_os), - file=sys.stderr) - return 1 - - if target_os == 'linux-noasm': - configure_flags['Common'].extend([ - '--disable-asm', - '--disable-inline-asm', - ]) - - if 'win' not in target_os and 'android' not in target_os: - configure_flags['Common'].extend([ - '--enable-pic', - '--cc=clang', - '--cxx=clang++', - '--ld=clang', - ]) - - # Clang Linux will use the first 'ld' it finds on the path, which will - # typically be the system one, so explicitly configure use of Clang's - # ld.lld, to ensure that things like cross-compilation and LTO work. - # This does not work for ia32 and is always used on mac. - if target_arch != 'ia32' and target_os != 'mac': - configure_flags['Common'].append('--extra-ldflags=-fuse-ld=lld') - - # Should be run on Mac, unless we're cross-compiling on Linux. - if target_os == 'mac': - if host_os != 'mac' and host_os != 'linux': - print( - 'Script should be run on a Mac or Linux host.\n', - file=sys.stderr) - return 1 - - if host_os != 'mac': - configure_flags['Common'].extend( - SetupMacCrossCompileToolchain(target_arch)) - else: - # ffmpeg links against Chromium's libopus, which isn't built when this - # script runs. Suppress all undefined symbols (which matches the default - # on Linux), to get things to build. This also requires opting in to - # flat namespaces. - configure_flags['Common'].extend([ - '--extra-ldflags=-Wl,-flat_namespace -Wl,-undefined,warning', - ]) - - if target_arch == 'x64': - configure_flags['Common'].extend([ - '--arch=x86_64', - '--extra-cflags=-m64', - '--extra-ldflags=-arch x86_64', - ]) - elif target_arch == 'arm64': - configure_flags['Common'].extend([ - '--arch=arm64', - '--extra-cflags=-arch arm64', - '--extra-ldflags=-arch arm64', - ]) - else: - print( - 'Error: Unknown target arch %r for target OS %r!' % (target_arch, - target_os), - file=sys.stderr) - - # Should be run on Windows. - if target_os == 'win': - configure_flags['Common'].extend([ - '--toolchain=msvc', - '--extra-cflags=-I' + os.path.join(FFMPEG_DIR, 'chromium/include/win'), - ]) - - if target_arch == 'x64': - configure_flags['Common'].extend(['--target-os=win64']) - elif target_arch == 'x86': - configure_flags['Common'].extend(['--target-os=win32']) - - if host_os != 'win': - configure_flags['Common'].extend( - SetupWindowsCrossCompileToolchain(target_arch)) - - if 'CYGWIN_NT' in platform.system(): - configure_flags['Common'].extend([ - '--cc=cygwin-wrapper cl', - '--ld=cygwin-wrapper link', - '--nm=cygwin-wrapper dumpbin -symbols', - '--ar=cygwin-wrapper lib', - ]) - - # Google Chrome & ChromeOS specific configuration. - configure_flags['Chrome'].extend([ - '--enable-decoder=aac,h264,mp3,eac3,ac3,hevc,mpeg4,mpegvideo,mp2,mp1,flac', - '--enable-demuxer=aac,mp3,mov,dtshd,dts,avi,mpegvideo,m4v,h264,vc1,flac', - '--enable-parser=aac,h264,hevc,mpegaudio,mpeg4video,mpegvideo,ac3,h261,vc1,h263,flac', - ]) - - # Google ChromeOS specific configuration. - # We want to make sure to play everything Android generates and plays. - # http://developer.android.com/guide/appendix/media-formats.html - configure_flags['ChromeOS'].extend([ - # Enable playing avi files. - '--enable-decoder=mpeg4', - '--enable-parser=h263,mpeg4video', - '--enable-demuxer=avi', - # Enable playing Android 3gp files. - '--enable-demuxer=amr', - '--enable-decoder=amrnb,amrwb', - # Wav files for playing phone messages. - '--enable-decoder=gsm_ms', - '--enable-parser=gsm', - ]) - - configure_flags['ChromeAndroid'].extend([ - '--enable-demuxer=aac', - '--enable-parser=aac', - '--enable-decoder=aac', - - # TODO(dalecurtis, watk): Figure out if we need h264 parser for now? - ]) - - def do_build_ffmpeg(branding, configure_flags): - if options.brandings and branding not in options.brandings: - print('%s skipped' % branding) - return - - print('%s configure/build:' % branding) - BuildFFmpeg(target_os, target_arch, host_os, host_arch, parallel_jobs, - options.config_only, branding, configure_flags, options) - - # Only build Chromium, Chrome for ia32, x86 non-android platforms. - if target_os != 'android': - do_build_ffmpeg( - 'Chromium', configure_flags['Common'] + configure_flags['Chromium'] + - configure_args) - do_build_ffmpeg( - 'Chrome', - configure_flags['Common'] + configure_flags['Chrome'] + configure_args) - else: - do_build_ffmpeg('Chromium', configure_flags['Common'] + configure_args) - do_build_ffmpeg( - 'Chrome', configure_flags['Common'] + configure_flags['ChromeAndroid'] + - configure_args) - - if target_os in ['linux', 'linux-noasm']: - # ChromeOS enables MPEG4 which requires error resilience :( - chrome_os_flags = ( - configure_flags['Common'] + configure_flags['Chrome'] + - configure_flags['ChromeOS'] + configure_args) - chrome_os_flags.remove('--disable-error-resilience') - do_build_ffmpeg('ChromeOS', chrome_os_flags) - - print('Done. If desired you may copy config.h/config.asm into the ' - 'source/config tree using copy_config.sh.') - return 0 - - -if __name__ == '__main__': - sys.exit(main(sys.argv[1:])) diff --git a/other/AVX2/third_party/opus/src/celt/arch.h b/other/AVX2/third_party/opus/src/celt/arch.h deleted file mode 100644 index da57a32a..00000000 --- a/other/AVX2/third_party/opus/src/celt/arch.h +++ /dev/null @@ -1,294 +0,0 @@ -/* Copyright (c) 2003-2008 Jean-Marc Valin - Copyright (c) 2007-2008 CSIRO - Copyright (c) 2007-2009 Xiph.Org Foundation - Written by Jean-Marc Valin */ -/** - @file arch.h - @brief Various architecture definitions for CELT -*/ -/* - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER - OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#ifndef ARCH_H -#define ARCH_H - -#include "opus_types.h" -#include "opus_defines.h" - -# if !defined(__GNUC_PREREQ) -# if defined(__GNUC__)&&defined(__GNUC_MINOR__) -# define __GNUC_PREREQ(_maj,_min) \ - ((__GNUC__<<16)+__GNUC_MINOR__>=((_maj)<<16)+(_min)) -# else -# define __GNUC_PREREQ(_maj,_min) 0 -# endif -# endif - -#if OPUS_GNUC_PREREQ(3, 0) -#define opus_likely(x) (__builtin_expect(!!(x), 1)) -#define opus_unlikely(x) (__builtin_expect(!!(x), 0)) -#else -#define opus_likely(x) (!!(x)) -#define opus_unlikely(x) (!!(x)) -#endif - -#define CELT_SIG_SCALE 32768.f - -#define CELT_FATAL(str) celt_fatal(str, __FILE__, __LINE__); - -#if defined(ENABLE_ASSERTIONS) || defined(ENABLE_HARDENING) -#ifdef __GNUC__ -__attribute__((noreturn)) -#endif -void celt_fatal(const char *str, const char *file, int line); - -#if defined(CELT_C) && !defined(OVERRIDE_celt_fatal) -#include -#include -#ifdef __GNUC__ -__attribute__((noreturn)) -#endif -void celt_fatal(const char *str, const char *file, int line) -{ -#if !defined(CHROMIUM_NO_LOGGING) - fprintf (stderr, "Fatal (internal) error in %s, line %d: %s\n", file, line, str); -#endif -#if defined(_MSC_VER) - _set_abort_behavior( 0, _WRITE_ABORT_MSG); -#endif - abort(); -} -#endif - -#define celt_assert(cond) {if (!(cond)) {CELT_FATAL("assertion failed: " #cond);}} -#define celt_assert2(cond, message) {if (!(cond)) {CELT_FATAL("assertion failed: " #cond "\n" message);}} -#define MUST_SUCCEED(call) celt_assert((call) == OPUS_OK) -#else -#define celt_assert(cond) -#define celt_assert2(cond, message) -#define MUST_SUCCEED(call) do {if((call) != OPUS_OK) {RESTORE_STACK; return OPUS_INTERNAL_ERROR;} } while (0) -#endif - -#if defined(ENABLE_ASSERTIONS) -#define celt_sig_assert(cond) {if (!(cond)) {CELT_FATAL("signal assertion failed: " #cond);}} -#else -#define celt_sig_assert(cond) -#endif - -#define IMUL32(a,b) ((a)*(b)) - -#define MIN16(a,b) ((a) < (b) ? (a) : (b)) /**< Minimum 16-bit value. */ -#define MAX16(a,b) ((a) > (b) ? (a) : (b)) /**< Maximum 16-bit value. */ -#define MIN32(a,b) ((a) < (b) ? (a) : (b)) /**< Minimum 32-bit value. */ -#define MAX32(a,b) ((a) > (b) ? (a) : (b)) /**< Maximum 32-bit value. */ -#define IMIN(a,b) ((a) < (b) ? (a) : (b)) /**< Minimum int value. */ -#define IMAX(a,b) ((a) > (b) ? (a) : (b)) /**< Maximum int value. */ -#define UADD32(a,b) ((a)+(b)) -#define USUB32(a,b) ((a)-(b)) - -/* Set this if opus_int64 is a native type of the CPU. */ -/* Assume that all LP64 architectures have fast 64-bit types; also x86_64 - (which can be ILP32 for x32) and Win64 (which is LLP64). */ -#if defined(__x86_64__) || defined(__LP64__) || defined(_WIN64) -#define OPUS_FAST_INT64 1 -#else -#define OPUS_FAST_INT64 0 -#endif - -#define PRINT_MIPS(file) - -#ifdef FIXED_POINT - -typedef opus_int16 opus_val16; -typedef opus_int32 opus_val32; -typedef opus_int64 opus_val64; - -typedef opus_val32 celt_sig; -typedef opus_val16 celt_norm; -typedef opus_val32 celt_ener; - -#define celt_isnan(x) 0 - -#define Q15ONE 32767 - -#define SIG_SHIFT 12 -/* Safe saturation value for 32-bit signals. Should be less than - 2^31*(1-0.85) to avoid blowing up on DC at deemphasis.*/ -#define SIG_SAT (300000000) - -#define NORM_SCALING 16384 - -#define DB_SHIFT 10 - -#define EPSILON 1 -#define VERY_SMALL 0 -#define VERY_LARGE16 ((opus_val16)32767) -#define Q15_ONE ((opus_val16)32767) - -#define SCALEIN(a) (a) -#define SCALEOUT(a) (a) - -#define ABS16(x) ((x) < 0 ? (-(x)) : (x)) -#define ABS32(x) ((x) < 0 ? (-(x)) : (x)) - -static OPUS_INLINE opus_int16 SAT16(opus_int32 x) { - return x > 32767 ? 32767 : x < -32768 ? -32768 : (opus_int16)x; -} - -#ifdef FIXED_DEBUG -#include "fixed_debug.h" -#else - -#include "fixed_generic.h" - -#ifdef OPUS_ARM_PRESUME_AARCH64_NEON_INTR -#include "arm/fixed_arm64.h" -#elif defined (OPUS_ARM_INLINE_EDSP) -#include "arm/fixed_armv5e.h" -#elif defined (OPUS_ARM_INLINE_ASM) -#include "arm/fixed_armv4.h" -#elif defined (BFIN_ASM) -#include "fixed_bfin.h" -#elif defined (TI_C5X_ASM) -#include "fixed_c5x.h" -#elif defined (TI_C6X_ASM) -#include "fixed_c6x.h" -#endif - -#endif - -#else /* FIXED_POINT */ - -typedef float opus_val16; -typedef float opus_val32; -typedef float opus_val64; - -typedef float celt_sig; -typedef float celt_norm; -typedef float celt_ener; - -#define FLOAT_APPROX -#ifdef FLOAT_APPROX -/* This code should reliably detect NaN/inf even when -ffast-math is used. - Assumes IEEE 754 format. */ -static OPUS_INLINE int celt_isnan(float x) -{ - union {float f; opus_uint32 i;} in; - in.f = x; - return ((in.i>>23)&0xFF)==0xFF && (in.i&0x007FFFFF)!=0; -} -#else -#ifdef __FAST_MATH__ -#error Cannot build libopus with -ffast-math unless FLOAT_APPROX is defined. This could result in crashes on extreme (e.g. NaN) input -#endif -#define celt_isnan(x) ((x)!=(x)) -#endif - -#define Q15ONE 1.0f - -#define NORM_SCALING 1.f - -#define EPSILON 1e-15f -#define VERY_SMALL 1e-30f -#define VERY_LARGE16 1e15f -#define Q15_ONE ((opus_val16)1.f) - -/* This appears to be the same speed as C99's fabsf() but it's more portable. */ -#define ABS16(x) ((float)fabs(x)) -#define ABS32(x) ((float)fabs(x)) - -#define QCONST16(x,bits) (x) -#define QCONST32(x,bits) (x) - -#define NEG16(x) (-(x)) -#define NEG32(x) (-(x)) -#define NEG32_ovflw(x) (-(x)) -#define EXTRACT16(x) (x) -#define EXTEND32(x) (x) -#define SHR16(a,shift) (a) -#define SHL16(a,shift) (a) -#define SHR32(a,shift) (a) -#define SHL32(a,shift) (a) -#define PSHR32(a,shift) (a) -#define VSHR32(a,shift) (a) - -#define PSHR(a,shift) (a) -#define SHR(a,shift) (a) -#define SHL(a,shift) (a) -#define SATURATE(x,a) (x) -#define SATURATE16(x) (x) - -#define ROUND16(a,shift) (a) -#define SROUND16(a,shift) (a) -#define HALF16(x) (.5f*(x)) -#define HALF32(x) (.5f*(x)) - -#define ADD16(a,b) ((a)+(b)) -#define SUB16(a,b) ((a)-(b)) -#define ADD32(a,b) ((a)+(b)) -#define SUB32(a,b) ((a)-(b)) -#define ADD32_ovflw(a,b) ((a)+(b)) -#define SUB32_ovflw(a,b) ((a)-(b)) -#define MULT16_16_16(a,b) ((a)*(b)) -#define MULT16_16(a,b) ((opus_val32)(a)*(opus_val32)(b)) -#define MAC16_16(c,a,b) ((c)+(opus_val32)(a)*(opus_val32)(b)) - -#define MULT16_32_Q15(a,b) ((a)*(b)) -#define MULT16_32_Q16(a,b) ((a)*(b)) - -#define MULT32_32_Q31(a,b) ((a)*(b)) - -#define MAC16_32_Q15(c,a,b) ((c)+(a)*(b)) -#define MAC16_32_Q16(c,a,b) ((c)+(a)*(b)) - -#define MULT16_16_Q11_32(a,b) ((a)*(b)) -#define MULT16_16_Q11(a,b) ((a)*(b)) -#define MULT16_16_Q13(a,b) ((a)*(b)) -#define MULT16_16_Q14(a,b) ((a)*(b)) -#define MULT16_16_Q15(a,b) ((a)*(b)) -#define MULT16_16_P15(a,b) ((a)*(b)) -#define MULT16_16_P13(a,b) ((a)*(b)) -#define MULT16_16_P14(a,b) ((a)*(b)) -#define MULT16_32_P16(a,b) ((a)*(b)) - -#define DIV32_16(a,b) (((opus_val32)(a))/(opus_val16)(b)) -#define DIV32(a,b) (((opus_val32)(a))/(opus_val32)(b)) - -#define SCALEIN(a) ((a)*CELT_SIG_SCALE) -#define SCALEOUT(a) ((a)*(1/CELT_SIG_SCALE)) - -#define SIG2WORD16(x) (x) - -#endif /* !FIXED_POINT */ - -#ifndef GLOBAL_STACK_SIZE -#ifdef FIXED_POINT -#define GLOBAL_STACK_SIZE 120000 -#else -#define GLOBAL_STACK_SIZE 120000 -#endif -#endif - -#endif /* ARCH_H */ diff --git a/other/AVX2/third_party/opus/src/configure.ac b/other/AVX2/third_party/opus/src/configure.ac deleted file mode 100644 index 462b5e60..00000000 --- a/other/AVX2/third_party/opus/src/configure.ac +++ /dev/null @@ -1,952 +0,0 @@ -dnl Process this file with autoconf to produce a configure script. -*-m4-*- - -dnl The package_version file will be automatically synced to the git revision -dnl by the update_version script when configured in the repository, but will -dnl remain constant in tarball releases unless it is manually edited. -m4_define([CURRENT_VERSION], - m4_esyscmd([ ./update_version 2>/dev/null || true - if test -e package_version; then - . ./package_version - printf "$PACKAGE_VERSION" - else - printf "unknown" - fi ])) - -AC_INIT([opus],[CURRENT_VERSION],[opus@xiph.org]) - -AC_CONFIG_SRCDIR(src/opus_encoder.c) -AC_CONFIG_MACRO_DIR([m4]) - -dnl enable silent rules on automake 1.11 and later -m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) - -# For libtool. -dnl Please update these for releases. -OPUS_LT_CURRENT=8 -OPUS_LT_REVISION=0 -OPUS_LT_AGE=8 - -AC_SUBST(OPUS_LT_CURRENT) -AC_SUBST(OPUS_LT_REVISION) -AC_SUBST(OPUS_LT_AGE) - -AM_INIT_AUTOMAKE([no-define]) -AM_MAINTAINER_MODE([enable]) - -AC_CANONICAL_HOST -AC_MINGW32 -AM_PROG_LIBTOOL -AM_PROG_CC_C_O - -AC_PROG_CC_C99 -AC_C_CONST -AC_C_INLINE - -AM_PROG_AS - -AC_DEFINE([OPUS_BUILD], [], [This is a build of OPUS]) - -#Use a hacked up version of autoconf's AC_C_RESTRICT because it's not -#strong enough a test to detect old buggy versions of GCC (e.g. 2.95.3) -#Note: Both this and the test for variable-size arrays below are also -# done by AC_PROG_CC_C99, but not thoroughly enough apparently. -AC_CACHE_CHECK([for C/C++ restrict keyword], ac_cv_c_restrict, - [ac_cv_c_restrict=no - # The order here caters to the fact that C++ does not require restrict. - for ac_kw in __restrict __restrict__ _Restrict restrict; do - AC_COMPILE_IFELSE([AC_LANG_PROGRAM( - [[typedef int * int_ptr; - int foo (int_ptr $ac_kw ip, int * $ac_kw baz[]) { - return ip[0]; - }]], - [[int s[1]; - int * $ac_kw t = s; - t[0] = 0; - return foo(t, (void *)0)]])], - [ac_cv_c_restrict=$ac_kw]) - test "$ac_cv_c_restrict" != no && break - done - ]) - -AH_VERBATIM([restrict], -[/* Define to the equivalent of the C99 'restrict' keyword, or to - nothing if this is not supported. Do not define if restrict is - supported directly. */ -#undef restrict -/* Work around a bug in Sun C++: it does not support _Restrict or - __restrict__, even though the corresponding Sun C compiler ends up with - "#define restrict _Restrict" or "#define restrict __restrict__" in the - previous line. Perhaps some future version of Sun C++ will work with - restrict; if so, hopefully it defines __RESTRICT like Sun C does. */ -#if defined __SUNPRO_CC && !defined __RESTRICT -# define _Restrict -# define __restrict__ -#endif]) - -case $ac_cv_c_restrict in - restrict) ;; - no) AC_DEFINE([restrict], []) ;; - *) AC_DEFINE_UNQUOTED([restrict], [$ac_cv_c_restrict]) ;; -esac - -AC_MSG_CHECKING(for C99 variable-size arrays) -AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], - [[static int x; char a[++x]; a[sizeof a - 1] = 0; int N; return a[0];]])], - [ has_var_arrays=yes - use_alloca="no (using var arrays)" - AC_DEFINE([VAR_ARRAYS], [1], [Use C99 variable-size arrays]) - ],[ - has_var_arrays=no - ]) -AC_MSG_RESULT([$has_var_arrays]) - -AS_IF([test "$has_var_arrays" = "no"], - [ - AC_CHECK_HEADERS([alloca.h]) - AC_MSG_CHECKING(for alloca) - AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], - [[int foo=10; int *array = alloca(foo);]])], - [ use_alloca=yes; - AC_DEFINE([USE_ALLOCA], [], [Make use of alloca]) - ],[ - use_alloca=no - ]) - AC_MSG_RESULT([$use_alloca]) - ]) - -LT_LIB_M - -AC_ARG_ENABLE([fixed-point], - [AS_HELP_STRING([--enable-fixed-point], - [compile without floating point (for machines without a fast enough FPU)])],, - [enable_fixed_point=no]) - -AS_IF([test "$enable_fixed_point" = "yes"],[ - enable_float="no" - AC_DEFINE([FIXED_POINT], [1], [Compile as fixed-point (for machines without a fast enough FPU)]) - PC_BUILD="fixed-point" -],[ - enable_float="yes"; - PC_BUILD="floating-point" -]) - -AM_CONDITIONAL([FIXED_POINT], [test "$enable_fixed_point" = "yes"]) - -AC_ARG_ENABLE([fixed-point-debug], - [AS_HELP_STRING([--enable-fixed-point-debug], [debug fixed-point implementation])],, - [enable_fixed_point_debug=no]) - -AS_IF([test "$enable_fixed_point_debug" = "yes"],[ - AC_DEFINE([FIXED_DEBUG], [1], [Debug fixed-point implementation]) -]) - -AC_ARG_ENABLE([float_api], - [AS_HELP_STRING([--disable-float-api], - [compile without the floating point API (for machines with no float library)])],, - [enable_float_api=yes]) - -AM_CONDITIONAL([DISABLE_FLOAT_API], [test "$enable_float_api" = "no"]) - -AS_IF([test "$enable_float_api" = "no"],[ - AC_DEFINE([DISABLE_FLOAT_API], [1], [Do not build the float API]) -]) - -AC_ARG_ENABLE([custom-modes], - [AS_HELP_STRING([--enable-custom-modes], [enable non-Opus modes, e.g. 44.1 kHz & 2^n frames])],, - [enable_custom_modes=no]) - -AS_IF([test "$enable_custom_modes" = "yes"],[ - AC_DEFINE([CUSTOM_MODES], [1], [Custom modes]) - PC_BUILD="$PC_BUILD, custom modes" -]) - -AM_CONDITIONAL([CUSTOM_MODES], [test "$enable_custom_modes" = "yes"]) - -has_float_approx=yes -enable_float_approx=yes -#case "$host_cpu" in -#i[[3456]]86 | x86_64 | powerpc64 | powerpc32 | ia64) -# has_float_approx=yes -# ;; -#esac - -AC_ARG_ENABLE([float-approx], - [AS_HELP_STRING([--enable-float-approx], [enable fast approximations for floating point])], - [if test "$enable_float_approx" = "yes"; then - AC_WARN([Floating point approximations are not supported on all platforms.]) - fi - ], - [enable_float_approx=$has_float_approx]) - -AS_IF([test "$enable_float_approx" = "yes"],[ - AC_DEFINE([FLOAT_APPROX], [1], [Float approximations]) -]) - -AC_ARG_ENABLE([asm], - [AS_HELP_STRING([--disable-asm], [Disable assembly optimizations])],, - [enable_asm=yes]) - -AC_ARG_ENABLE([rtcd], - [AS_HELP_STRING([--disable-rtcd], [Disable run-time CPU capabilities detection])],, - [enable_rtcd=yes]) - -AC_ARG_ENABLE([intrinsics], - [AS_HELP_STRING([--disable-intrinsics], [Disable intrinsics optimizations])],, - [enable_intrinsics=yes]) - -rtcd_support=no -cpu_arm=no -cpu_x86=no - -AS_IF([test x"${enable_asm}" = x"yes"],[ - inline_optimization="No inline ASM for your platform, please send patches" - case $host_cpu in - arm*) - dnl Currently we only have asm for fixed-point - AS_IF([test "$enable_float" != "yes"],[ - cpu_arm=yes - AC_DEFINE([OPUS_ARM_ASM], [], [Make use of ARM asm optimization]) - AS_GCC_INLINE_ASSEMBLY( - [inline_optimization="ARM"], - [inline_optimization="disabled"] - ) - AS_ASM_ARM_EDSP([OPUS_ARM_INLINE_EDSP=1],[OPUS_ARM_INLINE_EDSP=0]) - AS_ASM_ARM_MEDIA([OPUS_ARM_INLINE_MEDIA=1], - [OPUS_ARM_INLINE_MEDIA=0]) - AS_ASM_ARM_NEON([OPUS_ARM_INLINE_NEON=1],[OPUS_ARM_INLINE_NEON=0]) - AS_IF([test x"$inline_optimization" = x"ARM"],[ - AM_CONDITIONAL([OPUS_ARM_INLINE_ASM],[true]) - AC_DEFINE([OPUS_ARM_INLINE_ASM], 1, - [Use generic ARMv4 inline asm optimizations]) - AS_IF([test x"$OPUS_ARM_INLINE_EDSP" = x"1"],[ - AC_DEFINE([OPUS_ARM_INLINE_EDSP], [1], - [Use ARMv5E inline asm optimizations]) - inline_optimization="$inline_optimization (EDSP)" - ]) - AS_IF([test x"$OPUS_ARM_INLINE_MEDIA" = x"1"],[ - AC_DEFINE([OPUS_ARM_INLINE_MEDIA], [1], - [Use ARMv6 inline asm optimizations]) - inline_optimization="$inline_optimization (Media)" - ]) - AS_IF([test x"$OPUS_ARM_INLINE_NEON" = x"1"],[ - AC_DEFINE([OPUS_ARM_INLINE_NEON], 1, - [Use ARM NEON inline asm optimizations]) - inline_optimization="$inline_optimization (NEON)" - ]) - ]) - dnl We need Perl to translate RVCT-syntax asm to gas syntax. - AC_CHECK_PROG([HAVE_PERL], perl, yes, no) - AS_IF([test x"$HAVE_PERL" = x"yes"],[ - AM_CONDITIONAL([OPUS_ARM_EXTERNAL_ASM],[true]) - asm_optimization="ARM" - AS_IF([test x"$OPUS_ARM_INLINE_EDSP" = x"1"], [ - OPUS_ARM_PRESUME_EDSP=1 - OPUS_ARM_MAY_HAVE_EDSP=1 - ], - [ - OPUS_ARM_PRESUME_EDSP=0 - OPUS_ARM_MAY_HAVE_EDSP=0 - ]) - AS_IF([test x"$OPUS_ARM_INLINE_MEDIA" = x"1"], [ - OPUS_ARM_PRESUME_MEDIA=1 - OPUS_ARM_MAY_HAVE_MEDIA=1 - ], - [ - OPUS_ARM_PRESUME_MEDIA=0 - OPUS_ARM_MAY_HAVE_MEDIA=0 - ]) - AS_IF([test x"$OPUS_ARM_INLINE_NEON" = x"1"], [ - OPUS_ARM_PRESUME_NEON=1 - OPUS_ARM_MAY_HAVE_NEON=1 - ], - [ - OPUS_ARM_PRESUME_NEON=0 - OPUS_ARM_MAY_HAVE_NEON=0 - ]) - AS_IF([test x"$enable_rtcd" = x"yes"],[ - AS_IF([test x"$OPUS_ARM_MAY_HAVE_EDSP" != x"1"],[ - AC_MSG_NOTICE( - [Trying to force-enable armv5e EDSP instructions...]) - AS_ASM_ARM_EDSP_FORCE([OPUS_ARM_MAY_HAVE_EDSP=1]) - ]) - AS_IF([test x"$OPUS_ARM_MAY_HAVE_MEDIA" != x"1"],[ - AC_MSG_NOTICE( - [Trying to force-enable ARMv6 media instructions...]) - AS_ASM_ARM_MEDIA_FORCE([OPUS_ARM_MAY_HAVE_MEDIA=1]) - ]) - AS_IF([test x"$OPUS_ARM_MAY_HAVE_NEON" != x"1"],[ - AC_MSG_NOTICE( - [Trying to force-enable NEON instructions...]) - AS_ASM_ARM_NEON_FORCE([OPUS_ARM_MAY_HAVE_NEON=1]) - ]) - ]) - rtcd_support= - AS_IF([test x"$OPUS_ARM_MAY_HAVE_EDSP" = x"1"],[ - AC_DEFINE(OPUS_ARM_MAY_HAVE_EDSP, 1, - [Define if assembler supports EDSP instructions]) - AS_IF([test x"$OPUS_ARM_PRESUME_EDSP" = x"1"],[ - AC_DEFINE(OPUS_ARM_PRESUME_EDSP, 1, - [Define if binary requires EDSP instruction support]) - asm_optimization="$asm_optimization (EDSP)" - ], - [rtcd_support="$rtcd_support (EDSP)"] - ) - ]) - AC_SUBST(OPUS_ARM_MAY_HAVE_EDSP) - AS_IF([test x"$OPUS_ARM_MAY_HAVE_MEDIA" = x"1"],[ - AC_DEFINE(OPUS_ARM_MAY_HAVE_MEDIA, 1, - [Define if assembler supports ARMv6 media instructions]) - AS_IF([test x"$OPUS_ARM_PRESUME_MEDIA" = x"1"],[ - AC_DEFINE(OPUS_ARM_PRESUME_MEDIA, 1, - [Define if binary requires ARMv6 media instruction support]) - asm_optimization="$asm_optimization (Media)" - ], - [rtcd_support="$rtcd_support (Media)"] - ) - ]) - AC_SUBST(OPUS_ARM_MAY_HAVE_MEDIA) - AS_IF([test x"$OPUS_ARM_MAY_HAVE_NEON" = x"1"],[ - AC_DEFINE(OPUS_ARM_MAY_HAVE_NEON, 1, - [Define if compiler supports NEON instructions]) - AS_IF([test x"$OPUS_ARM_PRESUME_NEON" = x"1"], [ - AC_DEFINE(OPUS_ARM_PRESUME_NEON, 1, - [Define if binary requires NEON instruction support]) - asm_optimization="$asm_optimization (NEON)" - ], - [rtcd_support="$rtcd_support (NEON)"] - ) - ]) - AC_SUBST(OPUS_ARM_MAY_HAVE_NEON) - dnl Make sure turning on RTCD gets us at least one - dnl instruction set. - AS_IF([test x"$rtcd_support" != x""], - [rtcd_support=ARM"$rtcd_support"], - [rtcd_support="no"] - ) - AC_MSG_CHECKING([for apple style tools]) - AC_PREPROC_IFELSE([AC_LANG_PROGRAM([ -#ifndef __APPLE__ -#error 1 -#endif],[])], - [AC_MSG_RESULT([yes]); ARM2GNU_PARAMS="--apple"], - [AC_MSG_RESULT([no]); ARM2GNU_PARAMS=""]) - AC_SUBST(ARM2GNU_PARAMS) - ], - [ - AC_MSG_WARN( - [*** ARM assembly requires perl -- disabling optimizations]) - asm_optimization="(missing perl dependency for ARM)" - ]) - ]) - ;; - esac -],[ - inline_optimization="disabled" - asm_optimization="disabled" -]) - -AM_CONDITIONAL([OPUS_ARM_INLINE_ASM], - [test x"${inline_optimization%% *}" = x"ARM"]) -AM_CONDITIONAL([OPUS_ARM_EXTERNAL_ASM], - [test x"${asm_optimization%% *}" = x"ARM"]) - -AM_CONDITIONAL([HAVE_SSE], [false]) -AM_CONDITIONAL([HAVE_SSE2], [false]) -AM_CONDITIONAL([HAVE_SSE4_1], [false]) -AM_CONDITIONAL([HAVE_AVX], [false]) - -m4_define([DEFAULT_X86_SSE_CFLAGS], [-msse]) -m4_define([DEFAULT_X86_SSE2_CFLAGS], [-msse2]) -m4_define([DEFAULT_X86_SSE4_1_CFLAGS], [-msse4.1]) -m4_define([DEFAULT_X86_AVX_CFLAGS], [-mavx]) -m4_define([DEFAULT_ARM_NEON_INTR_CFLAGS], [-mfpu=neon]) -# With GCC on ARM32 softfp architectures (e.g. Android, or older Ubuntu) you need to specify -# -mfloat-abi=softfp for -mfpu=neon to work. However, on ARM32 hardfp architectures (e.g. newer Ubuntu), -# this option will break things. - -# As a heuristic, if host matches arm*eabi* but not arm*hf*, it's probably soft-float. -m4_define([DEFAULT_ARM_NEON_SOFTFP_INTR_CFLAGS], [-mfpu=neon -mfloat-abi=softfp]) - -AS_CASE([$host], - [arm*hf*], [AS_VAR_SET([RESOLVED_DEFAULT_ARM_NEON_INTR_CFLAGS], "DEFAULT_ARM_NEON_INTR_CFLAGS")], - [arm*eabi*], [AS_VAR_SET([RESOLVED_DEFAULT_ARM_NEON_INTR_CFLAGS], "DEFAULT_ARM_NEON_SOFTFP_INTR_CFLAGS")], - [AS_VAR_SET([RESOLVED_DEFAULT_ARM_NEON_INTR_CFLAGS], "DEFAULT_ARM_NEON_INTR_CFLAGS")]) - -AC_ARG_VAR([X86_SSE_CFLAGS], [C compiler flags to compile SSE intrinsics @<:@default=]DEFAULT_X86_SSE_CFLAGS[@:>@]) -AC_ARG_VAR([X86_SSE2_CFLAGS], [C compiler flags to compile SSE2 intrinsics @<:@default=]DEFAULT_X86_SSE2_CFLAGS[@:>@]) -AC_ARG_VAR([X86_SSE4_1_CFLAGS], [C compiler flags to compile SSE4.1 intrinsics @<:@default=]DEFAULT_X86_SSE4_1_CFLAGS[@:>@]) -AC_ARG_VAR([X86_AVX_CFLAGS], [C compiler flags to compile AVX intrinsics @<:@default=]DEFAULT_X86_AVX_CFLAGS[@:>@]) -AC_ARG_VAR([ARM_NEON_INTR_CFLAGS], [C compiler flags to compile ARM NEON intrinsics @<:@default=]DEFAULT_ARM_NEON_INTR_CFLAGS / DEFAULT_ARM_NEON_SOFTFP_INTR_CFLAGS[@:>@]) - -AS_VAR_SET_IF([X86_SSE_CFLAGS], [], [AS_VAR_SET([X86_SSE_CFLAGS], "DEFAULT_X86_SSE_CFLAGS")]) -AS_VAR_SET_IF([X86_SSE2_CFLAGS], [], [AS_VAR_SET([X86_SSE2_CFLAGS], "DEFAULT_X86_SSE2_CFLAGS")]) -AS_VAR_SET_IF([X86_SSE4_1_CFLAGS], [], [AS_VAR_SET([X86_SSE4_1_CFLAGS], "DEFAULT_X86_SSE4_1_CFLAGS")]) -AS_VAR_SET_IF([X86_AVX_CFLAGS], [], [AS_VAR_SET([X86_AVX_CFLAGS], "DEFAULT_X86_AVX_CFLAGS")]) -AS_VAR_SET_IF([ARM_NEON_INTR_CFLAGS], [], [AS_VAR_SET([ARM_NEON_INTR_CFLAGS], ["$RESOLVED_DEFAULT_ARM_NEON_INTR_CFLAGS"])]) - -AC_DEFUN([OPUS_PATH_NE10], - [ - AC_ARG_WITH(NE10, - AC_HELP_STRING([--with-NE10=PFX],[Prefix where libNE10 is installed (optional)]), - NE10_prefix="$withval", NE10_prefix="") - AC_ARG_WITH(NE10-libraries, - AC_HELP_STRING([--with-NE10-libraries=DIR], - [Directory where libNE10 library is installed (optional)]), - NE10_libraries="$withval", NE10_libraries="") - AC_ARG_WITH(NE10-includes, - AC_HELP_STRING([--with-NE10-includes=DIR], - [Directory where libNE10 header files are installed (optional)]), - NE10_includes="$withval", NE10_includes="") - - if test "x$NE10_libraries" != "x" ; then - NE10_LIBS="-L$NE10_libraries" - elif test "x$NE10_prefix" = "xno" || test "x$NE10_prefix" = "xyes" ; then - NE10_LIBS="" - elif test "x$NE10_prefix" != "x" ; then - NE10_LIBS="-L$NE10_prefix/lib" - elif test "x$prefix" != "xNONE" ; then - NE10_LIBS="-L$prefix/lib" - fi - - if test "x$NE10_prefix" != "xno" ; then - NE10_LIBS="$NE10_LIBS -lNE10" - fi - - if test "x$NE10_includes" != "x" ; then - NE10_CFLAGS="-I$NE10_includes" - elif test "x$NE10_prefix" = "xno" || test "x$NE10_prefix" = "xyes" ; then - NE10_CFLAGS="" - elif test "x$NE10_prefix" != "x" ; then - NE10_CFLAGS="-I$NE10_prefix/include" - elif test "x$prefix" != "xNONE"; then - NE10_CFLAGS="-I$prefix/include" - fi - - AC_MSG_CHECKING(for NE10) - save_CFLAGS="$CFLAGS"; CFLAGS="$CFLAGS $NE10_CFLAGS" - save_LIBS="$LIBS"; LIBS="$LIBS $NE10_LIBS $LIBM" - AC_LINK_IFELSE( - [ - AC_LANG_PROGRAM( - [[#include - ]], - [[ - ne10_fft_cfg_float32_t cfg; - cfg = ne10_fft_alloc_c2c_float32_neon(480); - ]] - ) - ],[ - HAVE_ARM_NE10=1 - AC_MSG_RESULT([yes]) - ],[ - HAVE_ARM_NE10=0 - AC_MSG_RESULT([no]) - NE10_CFLAGS="" - NE10_LIBS="" - ] - ) - CFLAGS="$save_CFLAGS"; LIBS="$save_LIBS" - #Now we know if libNE10 is installed or not - AS_IF([test x"$HAVE_ARM_NE10" = x"1"], - [ - AC_DEFINE([HAVE_ARM_NE10], 1, [NE10 library is installed on host. Make sure it is on target!]) - AC_SUBST(HAVE_ARM_NE10) - AC_SUBST(NE10_CFLAGS) - AC_SUBST(NE10_LIBS) - ] - ) - ] -) - -AS_IF([test x"$enable_intrinsics" = x"yes"],[ - intrinsics_support="" - AS_CASE([$host_cpu], - [arm*|aarch64*], - [ - cpu_arm=yes - OPUS_CHECK_INTRINSICS( - [ARM Neon], - [$ARM_NEON_INTR_CFLAGS], - [OPUS_ARM_MAY_HAVE_NEON_INTR], - [OPUS_ARM_PRESUME_NEON_INTR], - [[#include - ]], - [[ - static float32x4_t A0, A1, SUMM; - SUMM = vmlaq_f32(SUMM, A0, A1); - return (int)vgetq_lane_f32(SUMM, 0); - ]] - ) - AS_IF([test x"$OPUS_ARM_MAY_HAVE_NEON_INTR" = x"1" && test x"$OPUS_ARM_PRESUME_NEON_INTR" != x"1"], - [ - OPUS_ARM_NEON_INTR_CFLAGS="$ARM_NEON_INTR_CFLAGS" - AC_SUBST([OPUS_ARM_NEON_INTR_CFLAGS]) - ] - ) - - AS_IF([test x"$OPUS_ARM_MAY_HAVE_NEON_INTR" = x"1"], - [ - AC_DEFINE([OPUS_ARM_MAY_HAVE_NEON_INTR], 1, [Compiler supports ARMv7/Aarch64 Neon Intrinsics]) - intrinsics_support="$intrinsics_support (NEON)" - - AS_IF([test x"$enable_rtcd" != x"no" && test x"$OPUS_ARM_PRESUME_NEON_INTR" != x"1"], - [AS_IF([test x"$rtcd_support" = x"no"], - [rtcd_support="ARM (NEON Intrinsics)"], - [rtcd_support="$rtcd_support (NEON Intrinsics)"])]) - - AS_IF([test x"$OPUS_ARM_PRESUME_NEON_INTR" = x"1"], - [AC_DEFINE([OPUS_ARM_PRESUME_NEON_INTR], 1, [Define if binary requires NEON intrinsics support])]) - - OPUS_PATH_NE10() - AS_IF([test x"$NE10_LIBS" != x""], - [ - intrinsics_support="$intrinsics_support (NE10)" - AS_IF([test x"enable_rtcd" != x"" \ - && test x"$OPUS_ARM_PRESUME_NEON_INTR" != x"1"], - [rtcd_support="$rtcd_support (NE10)"]) - ]) - - OPUS_CHECK_INTRINSICS( - [Aarch64 Neon], - [$ARM_NEON_INTR_CFLAGS], - [OPUS_ARM_MAY_HAVE_AARCH64_NEON_INTR], - [OPUS_ARM_PRESUME_AARCH64_NEON_INTR], - [[#include - ]], - [[ - static int32_t IN; - static int16_t OUT; - OUT = vqmovns_s32(IN); - ]] - ) - - AS_IF([test x"$OPUS_ARM_PRESUME_AARCH64_NEON_INTR" = x"1"], - [ - AC_DEFINE([OPUS_ARM_PRESUME_AARCH64_NEON_INTR], 1, [Define if binary requires Aarch64 Neon Intrinsics]) - intrinsics_support="$intrinsics_support (NEON [Aarch64])" - ]) - - AS_IF([test x"$intrinsics_support" = x""], - [intrinsics_support=no], - [intrinsics_support="ARM$intrinsics_support"]) - ], - [ - AC_MSG_WARN([Compiler does not support ARM intrinsics]) - intrinsics_support=no - ]) - ], - [i?86|x86_64], - [ - cpu_x86=yes - OPUS_CHECK_INTRINSICS( - [SSE], - [$X86_SSE_CFLAGS], - [OPUS_X86_MAY_HAVE_SSE], - [OPUS_X86_PRESUME_SSE], - [[#include - #include - ]], - [[ - __m128 mtest; - mtest = _mm_set1_ps((float)time(NULL)); - mtest = _mm_mul_ps(mtest, mtest); - return _mm_cvtss_si32(mtest); - ]] - ) - AS_IF([test x"$OPUS_X86_MAY_HAVE_SSE" = x"1" && test x"$OPUS_X86_PRESUME_SSE" != x"1"], - [ - OPUS_X86_SSE_CFLAGS="$X86_SSE_CFLAGS" - AC_SUBST([OPUS_X86_SSE_CFLAGS]) - ] - ) - OPUS_CHECK_INTRINSICS( - [SSE2], - [$X86_SSE2_CFLAGS], - [OPUS_X86_MAY_HAVE_SSE2], - [OPUS_X86_PRESUME_SSE2], - [[#include - #include - ]], - [[ - __m128i mtest; - mtest = _mm_set1_epi32((int)time(NULL)); - mtest = _mm_mul_epu32(mtest, mtest); - return _mm_cvtsi128_si32(mtest); - ]] - ) - AS_IF([test x"$OPUS_X86_MAY_HAVE_SSE2" = x"1" && test x"$OPUS_X86_PRESUME_SSE2" != x"1"], - [ - OPUS_X86_SSE2_CFLAGS="$X86_SSE2_CFLAGS" - AC_SUBST([OPUS_X86_SSE2_CFLAGS]) - ] - ) - OPUS_CHECK_INTRINSICS( - [SSE4.1], - [$X86_SSE4_1_CFLAGS], - [OPUS_X86_MAY_HAVE_SSE4_1], - [OPUS_X86_PRESUME_SSE4_1], - [[#include - #include - ]], - [[ - __m128i mtest; - mtest = _mm_set1_epi32((int)time(NULL)); - mtest = _mm_mul_epi32(mtest, mtest); - return _mm_cvtsi128_si32(mtest); - ]] - ) - AS_IF([test x"$OPUS_X86_MAY_HAVE_SSE4_1" = x"1" && test x"$OPUS_X86_PRESUME_SSE4_1" != x"1"], - [ - OPUS_X86_SSE4_1_CFLAGS="$X86_SSE4_1_CFLAGS" - AC_SUBST([OPUS_X86_SSE4_1_CFLAGS]) - ] - ) - OPUS_CHECK_INTRINSICS( - [AVX], - [$X86_AVX_CFLAGS], - [OPUS_X86_MAY_HAVE_AVX], - [OPUS_X86_PRESUME_AVX], - [[#include - #include - ]], - [[ - __m256 mtest; - mtest = _mm256_set1_ps((float)time(NULL)); - mtest = _mm256_addsub_ps(mtest, mtest); - return _mm_cvtss_si32(_mm256_extractf128_ps(mtest, 0)); - ]] - ) - AS_IF([test x"$OPUS_X86_MAY_HAVE_AVX" = x"1" && test x"$OPUS_X86_PRESUME_AVX" != x"1"], - [ - OPUS_X86_AVX_CFLAGS="$X86_AVX_CFLAGS" - AC_SUBST([OPUS_X86_AVX_CFLAGS]) - ] - ) - AS_IF([test x"$rtcd_support" = x"no"], [rtcd_support=""]) - AS_IF([test x"$OPUS_X86_MAY_HAVE_SSE" = x"1"], - [ - AC_DEFINE([OPUS_X86_MAY_HAVE_SSE], 1, [Compiler supports X86 SSE Intrinsics]) - intrinsics_support="$intrinsics_support SSE" - - AS_IF([test x"$OPUS_X86_PRESUME_SSE" = x"1"], - [AC_DEFINE([OPUS_X86_PRESUME_SSE], 1, [Define if binary requires SSE intrinsics support])], - [rtcd_support="$rtcd_support SSE"]) - ], - [ - AC_MSG_WARN([Compiler does not support SSE intrinsics]) - ]) - - AS_IF([test x"$OPUS_X86_MAY_HAVE_SSE2" = x"1"], - [ - AC_DEFINE([OPUS_X86_MAY_HAVE_SSE2], 1, [Compiler supports X86 SSE2 Intrinsics]) - intrinsics_support="$intrinsics_support SSE2" - - AS_IF([test x"$OPUS_X86_PRESUME_SSE2" = x"1"], - [AC_DEFINE([OPUS_X86_PRESUME_SSE2], 1, [Define if binary requires SSE2 intrinsics support])], - [rtcd_support="$rtcd_support SSE2"]) - ], - [ - AC_MSG_WARN([Compiler does not support SSE2 intrinsics]) - ]) - - AS_IF([test x"$OPUS_X86_MAY_HAVE_SSE4_1" = x"1"], - [ - AC_DEFINE([OPUS_X86_MAY_HAVE_SSE4_1], 1, [Compiler supports X86 SSE4.1 Intrinsics]) - intrinsics_support="$intrinsics_support SSE4.1" - - AS_IF([test x"$OPUS_X86_PRESUME_SSE4_1" = x"1"], - [AC_DEFINE([OPUS_X86_PRESUME_SSE4_1], 1, [Define if binary requires SSE4.1 intrinsics support])], - [rtcd_support="$rtcd_support SSE4.1"]) - ], - [ - AC_MSG_WARN([Compiler does not support SSE4.1 intrinsics]) - ]) - AS_IF([test x"$OPUS_X86_MAY_HAVE_AVX" = x"1"], - [ - AC_DEFINE([OPUS_X86_MAY_HAVE_AVX], 1, [Compiler supports X86 AVX Intrinsics]) - intrinsics_support="$intrinsics_support AVX" - - AS_IF([test x"$OPUS_X86_PRESUME_AVX" = x"1"], - [AC_DEFINE([OPUS_X86_PRESUME_AVX], 1, [Define if binary requires AVX intrinsics support])], - [rtcd_support="$rtcd_support AVX"]) - ], - [ - AC_MSG_WARN([Compiler does not support AVX intrinsics]) - ]) - - AS_IF([test x"$intrinsics_support" = x""], - [intrinsics_support=no], - [intrinsics_support="x86$intrinsics_support"] - ) - AS_IF([test x"$rtcd_support" = x""], - [rtcd_support=no], - [rtcd_support="x86$rtcd_support"], - ) - - AS_IF([test x"$enable_rtcd" = x"yes" && test x"$rtcd_support" != x""],[ - get_cpuid_by_asm="no" - AC_MSG_CHECKING([How to get X86 CPU Info]) - AC_LINK_IFELSE([AC_LANG_PROGRAM([[ - #include - ]],[[ - unsigned int CPUInfo0; - unsigned int CPUInfo1; - unsigned int CPUInfo2; - unsigned int CPUInfo3; - unsigned int InfoType; - #if defined(__i386__) && defined(__PIC__) - __asm__ __volatile__ ( - "xchg %%ebx, %1\n" - "cpuid\n" - "xchg %%ebx, %1\n": - "=a" (CPUInfo0), - "=r" (CPUInfo1), - "=c" (CPUInfo2), - "=d" (CPUInfo3) : - "a" (InfoType), "c" (0) - ); - #else - __asm__ __volatile__ ( - "cpuid": - "=a" (CPUInfo0), - "=b" (CPUInfo1), - "=c" (CPUInfo2), - "=d" (CPUInfo3) : - "a" (InfoType), "c" (0) - ); - #endif - ]])], - [get_cpuid_by_asm="yes" - AC_MSG_RESULT([Inline Assembly]) - AC_DEFINE([CPU_INFO_BY_ASM], [1], [Get CPU Info by asm method])], - [AC_LINK_IFELSE([AC_LANG_PROGRAM([[ - #include - ]],[[ - unsigned int CPUInfo0; - unsigned int CPUInfo1; - unsigned int CPUInfo2; - unsigned int CPUInfo3; - unsigned int InfoType; - __get_cpuid_count(InfoType, 0, &CPUInfo0, &CPUInfo1, &CPUInfo2, &CPUInfo3); - ]])], - [AC_MSG_RESULT([C method]) - AC_DEFINE([CPU_INFO_BY_C], [1], [Get CPU Info by c method])], - [AC_MSG_ERROR([no supported Get CPU Info method, please disable run-time CPU capabilities detection or intrinsics])])])]) - ], - [ - AC_MSG_WARN([No intrinsics support for your architecture]) - intrinsics_support="no" - ]) -], -[ - intrinsics_support="no" -]) - -AM_CONDITIONAL([CPU_ARM], [test "$cpu_arm" = "yes"]) -AM_CONDITIONAL([HAVE_ARM_NEON_INTR], - [test x"$OPUS_ARM_MAY_HAVE_NEON_INTR" = x"1"]) -AM_CONDITIONAL([HAVE_ARM_NE10], - [test x"$HAVE_ARM_NE10" = x"1"]) -AM_CONDITIONAL([CPU_X86], [test "$cpu_x86" = "yes"]) -AM_CONDITIONAL([HAVE_SSE], - [test x"$OPUS_X86_MAY_HAVE_SSE" = x"1"]) -AM_CONDITIONAL([HAVE_SSE2], - [test x"$OPUS_X86_MAY_HAVE_SSE2" = x"1"]) -AM_CONDITIONAL([HAVE_SSE4_1], - [test x"$OPUS_X86_MAY_HAVE_SSE4_1" = x"1"]) -AM_CONDITIONAL([HAVE_AVX], - [test x"$OPUS_X86_MAY_HAVE_AVX" = x"1"]) - -AM_CONDITIONAL([HAVE_RTCD], - [test x"$enable_rtcd" = x"yes" -a x"$rtcd_support" != x"no"]) -AS_IF([test x"$enable_rtcd" = x"yes"],[ - AS_IF([test x"$rtcd_support" != x"no"],[ - AC_DEFINE([OPUS_HAVE_RTCD], [1], - [Use run-time CPU capabilities detection]) - OPUS_HAVE_RTCD=1 - AC_SUBST(OPUS_HAVE_RTCD) - ]) -],[ - rtcd_support="disabled" -]) - -AC_ARG_ENABLE([assertions], - [AS_HELP_STRING([--enable-assertions],[enable additional software error checking])],, - [enable_assertions=no]) - -AS_IF([test "$enable_assertions" = "yes"], [ - AC_DEFINE([ENABLE_ASSERTIONS], [1], [Assertions]) -]) - -AC_ARG_ENABLE([hardening], - [AS_HELP_STRING([--disable-hardening],[disable run-time checks that are cheap and safe for use in production])],, - [enable_hardening=yes]) - -AS_IF([test "$enable_hardening" = "yes"], [ - AC_DEFINE([ENABLE_HARDENING], [1], [Hardening]) -]) - -AC_ARG_ENABLE([fuzzing], - [AS_HELP_STRING([--enable-fuzzing],[causes the encoder to make random decisions (do not use in production)])],, - [enable_fuzzing=no]) - -AS_IF([test "$enable_fuzzing" = "yes"], [ - AC_DEFINE([FUZZING], [1], [Fuzzing]) -]) - -AC_ARG_ENABLE([check-asm], - [AS_HELP_STRING([--enable-check-asm], - [enable bit-exactness checks between optimized and c implementations])],, - [enable_check_asm=no]) - -AS_IF([test "$enable_check_asm" = "yes"], [ - AC_DEFINE([OPUS_CHECK_ASM], [1], [Run bit-exactness checks between optimized and c implementations]) -]) - -AC_ARG_ENABLE([doc], - [AS_HELP_STRING([--disable-doc], [Do not build API documentation])],, - [enable_doc=yes]) - -AS_IF([test "$enable_doc" = "yes"], [ - AC_CHECK_PROG(HAVE_DOXYGEN, [doxygen], [yes], [no]) - AC_CHECK_PROG(HAVE_DOT, [dot], [yes], [no]) -],[ - HAVE_DOXYGEN=no -]) - -AM_CONDITIONAL([HAVE_DOXYGEN], [test "$HAVE_DOXYGEN" = "yes"]) - -AC_ARG_ENABLE([extra-programs], - [AS_HELP_STRING([--disable-extra-programs], [Do not build extra programs (demo and tests)])],, - [enable_extra_programs=yes]) - -AM_CONDITIONAL([EXTRA_PROGRAMS], [test "$enable_extra_programs" = "yes"]) - - -AC_ARG_ENABLE([rfc8251], - AS_HELP_STRING([--disable-rfc8251], [Disable bitstream fixes from RFC 8251]),, - [enable_rfc8251=yes]) - -AS_IF([test "$enable_rfc8251" = "no"], [ - AC_DEFINE([DISABLE_UPDATE_DRAFT], [1], [Disable bitstream fixes from RFC 8251]) -]) - - -saved_CFLAGS="$CFLAGS" -CFLAGS="$CFLAGS -fvisibility=hidden" -AC_MSG_CHECKING([if ${CC} supports -fvisibility=hidden]) -AC_COMPILE_IFELSE([AC_LANG_SOURCE([[char foo;]])], - [ AC_MSG_RESULT([yes]) ], - [ AC_MSG_RESULT([no]) - CFLAGS="$saved_CFLAGS" - ]) - -on_x86=no -case "$host_cpu" in -i[[3456]]86 | x86_64) - on_x86=yes - ;; -esac - -on_windows=no -case $host in -*cygwin*|*mingw*) - on_windows=yes - ;; -esac - -dnl Enable stack-protector-all only on x86 where it's well supported. -dnl on some platforms it causes crashes. Hopefully the OS's default's -dnl include this on platforms that work but have been missed here. -AC_ARG_ENABLE([stack-protector], - [AS_HELP_STRING([--disable-stack-protector],[Disable compiler stack hardening])],, - [ - AS_IF([test "$ac_cv_c_compiler_gnu" = "yes" && test "$on_x86" = "yes" && test "$on_windows" = "no"], - [enable_stack_protector=yes],[enable_stack_protector=no]) - ]) - -AS_IF([test "$enable_stack_protector" = "yes"], - [ - saved_CFLAGS="$CFLAGS" - CFLAGS="$CFLAGS -fstack-protector-strong" - AC_MSG_CHECKING([if ${CC} supports -fstack-protector-strong]) - AC_LINK_IFELSE([AC_LANG_PROGRAM([],[[char foo;]])], - [ AC_MSG_RESULT([yes]) ], - [ - AC_MSG_RESULT([no]) - enable_stack_protector=no - CFLAGS="$saved_CFLAGS" - ]) - ]) - -AS_IF([test x$ac_cv_c_compiler_gnu = xyes], - [AX_ADD_FORTIFY_SOURCE] -) - -CFLAGS="$CFLAGS -W" - -warn_CFLAGS="-Wall -Wextra -Wcast-align -Wnested-externs -Wshadow -Wstrict-prototypes" -saved_CFLAGS="$CFLAGS" -CFLAGS="$CFLAGS $warn_CFLAGS" -AC_MSG_CHECKING([if ${CC} supports ${warn_CFLAGS}]) -AC_COMPILE_IFELSE([AC_LANG_SOURCE([[char foo;]])], - [ AC_MSG_RESULT([yes]) ], - [ AC_MSG_RESULT([no]) - CFLAGS="$saved_CFLAGS" - ]) - -saved_LIBS="$LIBS" -LIBS="$LIBS $LIBM" -AC_CHECK_FUNCS([lrintf]) -AC_CHECK_FUNCS([lrint]) -LIBS="$saved_LIBS" - -AC_CHECK_FUNCS([__malloc_hook]) - -AC_SUBST([PC_BUILD]) - -AC_CONFIG_FILES([ - Makefile - opus.pc - opus-uninstalled.pc - celt/arm/armopts.s - doc/Makefile - doc/Doxyfile -]) -AC_CONFIG_HEADERS([config.h]) - -AC_OUTPUT - -AC_MSG_NOTICE([ ------------------------------------------------------------------------- - $PACKAGE_NAME $PACKAGE_VERSION: Automatic configuration OK. - - Compiler support: - - C99 var arrays: ................ ${has_var_arrays} - C99 lrintf: .................... ${ac_cv_func_lrintf} - Use alloca: .................... ${use_alloca} - - General configuration: - - Floating point support: ........ ${enable_float} - Fast float approximations: ..... ${enable_float_approx} - Fixed point debugging: ......... ${enable_fixed_point_debug} - Inline Assembly Optimizations: . ${inline_optimization} - External Assembly Optimizations: ${asm_optimization} - Intrinsics Optimizations: ...... ${intrinsics_support} - Run-time CPU detection: ........ ${rtcd_support} - Custom modes: .................. ${enable_custom_modes} - Assertion checking: ............ ${enable_assertions} - Hardening: ..................... ${enable_hardening} - Fuzzing: ....................... ${enable_fuzzing} - Check ASM: ..................... ${enable_check_asm} - - API documentation: ............. ${enable_doc} - Extra programs: ................ ${enable_extra_programs} ------------------------------------------------------------------------- - - Type "make; make install" to compile and install - Type "make check" to run the test suite -]) - diff --git a/other/AVX2/v8/BUILD.gn b/other/AVX2/v8/BUILD.gn index 92ddfc2a..fbd4b0ee 100644 --- a/other/AVX2/v8/BUILD.gn +++ b/other/AVX2/v8/BUILD.gn @@ -12,10 +12,6 @@ import("//build/config/riscv.gni") import("//build/config/sanitizers/sanitizers.gni") import("//build_overrides/build.gni") -if (is_android) { - import("//build/config/android/rules.gni") -} - import("gni/snapshot_toolchain.gni") import("gni/v8.gni") @@ -323,6 +319,10 @@ declare_args() { # Sets -DV8_ENABLE_SANDBOX. v8_enable_sandbox = "" + # Enable experimental code pointer sandboxing for the V8 sandbox. + # Sets -DV8_CODE_POINTER_SANDBOXING + v8_code_pointer_sandboxing = false + # Expose the memory corruption API to JavaScript. Useful for testing the sandbox. # WARNING This will expose builtins that (by design) cause memory corruption. # Sets -DV8_EXPOSE_MEMORY_CORRUPTION_API @@ -372,13 +372,6 @@ declare_args() { # (incomplete and experimental). v8_enable_cet_shadow_stack = false - # Get VMEX priviledge at startup. - # It allows to run V8 without "deprecated-ambient-replace-as-executable". - # Sets -DV8_USE_VMEX_RESOURCE. - # TODO(victorgomes): Remove this flag once Chormium no longer needs - # the deprecated feature. - v8_fuchsia_use_vmex_resource = is_fuchsia && !build_with_chromium - # Enables pointer compression for 8GB heaps. # Sets -DV8_COMPRESS_POINTERS_8GB. v8_enable_pointer_compression_8gb = "" @@ -397,6 +390,10 @@ declare_args() { # iOS (non-simulator) does not have executable pages for 3rd party # applications yet so disable jit. v8_jitless = v8_enable_lite_mode || target_is_ios_device + + # Enable Maglev's graph printer. + # Sets -DV8_MAGLEV_GRAPH_PRINTER. + v8_enable_maglev_graph_printer = !build_with_chromium } # Derived defaults. @@ -476,13 +473,13 @@ if (v8_enable_short_builtin_calls == "") { if (v8_enable_external_code_space == "") { v8_enable_external_code_space = v8_enable_pointer_compression && - (v8_current_cpu == "x64" || - (target_os != "fuchsia" && v8_current_cpu == "arm64")) + (v8_current_cpu == "x64" || v8_current_cpu == "arm64") } if (v8_enable_maglev == "") { v8_enable_maglev = v8_enable_turbofan && - (v8_current_cpu == "x64" || v8_current_cpu == "arm64") && - v8_enable_pointer_compression + (v8_current_cpu == "arm" || + ((v8_current_cpu == "x64" || v8_current_cpu == "arm64") && + v8_enable_pointer_compression)) } assert(v8_enable_turbofan || !v8_enable_maglev, "Maglev is not available when Turbofan is disabled.") @@ -645,6 +642,9 @@ assert(!v8_enable_sandbox || v8_enable_pointer_compression_shared_cage, assert(!v8_enable_sandbox || v8_enable_external_code_space, "The sandbox requires the external code space") +assert(!v8_code_pointer_sandboxing || v8_enable_sandbox, + "Code pointer sandboxing requires the sandbox") + assert(!v8_expose_memory_corruption_api || v8_enable_sandbox, "The Memory Corruption API requires the sandbox") @@ -678,10 +678,6 @@ if (v8_enable_single_generation == true) { "Requires unconditional write barriers or none (which disables incremental marking)") } -if (v8_fuchsia_use_vmex_resource) { - assert(target_os == "fuchsia", "VMEX resource only available on Fuchsia") -} - assert(!v8_enable_snapshot_compression || v8_use_zlib, "Snapshot compression requires zlib") @@ -724,7 +720,9 @@ config("internal_config") { } if (v8_current_cpu == "riscv64" || v8_current_cpu == "riscv32") { - libs = [ "atomic" ] + if (!is_clang) { + libs = [ "atomic" ] + } } } @@ -796,7 +794,9 @@ config("external_config") { } if (current_cpu == "riscv64" || current_cpu == "riscv32") { - libs = [ "atomic" ] + if (!is_clang) { + libs = [ "atomic" ] + } } } @@ -1142,9 +1142,6 @@ config("features") { if (v8_advanced_bigint_algorithms) { defines += [ "V8_ADVANCED_BIGINT_ALGORITHMS" ] } - if (v8_fuchsia_use_vmex_resource) { - defines += [ "V8_USE_VMEX_RESOURCE" ] - } if (v8_expose_memory_corruption_api) { defines += [ "V8_EXPOSE_MEMORY_CORRUPTION_API" ] } @@ -1169,6 +1166,12 @@ config("features") { if (v8_enable_wasm_simd256_revec) { defines += [ "V8_ENABLE_WASM_SIMD256_REVEC" ] } + if (v8_code_pointer_sandboxing) { + defines += [ "V8_CODE_POINTER_SANDBOXING" ] + } + if (v8_enable_maglev_graph_printer) { + defines += [ "V8_ENABLE_MAGLEV_GRAPH_PRINTER" ] + } } config("toolchain") { @@ -1313,6 +1316,12 @@ config("toolchain") { defines += [ "V8_TARGET_ARCH_RISCV32" ] defines += [ "__riscv_xlen=32" ] defines += [ "CAN_USE_FPU_INSTRUCTIONS" ] + + # TODO(riscv32): Add condition riscv_use_rvv and riscv_rvv_vlen here after + # 4538202 merge. + if (target_is_simulator) { + defines += [ "CAN_USE_RVV_INSTRUCTIONS" ] + } } if (v8_current_cpu == "x86") { @@ -1331,7 +1340,7 @@ config("toolchain") { cflags += [ "/O2", "/arch:AVX2" ] ldflags += [ "/STACK:2097152" ] } - if (is_linux) { + if (is_linux || is_chromeos) { # Full optimization for V8. cflags += [ "-O3", "-mavx2", "-maes" ] ldflags += [ "-Wl,-O3", "-mavx2", "-maes" ] @@ -1339,7 +1348,6 @@ config("toolchain") { } if (is_android && v8_android_log_stdout) { defines += [ "V8_ANDROID_LOG_STDOUT" ] - cflags += [ "-O3" ] } # V8_TARGET_OS_ defines. The target OS may differ from host OS e.g. in @@ -1408,15 +1416,18 @@ config("toolchain") { "-Wmissing-field-initializers", "-Wunreachable-code", - # Google3 enables this warning, so we should also enable it to find issue - # earlier. See https://reviews.llvm.org/D56731 for details about this - # warning. - "-Wctad-maybe-unsupported", - # TODO(v8:12245): Fix shadowing instances and remove. "-Wno-shadow", ] + # TODO(fuchsia:127411): Re-enable once FIDL bindings are compatible. + if (!is_fuchsia) { + # Google3 enables this warning, so we should also enable it to find issue + # earlier. See https://reviews.llvm.org/D56731 for details about this + # warning. + cflags += [ "-Wctad-maybe-unsupported" ] + } + if (v8_current_cpu == "x64" || v8_current_cpu == "arm64" || v8_current_cpu == "mips64el" || v8_current_cpu == "riscv64") { cflags += [ "-Wshorten-64-to-32" ] @@ -1760,6 +1771,7 @@ if (v8_postmortem_support) { "src/objects/string-inl.h", "src/objects/struct.h", "src/objects/struct-inl.h", + "src/objects/tagged.h", ] outputs = [ "$target_gen_dir/debug-support.cc" ] @@ -1826,9 +1838,11 @@ torque_files = [ "src/builtins/iterator.tq", "src/builtins/iterator-from.tq", "src/builtins/iterator-helpers.tq", + "src/builtins/map-groupby.tq", "src/builtins/math.tq", "src/builtins/number.tq", "src/builtins/object-fromentries.tq", + "src/builtins/object-groupby.tq", "src/builtins/object.tq", "src/builtins/promise-abstract-operations.tq", "src/builtins/promise-all.tq", @@ -1864,6 +1878,8 @@ torque_files = [ "src/builtins/regexp-split.tq", "src/builtins/regexp-test.tq", "src/builtins/regexp.tq", + "src/builtins/set-intersection.tq", + "src/builtins/set-union.tq", "src/builtins/string-at.tq", "src/builtins/string-endswith.tq", "src/builtins/string-html.tq", @@ -2003,6 +2019,7 @@ if (v8_enable_i18n_support) { if (v8_enable_webassembly) { torque_files += [ + "src/builtins/js-to-wasm.tq", "src/builtins/wasm.tq", "src/debug/debug-wasm-objects.tq", "src/wasm/wasm-objects.tq", @@ -3082,6 +3099,7 @@ v8_header_set("v8_internal_headers") { "src/compiler/js-create-lowering.h", "src/compiler/js-generic-lowering.h", "src/compiler/js-graph.h", + "src/compiler/js-heap-broker-inl.h", "src/compiler/js-heap-broker.h", "src/compiler/js-inlining-heuristic.h", "src/compiler/js-inlining.h", @@ -3181,7 +3199,6 @@ v8_header_set("v8_internal_headers") { "src/compiler/turboshaft/store-store-elimination-phase.h", "src/compiler/turboshaft/store-store-elimination-reducer.h", "src/compiler/turboshaft/structural-optimization-reducer.h", - "src/compiler/turboshaft/tag-untag-lowering-reducer.h", "src/compiler/turboshaft/tracing.h", "src/compiler/turboshaft/type-assertions-phase.h", "src/compiler/turboshaft/type-inference-analysis.h", @@ -3361,6 +3378,7 @@ v8_header_set("v8_internal_headers") { "src/heap/marking-worklist.h", "src/heap/marking.h", "src/heap/memory-allocator.h", + "src/heap/memory-balancer.h", "src/heap/memory-chunk-inl.h", "src/heap/memory-chunk-layout.h", "src/heap/memory-chunk.h", @@ -3377,6 +3395,7 @@ v8_header_set("v8_internal_headers") { "src/heap/paged-spaces-inl.h", "src/heap/paged-spaces.h", "src/heap/parallel-work-item.h", + "src/heap/parked-scope-inl.h", "src/heap/parked-scope.h", "src/heap/pretenuring-handler-inl.h", "src/heap/pretenuring-handler.h", @@ -3649,6 +3668,7 @@ v8_header_set("v8_internal_headers") { "src/objects/tagged-index.h", "src/objects/tagged-value-inl.h", "src/objects/tagged-value.h", + "src/objects/tagged.h", "src/objects/template-objects-inl.h", "src/objects/template-objects.h", "src/objects/templates-inl.h", @@ -3733,6 +3753,10 @@ v8_header_set("v8_internal_headers") { "src/runtime/runtime.h", "src/sandbox/bounded-size-inl.h", "src/sandbox/bounded-size.h", + "src/sandbox/code-pointer-inl.h", + "src/sandbox/code-pointer-table-inl.h", + "src/sandbox/code-pointer-table.h", + "src/sandbox/code-pointer.h", "src/sandbox/external-entity-table-inl.h", "src/sandbox/external-entity-table.h", "src/sandbox/external-pointer-inl.h", @@ -3752,6 +3776,7 @@ v8_header_set("v8_internal_headers") { "src/snapshot/embedded/embedded-file-writer-interface.h", "src/snapshot/object-deserializer.h", "src/snapshot/read-only-deserializer.h", + "src/snapshot/read-only-serializer-deserializer.h", "src/snapshot/read-only-serializer.h", "src/snapshot/references.h", "src/snapshot/roots-serializer.h", @@ -3856,7 +3881,9 @@ v8_header_set("v8_internal_headers") { "src/maglev/maglev-register-frame-array.h", "src/maglev/maglev.h", ] - if (v8_current_cpu == "arm64") { + if (v8_current_cpu == "arm") { + sources += [ "src/maglev/arm/maglev-assembler-arm-inl.h" ] + } else if (v8_current_cpu == "arm64") { sources += [ "src/maglev/arm64/maglev-assembler-arm64-inl.h" ] } else if (v8_current_cpu == "x64") { sources += [ "src/maglev/x64/maglev-assembler-x64-inl.h" ] @@ -3871,6 +3898,7 @@ v8_header_set("v8_internal_headers") { "src/asmjs/asm-scanner.h", "src/asmjs/asm-types.h", "src/compiler/int64-lowering.h", + "src/compiler/turboshaft/wasm-js-lowering-reducer.h", "src/compiler/wasm-address-reassociation.h", "src/compiler/wasm-call-descriptors.h", "src/compiler/wasm-compiler-definitions.h", @@ -3881,6 +3909,7 @@ v8_header_set("v8_internal_headers") { "src/compiler/wasm-graph-assembler.h", "src/compiler/wasm-inlining-into-js.h", "src/compiler/wasm-inlining.h", + "src/compiler/wasm-js-lowering.h", "src/compiler/wasm-load-elimination.h", "src/compiler/wasm-loop-peeling.h", "src/compiler/wasm-typer.h", @@ -4538,6 +4567,7 @@ if (v8_enable_webassembly) { "src/compiler/wasm-graph-assembler.cc", "src/compiler/wasm-inlining-into-js.cc", "src/compiler/wasm-inlining.cc", + "src/compiler/wasm-js-lowering.cc", "src/compiler/wasm-load-elimination.cc", "src/compiler/wasm-loop-peeling.cc", "src/compiler/wasm-typer.cc", @@ -4889,6 +4919,7 @@ v8_source_set("v8_base_without_compiler") { "src/heap/marking-worklist.cc", "src/heap/marking.cc", "src/heap/memory-allocator.cc", + "src/heap/memory-balancer.cc", "src/heap/memory-chunk-layout.cc", "src/heap/memory-chunk.cc", "src/heap/memory-measurement.cc", @@ -5100,6 +5131,7 @@ v8_source_set("v8_base_without_compiler") { "src/runtime/runtime-typedarray.cc", "src/runtime/runtime-weak-refs.cc", "src/runtime/runtime.cc", + "src/sandbox/code-pointer-table.cc", "src/sandbox/external-pointer-table.cc", "src/sandbox/sandbox.cc", "src/sandbox/testing.cc", @@ -5174,7 +5206,12 @@ v8_source_set("v8_base_without_compiler") { "src/maglev/maglev-regalloc.cc", "src/maglev/maglev.cc", ] - if (v8_current_cpu == "arm64") { + if (v8_current_cpu == "arm") { + sources += [ + "src/maglev/arm/maglev-assembler-arm.cc", + "src/maglev/arm/maglev-ir-arm.cc", + ] + } else if (v8_current_cpu == "arm64") { sources += [ "src/maglev/arm64/maglev-assembler-arm64.cc", "src/maglev/arm64/maglev-ir-arm64.cc", @@ -5589,7 +5626,9 @@ v8_source_set("v8_base_without_compiler") { v8_current_cpu == "ppc" || v8_current_cpu == "ppc64" || v8_current_cpu == "s390" || v8_current_cpu == "s390x" || v8_current_cpu == "riscv64" || v8_current_cpu == "riscv32") { - libs += [ "atomic" ] + if (!is_clang) { + libs += [ "atomic" ] + } } if (v8_enable_vtunetracemark && (is_linux || is_chromeos || is_win)) { @@ -5936,8 +5975,8 @@ v8_component("v8_libbase") { "src/base/platform/platform-fuchsia.cc", ] deps += [ - "//third_party/fuchsia-sdk/sdk/fidl/fuchsia.kernel", - "//third_party/fuchsia-sdk/sdk/pkg/fdio", + "//third_party/fuchsia-sdk/sdk/fidl/fuchsia.kernel:fuchsia.kernel_cpp", + "//third_party/fuchsia-sdk/sdk/pkg/component_incoming_cpp", "//third_party/fuchsia-sdk/sdk/pkg/zx", ] } else if (is_mac) { @@ -5989,7 +6028,9 @@ v8_component("v8_libbase") { } if (v8_current_cpu == "riscv64" || v8_current_cpu == "riscv32") { - libs += [ "atomic" ] + if (!is_clang) { + libs += [ "atomic" ] + } } if (is_tsan && !build_with_chromium) { @@ -6099,7 +6140,9 @@ v8_component("v8_libplatform") { } if (v8_current_cpu == "riscv64" || v8_current_cpu == "riscv32") { - libs = [ "atomic" ] + if (!is_clang) { + libs = [ "atomic" ] + } } } @@ -7038,7 +7081,9 @@ v8_executable("cppgc_hello_world") { sources = [ "samples/cppgc/hello-world.cc" ] if (v8_current_cpu == "riscv64" || v8_current_cpu == "riscv32") { - libs = [ "atomic" ] + if (!is_clang) { + libs = [ "atomic" ] + } } configs = [ diff --git a/other/CrOS/third_party/ffmpeg/chromium/scripts/build_ffmpeg.py b/other/CrOS/third_party/ffmpeg/chromium/scripts/build_ffmpeg.py deleted file mode 100755 index 4dc2230f..00000000 --- a/other/CrOS/third_party/ffmpeg/chromium/scripts/build_ffmpeg.py +++ /dev/null @@ -1,1076 +0,0 @@ -#!/usr/bin/env python3 -# -# Copyright 2023 The Chromium Authors, Alex313031, and Midzer. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -from __future__ import print_function - -import atexit -import collections -import functools -import glob -import optparse -import os -import platform -import re -import shlex -import shutil -import signal -import subprocess -import sys -import tempfile - -SCRIPTS_DIR = os.path.abspath(os.path.dirname(__file__)) -FFMPEG_DIR = os.path.abspath(os.path.join(SCRIPTS_DIR, '..', '..')) -CHROMIUM_ROOT_DIR = os.path.abspath(os.path.join(FFMPEG_DIR, '..', '..')) -NDK_ROOT_DIR = os.path.abspath( - os.path.join(CHROMIUM_ROOT_DIR, 'third_party', 'android_ndk')) -SUCCESS_TOKEN = 'THIS_BUILD_WORKED' - -sys.path.append(os.path.join(CHROMIUM_ROOT_DIR, 'build')) -import gn_helpers - -BRANDINGS = [ - 'Chrome', - 'ChromeOS', - 'Chromium', -] - -ARCH_MAP = { - 'android': ['ia32', 'x64', 'arm-neon', 'arm64'], - 'linux': [ - 'ia32', 'x64', 'noasm-x64', 'arm', 'arm-neon', 'arm64' - ], - 'mac': ['x64', 'arm64'], - 'win': ['ia32', 'x64', 'arm64'], -} - -USAGE_BEGIN = """Usage: %prog TARGET_OS TARGET_ARCH [options] -- [configure_args]""" -USAGE_END = """ -Valid combinations are android [%(android)s] - linux [%(linux)s] - mac [%(mac)s] - win [%(win)s] - -If no target architecture is specified all will be built. - -Platform specific build notes: - android: - Script can be run on a normal x64 Ubuntu box with an Android-ready Chromium - checkout: https://chromium.googlesource.com/chromium/src/+/master/docs/android_build_instructions.md - - linux ia32/x64: - Script can run on a normal Ubuntu box. - - linux arm/arm-neon/arm64/mipsel/mips64el: - Script can run on a normal Ubuntu with ARM/ARM64 or MIPS32/MIPS64 ready Chromium checkout: - build/linux/sysroot_scripts/install-sysroot.py --arch=arm - build/linux/sysroot_scripts/install-sysroot.py --arch=arm64 - build/linux/sysroot_scripts/install-sysroot.py --arch=mips - build/linux/sysroot_scripts/install-sysroot.py --arch=mips64el - - mac: - Script must be run on Linux or macOS. Additionally, ensure the Chromium - (not Apple) version of clang is in the path; usually found under - src/third_party/llvm-build/Release+Asserts/bin - - The arm64 version has to be built with an SDK that can build mac/arm64 - binaries -- currently Xcode 12 beta and its included 11.0 SDK. You must - pass --enable-cross-compile to be able to build ffmpeg for mac/arm64 on an - Intel Mac. On a Mac, run like so: - PATH=$PWD/../../third_party/llvm-build/Release+Asserts/bin:$PATH \ - SDKROOT=/Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.0.sdk \ - chromium/scripts/build_ffmpeg.py mac arm64 -- --enable-cross-compile - - On Linux, the normal robosushi flow will work for arm64. - - win: - Script may be run unders Linux or Windows; if cross-compiling you will need - to follow the Chromium instruction for Cross-compiling Chrome/win: - https://chromium.googlesource.com/chromium/src/+/master/docs/win_cross.md - - Once you have a working Chromium build that can cross-compile, you'll also - need to run $chrome_dir/tools/clang/scripts/update.py --package=objdump to - pick up the llvm-ar and llvm-nm tools. You can then build as normal. - - If not cross-compiling, script must be run on Windows with VS2015 or higher - under Cygwin (or MinGW, but as of 1.0.11, it has serious performance issues - with make which makes building take hours). - - Additionally, ensure you have the correct toolchain environment for building. - The x86 toolchain environment is required for ia32 builds and the x64 one - for x64 builds. This can be verified by running "cl.exe" and checking if - the version string ends with "for x64" or "for x86." - - Building on Windows also requires some additional Cygwin packages plus a - wrapper script for converting Cygwin paths to DOS paths. - - Add these packages at install time: diffutils, nasm, make, python. - - Copy chromium/scripts/cygwin-wrapper to /usr/local/bin - -Resulting binaries will be placed in: - build.TARGET_ARCH.TARGET_OS/Chrome/ - build.TARGET_ARCH.TARGET_OS/ChromeOS/ - build.TARGET_ARCH.TARGET_OS/Chromium/ - """ - - -def PrintAndCheckCall(argv, *args, **kwargs): - print('Running %s' % '\n '.join(argv)) - subprocess.check_call(argv, *args, **kwargs) - - -def DetermineHostOsAndArch(): - if platform.system() == 'Linux': - host_os = 'linux' - elif platform.system() == 'Darwin': - host_os = 'mac' - elif platform.system() == 'Windows' or 'CYGWIN_NT' in platform.system(): - host_os = 'win' - else: - return None - - if re.match(r'i.86', platform.machine()): - host_arch = 'ia32' - elif platform.machine() == 'x86_64' or platform.machine() == 'AMD64': - host_arch = 'x64' - elif platform.machine() == 'aarch64': - host_arch = 'arm64' - elif platform.machine() == 'mips32': - host_arch = 'mipsel' - elif platform.machine() == 'mips64': - host_arch = 'mips64el' - elif platform.machine().startswith('arm'): - host_arch = 'arm' - else: - return None - - return (host_os, host_arch) - - -def GetDsoName(target_os, dso_name, dso_version): - if target_os in ('linux', 'linux-noasm', 'android'): - return 'lib%s.so.%s' % (dso_name, dso_version) - elif target_os == 'mac': - return 'lib%s.%s.dylib' % (dso_name, dso_version) - elif target_os == 'win': - return '%s-%s.dll' % (dso_name, dso_version) - else: - raise ValueError('Unexpected target_os %s' % target_os) - - -def RewriteFile(path, search_replace): - with open(path) as f: - contents = f.read() - with open(path, 'w') as f: - for search, replace in search_replace: - contents = re.sub(search, replace, contents) - f.write(contents) - - -# Class for determining the 32-bit and 64-bit Android API levels that Chromium -# uses. Since @functools.cache is not available for easy memoization of the -# determination result, we use a lazy singleton instance constructed by calling -# Get(). -class AndroidApiLevels: - __instance = None - - # Extracts the Android API levels from the Chromium Android GN config. - # Before Q1 2021, these were grep'able from build/config/android/config.gni. - # With conditional logic introduced in that gni file, we seek to avoid fragility - # going forwards, at the cost of creating a full temporary GN Chromium Android - # build configuration just to extract the API levels here. Caches the results - # in api32 and api64 instance variables. - def Setup(self): - print('Creating a temporary GN config to retrieve Android API levels:') - - # Make a temporary GN build output folder - # No tempfile.TemporaryDirectory until python 3.2, so instead: - tmp_dir = tempfile.mkdtemp(prefix = 'android_build_ffmpeg_for_api_level_config') - print('Created temporary directory ' + tmp_dir) - - # Populate that GN build output folder with generated config for Android as - # target OS. - with open(os.path.join(tmp_dir, 'args.gn'), 'w') as args_gn_file: - args_gn_file.write('target_os = "android"\n') - print('Created ' + os.path.realpath(args_gn_file.name)) - - # Ask GN to generate build files. - PrintAndCheckCall(['gn', 'gen', tmp_dir], cwd=CHROMIUM_ROOT_DIR) - - # Query the API levels in the generated build config. - print('Retrieving config vars') - config_output = subprocess.check_output( - ['gn', 'args', tmp_dir, '--short', '--list'], - cwd=CHROMIUM_ROOT_DIR).decode('utf-8') - - # Remove the temporary GN build output folder - print('removing temp dir ' + tmp_dir) - shutil.rmtree(tmp_dir, ignore_errors=False) - - api64_match = re.search(r'android64_ndk_api_level\s*=\s*(\d{2})', - config_output) - api32_match = re.search(r'android32_ndk_api_level\s*=\s*(\d{2})', - config_output) - if not api32_match or not api64_match: - raise Exception('Failed to find the android api levels') - - self.api32 = api32_match.group(1) - self.api64 = api64_match.group(1) - - def ApiLevels(self): - return (self.api32, self.api64) - - @classmethod - def Get(cls): - if cls.__instance is None: - cls.__instance = AndroidApiLevels() - cls.__instance.Setup() - return cls.__instance.ApiLevels() - - -# Sets up cross-compilation (specific to host being linux-x64_64) for compiling -# Android. -# Returns the necessary configure flags as a list. -# See also https://developer.android.com/ndk/guides/other_build_systems -# As of M90, //third_party/android_ndk no longer includes mipsel or mips64el -# toolchains; they were not previously supported by default by this script, and -# currently are unsupported due to lack of toolchain in checkout. -def SetupAndroidToolchain(target_arch): - api_level, api64_level = AndroidApiLevels.Get() - print('Determined Android API levels: 32bit=' + api_level + - ', 64bit=' + api64_level) - - # Toolchain prefix misery, for when just one pattern is not enough :/ - toolchain_level = api_level - toolchain_bin_prefix = target_arch - - if target_arch == 'arm-neon' or target_arch == 'arm': - toolchain_bin_prefix = 'arm-linux-androideabi' - elif target_arch == 'arm64': - toolchain_level = api64_level - toolchain_bin_prefix = 'aarch64-linux-android' - elif target_arch == 'ia32': - toolchain_bin_prefix = 'i686-linux-android' - elif target_arch == 'x64': - toolchain_level = api64_level - toolchain_bin_prefix = 'x86_64-linux-android' - elif target_arch == 'mipsel': # Unsupported beginning in M90 - toolchain_bin_prefix = 'mipsel-linux-android' - elif target_arch == 'mips64el': # Unsupported beginning in M90 - toolchain_level = api64_level - toolchain_bin_prefix = 'mips64el-linux-android' - - clang_toolchain_dir = NDK_ROOT_DIR + '/toolchains/llvm/prebuilt/linux-x86_64/' - - # Big old nasty hack here, beware! The new android ndk has some foolery with - # libgcc.a -- clang still uses gcc for its linker when cross compiling. - # It can't just be that simple though - the |libgcc.a| file is actually a - # super secret linkerscript which links libgcc_real.a, because apparently - # someone decided that more flags are needed, including -lunwind; thats where - # our story begins. ffmpeg doesn't use linunwind, and we dont really have a - # good way to get a cross-compiled version anyway, but this silly linker - # script insists that we must link with it, or face all sorts of horrible - # consequences -- namely configure failures. Anyway, there is a way around it: - # the "big old nasty hack" mentioned what feels like forever ago now. It's - # simple, we uhh, kill tha batman. Actually we just make a fake libunwind.a - # linker script and drop it someplace nobody will ever find, like I dunno, say - # /tmp/fakelinkerscripts or something. Then we add that path to the ldflags - # flags and everything works again. - fakedir = '/tmp/fakelinkerscripts' - os.system('mkdir -p {fakedir} && touch {fakedir}/libunwind.a'.format( - fakedir=fakedir)) - - return [ - '--enable-pic', - '--cc=' + clang_toolchain_dir + 'bin/clang', - '--cxx=' + clang_toolchain_dir + 'bin/clang++', - '--ld=' + clang_toolchain_dir + 'bin/clang', - '--enable-cross-compile', - '--sysroot=' + clang_toolchain_dir + 'sysroot', - '--extra-cflags=-I' + clang_toolchain_dir + 'sysroot/usr/include', - '--extra-cflags=-I' + clang_toolchain_dir + 'sysroot/usr/include/' + - toolchain_bin_prefix, - '--extra-cflags=--target=' + toolchain_bin_prefix + toolchain_level, - '--extra-ldflags=--target=' + toolchain_bin_prefix + toolchain_level, - '--extra-ldflags=-L{}'.format(fakedir), - '--extra-ldflags=-L' + clang_toolchain_dir + toolchain_bin_prefix, - '--extra-ldflags=--gcc-toolchain=' + clang_toolchain_dir, - '--target-os=android', - ] - - -def SetupWindowsCrossCompileToolchain(target_arch): - # First retrieve various MSVC and Windows SDK paths. - output = subprocess.check_output([ - os.path.join(CHROMIUM_ROOT_DIR, 'build', 'vs_toolchain.py'), - 'get_toolchain_dir' - ]).decode('utf-8') - - new_args = [ - '--enable-cross-compile', - '--cc=clang-cl', - '--ld=lld-link', - '--nm=llvm-nm', - '--ar=llvm-ar', - - # Separate from optflags because configure strips it from msvc builds... - '--extra-cflags=-O3', - ] - - if target_arch == 'ia32': - new_args += ['--extra-cflags=-m32'] - if target_arch == 'ia32': - target_arch = 'x86' - if target_arch == 'arm64': - new_args += [ - # With ASM enabled, an ARCH must be specified. - '--arch=aarch64', - # When cross-compiling (from Linux), armasm64.exe is not available. - '--as=clang-cl', - # FFMPEG is not yet enlightened for ARM64 Windows. - # Imitate Android workaround. - '--extra-cflags=--target=arm64-windows' - ] - - # Turn this into a dictionary. - win_dirs = gn_helpers.FromGNArgs(output) - - # Use those paths with a second script which will tell us the proper lib paths - # to specify for ldflags. - output = subprocess.check_output([ - 'python3', - os.path.join(CHROMIUM_ROOT_DIR, 'build', 'toolchain', 'win', - 'setup_toolchain.py'), win_dirs['vs_path'], - win_dirs['sdk_path'], win_dirs['runtime_dirs'], 'win', target_arch, 'none' - ]).decode('utf-8') - - flags = gn_helpers.FromGNArgs(output) - - # Q1 2021 update to LLVM now lets us use a sysroot for cross-compilation - # targeting Windows, instead of specificying a variety of individual include - # folders which now include whitespace within paths within the SDK. Either - # injection of such paths into environment variable or using the new sysroot - # option is required, since using a /tmp symlink solution to avoid the spaces - # broke cross-compilation for win-arm64. For at least now, we'll use the - # sysroot approach, until and unless the environment variable injection - # approach is determined to be better or more consistent. - new_args += [ - '--extra-cflags=/winsysroot' + win_dirs['vs_path'], - '--extra-ldflags=/winsysroot:' + win_dirs['vs_path'], - ] - - # FFmpeg configure doesn't like arguments with spaces in them even if quoted - # or double-quoted or escape-quoted (whole argument and/or the internal - # spaces). To automate this for now, every path that has a space in it is - # replaced with a symbolic link created in the OS' temp folder to the real - # path. - def do_remove_temp_link(temp_name): - assert os.path.exists(temp_name) - assert os.path.islink(temp_name) - print('Removing temporary link ' + temp_name) - os.remove(temp_name) - - def do_make_temp_link(real_target): - temp_file = tempfile.NamedTemporaryFile(prefix='windows_build_ffmpeg') - temp_name = temp_file.name - # Destroy |temp_file|, but reuse its name for the symbolic link which - # survives this helper method. - temp_file.close() - os.symlink(real_target, temp_name) - assert os.path.exists(temp_name) - assert os.path.islink(temp_name) - atexit.register(do_remove_temp_link, temp_name) - return temp_name - - return new_args - - -def SetupMacCrossCompileToolchain(target_arch): - # First compute the various SDK paths. - mac_min_ver = '10.10' - developer_dir = os.path.join(CHROMIUM_ROOT_DIR, 'build', 'mac_files', - 'xcode_binaries', 'Contents', 'Developer') - sdk_dir = os.path.join(developer_dir, 'Platforms', 'MacOSX.platform', - 'Developer', 'SDKs', 'MacOSX.sdk') - - if target_arch == 'x64': - target_triple = 'x86_64-apple-macosx' - elif target_arch == 'arm64': - target_triple = 'arm64-apple-macosx' - else: - raise Exception("unknown arch " + target_arch) - - # We're guessing about the right sdk path, so warn if we don't find it. - if not os.path.exists(sdk_dir): - print (sdk_dir) - raise Exception("Can't find the mac sdk. Please see crbug.com/841826") - - frameworks_dir = os.path.join(sdk_dir, "System", "Library", "Frameworks") - libs_dir = os.path.join(sdk_dir, "usr", "lib") - - new_args = [ - '--enable-cross-compile', - '--cc=clang', - # This is replaced with fake_linker.py further down. We need a real linker - # at configure time for a few configure checks. These checks only link - # very basic programs, so it's ok to use ld64.lld, even though it's not - # generally production quality. - '--ld=ld64.lld', - '--nm=llvm-nm', - '--ar=llvm-ar', - '--target-os=darwin', - - '--extra-cflags=--target=' + target_triple, - '--extra-cflags=-F' + frameworks_dir, - '--extra-cflags=-mmacosx-version-min=' + mac_min_ver - ] - - # We need to pass -nostdinc so that clang does not pick up linux headers, - # but then it also can't find its own headers like stddef.h. So tell it - # where to look for those headers. - clang_dir = glob.glob(os.path.join(CHROMIUM_ROOT_DIR, 'third_party', - 'llvm-build', 'Release+Asserts', 'lib', 'clang', '*', 'include'))[0] - - new_args += [ - '--extra-cflags=-fblocks', - '--extra-cflags=-nostdinc', - '--extra-cflags=-isystem%s/usr/include' % sdk_dir, - '--extra-cflags=-isystem' + clang_dir, - '--extra-ldflags=-syslibroot', '--extra-ldflags=' + sdk_dir, - '--extra-ldflags=' + '-L' + libs_dir, - '--extra-ldflags=-lSystem', - '--extra-ldflags=-macosx_version_min', '--extra-ldflags=' + mac_min_ver, - '--extra-ldflags=-sdk_version', '--extra-ldflags=' + mac_min_ver, - # ld64.lld requires -platform_version - # - '--extra-ldflags=-platform_version', '--extra-ldflags=macos', - '--extra-ldflags=' + mac_min_ver, '--extra-ldflags=' + mac_min_ver] - - return new_args - - -def BuildFFmpeg(target_os, target_arch, host_os, host_arch, parallel_jobs, - config_only, config, configure_flags, options): - config_dir = 'build.%s.%s/%s' % (target_arch, target_os, config) - - # See if the token file exists, and skip building if '--fast' is given. - token_file = os.path.join(config_dir, SUCCESS_TOKEN) - if os.path.exists(token_file) and options.fast: - print('Success token exists, skipping build of %s' % config_dir) - return - - shutil.rmtree(config_dir, ignore_errors=True) - os.makedirs(config_dir) - - PrintAndCheckCall( - [os.path.join(FFMPEG_DIR, 'configure')] + configure_flags, cwd=config_dir) - - # These rewrites force disable various features and should be applied before - # attempting the standalone ffmpeg build to make sure compilation succeeds. - pre_make_rewrites = [ - (r'(#define HAVE_VALGRIND_VALGRIND_H [01])', - r'#define HAVE_VALGRIND_VALGRIND_H 0 /* \1 -- forced to 0. See ' - r'https://crbug.com/590440 */') - ] - pre_make_asm_rewrites = [ - (r'(%define HAVE_VALGRIND_VALGRIND_H [01])', - r'%define HAVE_VALGRIND_VALGRIND_H 0 ; \1 -- forced to 0. See ' - r'https://crbug.com/590440') - ] - - if target_os == 'android': - pre_make_rewrites += [ - (r'(#define HAVE_POSIX_MEMALIGN [01])', - r'#define HAVE_POSIX_MEMALIGN 0 /* \1 -- forced to 0. See ' - r'https://crbug.com/604451 */') - ] - - # Linux configs is also used on Fuchsia. They are mostly compatible with - # Fuchsia except that Fuchsia doesn't support sysctl(). On Linux sysctl() - # isn't actually used, so it's safe to set HAVE_SYSCTL to 0. Linux is also - # removing soon, so this is needed to silence a deprecation - # #warning which will be converted to an error via -Werror. - # There is also no prctl.h - if target_os in ['linux', 'linux-noasm']: - pre_make_rewrites += [ - (r'(#define HAVE_SYSCTL [01])', - r'#define HAVE_SYSCTL 0 /* \1 -- forced to 0 for Fuchsia */'), - (r'(#define HAVE_PRCTL [01])', - r'#define HAVE_PRCTL 0 /* \1 -- forced to 0 for Fuchsia */') - ] - - # Turn off bcrypt, since we don't have it on Windows builders, but it does - # get detected when cross-compiling. - if target_os == 'win': - pre_make_rewrites += [ - (r'(#define HAVE_BCRYPT [01])', - r'#define HAVE_BCRYPT 0') - ] - - # Sanitizers can't compile the h264 code when EBP is used. - # Pre-make as ffmpeg fails to compile otherwise. - if target_arch == 'ia32': - pre_make_rewrites += [ - (r'(#define HAVE_EBP_AVAILABLE [01])', - r'/* \1 -- ebp selection is done by the chrome build */') - ] - - RewriteFile(os.path.join(config_dir, 'config.h'), pre_make_rewrites) - asm_path = os.path.join(config_dir, 'config.asm') - if os.path.exists(asm_path): - RewriteFile(asm_path, pre_make_asm_rewrites) - - # Windows linking resolves external symbols. Since generate_gn.py does not - # need a functioning set of libraries, ignore unresolved symbols here. - # This is especially useful here to avoid having to build a local libopus for - # windows. We munge the output of configure here to avoid this LDFLAGS setting - # triggering mis-detection during configure execution. - if target_os == 'win': - RewriteFile( - os.path.join(config_dir, 'ffbuild/config.mak'), [(r'(LDFLAGS=.*)', - r'\1 -FORCE:UNRESOLVED')]) - - # TODO(https://crbug.com/840976): Linking when targetting mac on linux is - # currently broken. - # Replace the linker step with something that just creates the target. - if target_os == 'mac' and host_os == 'linux': - RewriteFile( - os.path.join(config_dir, 'ffbuild/config.mak'), [(r'LD=ld64.lld', - r'LD=' + os.path.join(SCRIPTS_DIR, 'fake_linker.py'))]) - - # The FFMPEG roll build hits a bug in lld-link that does not impact the - # overall Chromium build. - # Replace the linker step with something that just creates the target. - if target_os == 'win' and target_arch == 'arm64' and host_os == 'linux': - RewriteFile( - os.path.join(config_dir, 'ffbuild/config.mak'), [(r'LD=lld-link', - r'LD=' + os.path.join(SCRIPTS_DIR, 'fake_linker.py'))]) - - if target_os in (host_os, host_os + '-noasm', 'android', - 'win', 'mac') and not config_only: - PrintAndCheckCall( - ['make', '-j%d' % parallel_jobs], cwd=config_dir) - elif config_only: - print('Skipping build step as requested.') - else: - print('Skipping compile as host configuration differs from target.\n' - 'Please compare the generated config.h with the previous version.\n' - 'You may also patch the script to properly cross-compile.\n' - 'Host OS : %s\n' - 'Target OS : %s\n' - 'Host arch : %s\n' - 'Target arch : %s\n' % (host_os, target_os, host_arch, target_arch)) - - # These rewrites are necessary to faciliate various Chrome build options. - post_make_rewrites = [ - (r'(#define FFMPEG_CONFIGURATION .*)', - r'/* \1 -- elide long configuration string from binary */') - ] - - if target_arch in ('arm', 'arm-neon', 'arm64'): - post_make_rewrites += [ - (r'(#define HAVE_VFP_ARGS [01])', - r'/* \1 -- softfp/hardfp selection is done by the chrome build */') - ] - - RewriteFile(os.path.join(config_dir, 'config.h'), post_make_rewrites) - - # Yay! create the token file so that we can skip this in the future. - with open(token_file, 'w'): - pass - - -def main(argv): - clean_arch_map = {k: '|'.join(v) for k, v in ARCH_MAP.items()} - formatted_usage_end = USAGE_END % clean_arch_map - parser = optparse.OptionParser(usage=USAGE_BEGIN + formatted_usage_end) - parser.add_option( - '--branding', - action='append', - dest='brandings', - choices=BRANDINGS, - help='Branding to build; determines e.g. supported codecs') - parser.add_option( - '--config-only', - action='store_true', - help='Skip the build step. Useful when a given platform ' - 'is not necessary for generate_gn.py') - parser.add_option( - '--fast', - action='store_true', - help='Skip building (successfully) if the success token file exists') - options, args = parser.parse_args(argv) - - if len(args) < 1: - parser.print_help() - return 1 - - target_os = args[0] - target_arch = '' - if len(args) >= 2: - target_arch = args[1] - configure_args = args[2:] - - - if target_os not in ('android', 'linux', 'linux-noasm', 'mac', 'win', 'all'): - parser.print_help() - return 1 - - host_tuple = DetermineHostOsAndArch() - if not host_tuple: - print('Unrecognized host OS and architecture.', file=sys.stderr) - return 1 - - host_os, host_arch = host_tuple - parallel_jobs = 8 - - if target_os.split('-', 1)[0] != host_os and (host_os != 'linux' or - host_arch != 'x64'): - print('Cross compilation can only be done from a linux x64 host.') - return 1 - - for os in ARCH_MAP.keys(): - if os != target_os and target_os != 'all': - continue - for arch in ARCH_MAP[os]: - if target_arch and arch != target_arch: - continue - - print('System information:\n' - 'Host OS : %s\n' - 'Target OS : %s\n' - 'Host arch : %s\n' - 'Target arch : %s\n' % (host_os, os, host_arch, arch)) - ConfigureAndBuild( - arch, - os, - host_os, - host_arch, - parallel_jobs, - configure_args, - options=options) - - -def ConfigureAndBuild(target_arch, target_os, host_os, host_arch, parallel_jobs, - configure_args, options): - if target_os == 'linux' and target_arch == 'noasm-x64': - target_os = 'linux-noasm' - target_arch = 'x64' - - configure_flags = collections.defaultdict(list) - - # Common configuration. Note: --disable-everything does not in fact disable - # everything, just non-library components such as decoders and demuxers. - configure_flags['Common'].extend([ - '--disable-everything', - '--disable-all', - '--disable-doc', - '--disable-htmlpages', - '--disable-manpages', - '--disable-podpages', - '--disable-txtpages', - '--disable-static', - '--enable-avcodec', - '--enable-avformat', - '--enable-avutil', - '--enable-fft', - '--enable-rdft', - '--enable-static', - '--enable-libopus', - - # Disable features. - '--disable-debug', - '--disable-bzlib', - '--disable-error-resilience', - '--disable-iconv', - '--disable-network', - '--disable-schannel', - '--disable-sdl2', - '--disable-symver', - '--disable-xlib', - '--disable-zlib', - '--disable-securetransport', - '--disable-faan', - '--disable-alsa', - - # Disable automatically detected external libraries. This prevents - # automatic inclusion of things like hardware decoders. Each roll should - # audit new [autodetect] configure options and add any desired options to - # this file. - '--disable-autodetect', - - # Common codecs. - '--enable-decoder=vorbis,libopus,flac', - '--enable-decoder=pcm_u8,pcm_s16le,pcm_s24le,pcm_s32le,pcm_f32le,mp3', - '--enable-decoder=pcm_s16be,pcm_s24be,pcm_mulaw,pcm_alaw', - '--enable-demuxer=ogg,matroska,wav,flac,mp3,mov', - '--enable-parser=opus,vorbis,flac,mpegaudio,vp9', - - # Setup include path so Chromium's libopus can be used. - '--extra-cflags=-I' + os.path.join(CHROMIUM_ROOT_DIR, - 'third_party/opus/src/include'), - - # Disable usage of Linux Performance API. Not used in production code, but - # missing system headers break some Android builds. - '--disable-linux-perf', - - # Force usage of nasm. - '--x86asmexe=nasm', - ]) - - if target_os == 'android': - configure_flags['Common'].extend([ - # This replaces --optflags="-Os" since it implies it and since if it is - # also specified, configure ends up dropping all optflags :/ - '--enable-small', - ]) - - configure_flags['Common'].extend(SetupAndroidToolchain(target_arch)) - else: - configure_flags['Common'].extend([ - # --optflags doesn't append multiple entries, so set all at once. - '--optflags="-O3"', - '--extra-cflags=-msse4.1', - '--extra-cflags=-O3', - '--enable-decoder=theora,vp8', - '--enable-parser=vp3,vp8', - ]) - - if target_os in ('linux', 'linux-noasm', 'android'): - if target_arch == 'x64': - if target_os == 'android': - configure_flags['Common'].extend([ - '--arch=x86_64', - ]) - else: - configure_flags['Common'].extend([ - '--enable-lto', - '--extra-cflags=-O3', - '--extra-cflags=-msse4.1', - '--arch=x86_64', - '--target-os=linux', - ]) - - if host_arch != 'x64': - configure_flags['Common'].extend([ - '--enable-cross-compile', - '--cross-prefix=/usr/bin/x86_64-linux-gnu-', - '--extra-cflags=--target=x86_64-linux-gnu', - '--extra-ldflags=--target=x86_64-linux-gnu', - ]) - elif target_arch == 'ia32': - configure_flags['Common'].extend([ - '--arch=i686', - '--extra-cflags="-m32"', - '--extra-ldflags="-m32"', - ]) - # Android ia32 can't handle textrels and ffmpeg can't compile without - # them. http://crbug.com/559379 - if target_os == 'android': - configure_flags['Common'].extend([ - '--disable-x86asm', - ]) - elif target_arch == 'arm' or target_arch == 'arm-neon': - # TODO(ihf): ARM compile flags are tricky. The final options - # overriding everything live in chroot /build/*/etc/make.conf - # (some of them coming from src/overlays/overlay-/make.conf). - # We try to follow these here closely. In particular we need to - # set ffmpeg internal #defines to conform to make.conf. - # TODO(ihf): For now it is not clear if thumb or arm settings would be - # faster. I ran experiments in other contexts and performance seemed - # to be close and compiler version dependent. In practice thumb builds are - # much smaller than optimized arm builds, hence we go with the global - # CrOS settings. - configure_flags['Common'].extend([ - '--arch=arm', - '--enable-armv6', - '--enable-armv6t2', - '--enable-vfp', - '--enable-thumb', - '--extra-cflags=-march=armv7-a', - ]) - - if target_os == 'android': - configure_flags['Common'].extend([ - # Runtime neon detection requires /proc/cpuinfo access, so ensure - # av_get_cpu_flags() is run outside of the sandbox when enabled. - '--enable-neon', - '--extra-cflags=-mtune=generic-armv7-a', - # Enabling softfp lets us choose either softfp or hardfp when doing - # the chrome build. - '--extra-cflags=-mfloat-abi=softfp', - ]) - if target_arch == 'arm': - print('arm-neon is the only supported arm arch for Android.\n') - return 1 - - if target_arch == 'arm-neon': - configure_flags['Common'].extend([ - '--extra-cflags=-mfpu=neon', - ]) - else: - configure_flags['Common'].extend([ - '--extra-cflags=-mfpu=vfpv3-d16', - ]) - else: - if host_arch != 'arm': - configure_flags['Common'].extend([ - '--enable-cross-compile', - '--target-os=linux', - '--extra-cflags=--target=arm-linux-gnueabihf', - '--extra-ldflags=--target=arm-linux-gnueabihf', - '--sysroot=' + os.path.join(CHROMIUM_ROOT_DIR, - 'build/linux/debian_bullseye_armhf-sysroot'), - '--extra-cflags=-mtune=cortex-a8', - # NOTE: we don't need softfp for this hardware. - '--extra-cflags=-mfloat-abi=hard', - # For some reason configure drops this... - '--extra-cflags=-O3', - ]) - - if target_arch == 'arm-neon': - configure_flags['Common'].extend([ - '--enable-neon', - '--extra-cflags=-mfpu=neon', - ]) - else: - configure_flags['Common'].extend([ - '--disable-neon', - '--extra-cflags=-mfpu=vfpv3-d16', - ]) - elif target_arch == 'arm64': - if target_os != 'android': - if host_arch != 'arm64': - configure_flags['Common'].extend([ - '--enable-cross-compile', - '--cross-prefix=/usr/bin/aarch64-linux-gnu-', - '--extra-cflags=--target=aarch64-linux-gnu', - '--extra-ldflags=--target=aarch64-linux-gnu', - ]) - - configure_flags['Common'].extend([ - '--target-os=linux', - '--sysroot=' + os.path.join(CHROMIUM_ROOT_DIR, - 'build/linux/debian_bullseye_arm64-sysroot'), - ]) - configure_flags['Common'].extend([ - '--arch=aarch64', - '--enable-armv8', - '--extra-cflags=-march=armv8-a', - ]) - elif target_arch == 'mipsel': - # These flags taken from android chrome build with target_cpu='mipsel' - configure_flags['Common'].extend([ - '--arch=mipsel', - '--disable-mips32r6', - '--disable-mips32r5', - '--disable-mips32r2', - '--disable-mipsdsp', - '--disable-mipsdspr2', - '--disable-msa', - '--enable-mipsfpu', - '--extra-cflags=-march=mipsel', - '--extra-cflags=-mcpu=mips32', - # Required to avoid errors about dynamic relocation w/o -fPIC. - '--extra-ldflags=-z notext', - ]) - if target_os == 'linux': - configure_flags['Common'].extend([ - '--enable-cross-compile', - '--target-os=linux', - '--sysroot=' + os.path.join(CHROMIUM_ROOT_DIR, - 'build/linux/debian_bullseye_mips-sysroot'), - '--extra-cflags=--target=mipsel-linux-gnu', - '--extra-ldflags=--target=mipsel-linux-gnu', - ]) - elif target_arch == 'mips64el': - # These flags taken from android chrome build with target_cpu='mips64el' - configure_flags['Common'].extend([ - '--arch=mips64el', - '--enable-mipsfpu', - '--disable-mipsdsp', - '--disable-mipsdspr2', - '--extra-cflags=-march=mips64el', - # Required to avoid errors about dynamic relocation w/o -fPIC. - '--extra-ldflags=-z notext', - ]) - if target_os == 'android': - configure_flags['Common'].extend([ - '--enable-mips64r6', - '--extra-cflags=-mcpu=mips64r6', - '--disable-mips64r2', - '--enable-msa', - ]) - if target_os == 'linux': - configure_flags['Common'].extend([ - '--enable-cross-compile', - '--target-os=linux', - '--sysroot=' + os.path.join( - CHROMIUM_ROOT_DIR, 'build/linux/debian_bullseye_mips64el-sysroot'), - '--enable-mips64r2', - '--disable-mips64r6', - '--disable-msa', - '--extra-cflags=-mcpu=mips64r2', - '--extra-cflags=--target=mips64el-linux-gnuabi64', - '--extra-ldflags=--target=mips64el-linux-gnuabi64', - ]) - else: - print( - 'Error: Unknown target arch %r for target OS %r!' % (target_arch, - target_os), - file=sys.stderr) - return 1 - - if target_os == 'linux-noasm': - configure_flags['Common'].extend([ - '--disable-asm', - '--disable-inline-asm', - ]) - - if 'win' not in target_os and 'android' not in target_os: - configure_flags['Common'].extend([ - '--enable-pic', - '--cc=clang', - '--cxx=clang++', - '--ld=clang', - ]) - - # Clang Linux will use the first 'ld' it finds on the path, which will - # typically be the system one, so explicitly configure use of Clang's - # ld.lld, to ensure that things like cross-compilation and LTO work. - # This does not work for ia32 and is always used on mac. - if target_arch != 'ia32' and target_os != 'mac': - configure_flags['Common'].append('--extra-ldflags=-fuse-ld=lld') - - # Should be run on Mac, unless we're cross-compiling on Linux. - if target_os == 'mac': - if host_os != 'mac' and host_os != 'linux': - print( - 'Script should be run on a Mac or Linux host.\n', - file=sys.stderr) - return 1 - - if host_os != 'mac': - configure_flags['Common'].extend( - SetupMacCrossCompileToolchain(target_arch)) - else: - # ffmpeg links against Chromium's libopus, which isn't built when this - # script runs. Suppress all undefined symbols (which matches the default - # on Linux), to get things to build. This also requires opting in to - # flat namespaces. - configure_flags['Common'].extend([ - '--extra-ldflags=-Wl,-flat_namespace -Wl,-undefined,warning', - ]) - - if target_arch == 'x64': - configure_flags['Common'].extend([ - '--arch=x86_64', - '--extra-cflags=-m64', - '--extra-ldflags=-arch x86_64', - ]) - elif target_arch == 'arm64': - configure_flags['Common'].extend([ - '--arch=arm64', - '--extra-cflags=-arch arm64', - '--extra-ldflags=-arch arm64', - ]) - else: - print( - 'Error: Unknown target arch %r for target OS %r!' % (target_arch, - target_os), - file=sys.stderr) - - # Should be run on Windows. - if target_os == 'win': - configure_flags['Common'].extend([ - '--toolchain=msvc', - '--extra-cflags=-I' + os.path.join(FFMPEG_DIR, 'chromium/include/win'), - ]) - - if target_arch == 'x64': - configure_flags['Common'].extend(['--target-os=win64']) - elif target_arch == 'x86': - configure_flags['Common'].extend(['--target-os=win32']) - - if host_os != 'win': - configure_flags['Common'].extend( - SetupWindowsCrossCompileToolchain(target_arch)) - - if 'CYGWIN_NT' in platform.system(): - configure_flags['Common'].extend([ - '--cc=cygwin-wrapper cl', - '--ld=cygwin-wrapper link', - '--nm=cygwin-wrapper dumpbin -symbols', - '--ar=cygwin-wrapper lib', - ]) - - # Google Chrome & ChromeOS specific configuration. - configure_flags['Chrome'].extend([ - '--enable-decoder=aac,h264,mp3,eac3,ac3,hevc,mpeg4,mpegvideo,mp2,mp1,flac', - '--enable-demuxer=aac,mp3,mov,dtshd,dts,avi,mpegvideo,m4v,h264,vc1,flac', - '--enable-parser=aac,h264,hevc,mpegaudio,mpeg4video,mpegvideo,ac3,h261,vc1,h263,flac', - ]) - - # Google ChromeOS specific configuration. - # We want to make sure to play everything Android generates and plays. - # http://developer.android.com/guide/appendix/media-formats.html - configure_flags['ChromeOS'].extend([ - # Enable playing avi files. - '--enable-decoder=mpeg4', - '--enable-parser=h263,mpeg4video', - '--enable-demuxer=avi', - # Enable playing Android 3gp files. - '--enable-demuxer=amr', - '--enable-decoder=amrnb,amrwb', - # Wav files for playing phone messages. - '--enable-decoder=gsm_ms', - '--enable-parser=gsm', - ]) - - configure_flags['ChromeAndroid'].extend([ - '--enable-demuxer=aac', - '--enable-parser=aac', - '--enable-decoder=aac', - - # TODO(dalecurtis, watk): Figure out if we need h264 parser for now? - ]) - - def do_build_ffmpeg(branding, configure_flags): - if options.brandings and branding not in options.brandings: - print('%s skipped' % branding) - return - - print('%s configure/build:' % branding) - BuildFFmpeg(target_os, target_arch, host_os, host_arch, parallel_jobs, - options.config_only, branding, configure_flags, options) - - # Only build Chromium, Chrome for ia32, x86 non-android platforms. - if target_os != 'android': - do_build_ffmpeg( - 'Chromium', configure_flags['Common'] + configure_flags['Chromium'] + - configure_args) - do_build_ffmpeg( - 'Chrome', - configure_flags['Common'] + configure_flags['Chrome'] + configure_args) - else: - do_build_ffmpeg('Chromium', configure_flags['Common'] + configure_args) - do_build_ffmpeg( - 'Chrome', configure_flags['Common'] + configure_flags['ChromeAndroid'] + - configure_args) - - if target_os in ['linux', 'linux-noasm']: - # ChromeOS enables MPEG4 which requires error resilience :( - chrome_os_flags = ( - configure_flags['Common'] + configure_flags['Chrome'] + - configure_flags['ChromeOS'] + configure_args) - chrome_os_flags.remove('--disable-error-resilience') - do_build_ffmpeg('ChromeOS', chrome_os_flags) - - print('Done. If desired you may copy config.h/config.asm into the ' - 'source/config tree using copy_config.sh.') - return 0 - - -if __name__ == '__main__': - sys.exit(main(sys.argv[1:])) diff --git a/other/CrOS/v8/BUILD.gn b/other/CrOS/v8/BUILD.gn index 5de39cfa..bea65283 100644 --- a/other/CrOS/v8/BUILD.gn +++ b/other/CrOS/v8/BUILD.gn @@ -12,10 +12,6 @@ import("//build/config/riscv.gni") import("//build/config/sanitizers/sanitizers.gni") import("//build_overrides/build.gni") -if (is_android) { - import("//build/config/android/rules.gni") -} - import("gni/snapshot_toolchain.gni") import("gni/v8.gni") @@ -323,6 +319,10 @@ declare_args() { # Sets -DV8_ENABLE_SANDBOX. v8_enable_sandbox = "" + # Enable experimental code pointer sandboxing for the V8 sandbox. + # Sets -DV8_CODE_POINTER_SANDBOXING + v8_code_pointer_sandboxing = false + # Expose the memory corruption API to JavaScript. Useful for testing the sandbox. # WARNING This will expose builtins that (by design) cause memory corruption. # Sets -DV8_EXPOSE_MEMORY_CORRUPTION_API @@ -372,13 +372,6 @@ declare_args() { # (incomplete and experimental). v8_enable_cet_shadow_stack = false - # Get VMEX priviledge at startup. - # It allows to run V8 without "deprecated-ambient-replace-as-executable". - # Sets -DV8_USE_VMEX_RESOURCE. - # TODO(victorgomes): Remove this flag once Chormium no longer needs - # the deprecated feature. - v8_fuchsia_use_vmex_resource = is_fuchsia && !build_with_chromium - # Enables pointer compression for 8GB heaps. # Sets -DV8_COMPRESS_POINTERS_8GB. v8_enable_pointer_compression_8gb = "" @@ -397,6 +390,10 @@ declare_args() { # iOS (non-simulator) does not have executable pages for 3rd party # applications yet so disable jit. v8_jitless = v8_enable_lite_mode || target_is_ios_device + + # Enable Maglev's graph printer. + # Sets -DV8_MAGLEV_GRAPH_PRINTER. + v8_enable_maglev_graph_printer = !build_with_chromium } # Derived defaults. @@ -476,13 +473,13 @@ if (v8_enable_short_builtin_calls == "") { if (v8_enable_external_code_space == "") { v8_enable_external_code_space = v8_enable_pointer_compression && - (v8_current_cpu == "x64" || - (target_os != "fuchsia" && v8_current_cpu == "arm64")) + (v8_current_cpu == "x64" || v8_current_cpu == "arm64") } if (v8_enable_maglev == "") { v8_enable_maglev = v8_enable_turbofan && - (v8_current_cpu == "x64" || v8_current_cpu == "arm64") && - v8_enable_pointer_compression + (v8_current_cpu == "arm" || + ((v8_current_cpu == "x64" || v8_current_cpu == "arm64") && + v8_enable_pointer_compression)) } assert(v8_enable_turbofan || !v8_enable_maglev, "Maglev is not available when Turbofan is disabled.") @@ -645,6 +642,9 @@ assert(!v8_enable_sandbox || v8_enable_pointer_compression_shared_cage, assert(!v8_enable_sandbox || v8_enable_external_code_space, "The sandbox requires the external code space") +assert(!v8_code_pointer_sandboxing || v8_enable_sandbox, + "Code pointer sandboxing requires the sandbox") + assert(!v8_expose_memory_corruption_api || v8_enable_sandbox, "The Memory Corruption API requires the sandbox") @@ -678,10 +678,6 @@ if (v8_enable_single_generation == true) { "Requires unconditional write barriers or none (which disables incremental marking)") } -if (v8_fuchsia_use_vmex_resource) { - assert(target_os == "fuchsia", "VMEX resource only available on Fuchsia") -} - assert(!v8_enable_snapshot_compression || v8_use_zlib, "Snapshot compression requires zlib") @@ -724,7 +720,9 @@ config("internal_config") { } if (v8_current_cpu == "riscv64" || v8_current_cpu == "riscv32") { - libs = [ "atomic" ] + if (!is_clang) { + libs = [ "atomic" ] + } } } @@ -796,7 +794,9 @@ config("external_config") { } if (current_cpu == "riscv64" || current_cpu == "riscv32") { - libs = [ "atomic" ] + if (!is_clang) { + libs = [ "atomic" ] + } } } @@ -1142,9 +1142,6 @@ config("features") { if (v8_advanced_bigint_algorithms) { defines += [ "V8_ADVANCED_BIGINT_ALGORITHMS" ] } - if (v8_fuchsia_use_vmex_resource) { - defines += [ "V8_USE_VMEX_RESOURCE" ] - } if (v8_expose_memory_corruption_api) { defines += [ "V8_EXPOSE_MEMORY_CORRUPTION_API" ] } @@ -1169,6 +1166,12 @@ config("features") { if (v8_enable_wasm_simd256_revec) { defines += [ "V8_ENABLE_WASM_SIMD256_REVEC" ] } + if (v8_code_pointer_sandboxing) { + defines += [ "V8_CODE_POINTER_SANDBOXING" ] + } + if (v8_enable_maglev_graph_printer) { + defines += [ "V8_ENABLE_MAGLEV_GRAPH_PRINTER" ] + } } config("toolchain") { @@ -1313,6 +1316,12 @@ config("toolchain") { defines += [ "V8_TARGET_ARCH_RISCV32" ] defines += [ "__riscv_xlen=32" ] defines += [ "CAN_USE_FPU_INSTRUCTIONS" ] + + # TODO(riscv32): Add condition riscv_use_rvv and riscv_rvv_vlen here after + # 4538202 merge. + if (target_is_simulator) { + defines += [ "CAN_USE_RVV_INSTRUCTIONS" ] + } } if (v8_current_cpu == "x86") { @@ -1339,7 +1348,6 @@ config("toolchain") { } if (is_android && v8_android_log_stdout) { defines += [ "V8_ANDROID_LOG_STDOUT" ] - cflags += [ "-O3" ] } # V8_TARGET_OS_ defines. The target OS may differ from host OS e.g. in @@ -1408,15 +1416,18 @@ config("toolchain") { "-Wmissing-field-initializers", "-Wunreachable-code", - # Google3 enables this warning, so we should also enable it to find issue - # earlier. See https://reviews.llvm.org/D56731 for details about this - # warning. - "-Wctad-maybe-unsupported", - # TODO(v8:12245): Fix shadowing instances and remove. "-Wno-shadow", ] + # TODO(fuchsia:127411): Re-enable once FIDL bindings are compatible. + if (!is_fuchsia) { + # Google3 enables this warning, so we should also enable it to find issue + # earlier. See https://reviews.llvm.org/D56731 for details about this + # warning. + cflags += [ "-Wctad-maybe-unsupported" ] + } + if (v8_current_cpu == "x64" || v8_current_cpu == "arm64" || v8_current_cpu == "mips64el" || v8_current_cpu == "riscv64") { cflags += [ "-Wshorten-64-to-32" ] @@ -1760,6 +1771,7 @@ if (v8_postmortem_support) { "src/objects/string-inl.h", "src/objects/struct.h", "src/objects/struct-inl.h", + "src/objects/tagged.h", ] outputs = [ "$target_gen_dir/debug-support.cc" ] @@ -1826,9 +1838,11 @@ torque_files = [ "src/builtins/iterator.tq", "src/builtins/iterator-from.tq", "src/builtins/iterator-helpers.tq", + "src/builtins/map-groupby.tq", "src/builtins/math.tq", "src/builtins/number.tq", "src/builtins/object-fromentries.tq", + "src/builtins/object-groupby.tq", "src/builtins/object.tq", "src/builtins/promise-abstract-operations.tq", "src/builtins/promise-all.tq", @@ -1864,6 +1878,8 @@ torque_files = [ "src/builtins/regexp-split.tq", "src/builtins/regexp-test.tq", "src/builtins/regexp.tq", + "src/builtins/set-intersection.tq", + "src/builtins/set-union.tq", "src/builtins/string-at.tq", "src/builtins/string-endswith.tq", "src/builtins/string-html.tq", @@ -2003,6 +2019,7 @@ if (v8_enable_i18n_support) { if (v8_enable_webassembly) { torque_files += [ + "src/builtins/js-to-wasm.tq", "src/builtins/wasm.tq", "src/debug/debug-wasm-objects.tq", "src/wasm/wasm-objects.tq", @@ -3082,6 +3099,7 @@ v8_header_set("v8_internal_headers") { "src/compiler/js-create-lowering.h", "src/compiler/js-generic-lowering.h", "src/compiler/js-graph.h", + "src/compiler/js-heap-broker-inl.h", "src/compiler/js-heap-broker.h", "src/compiler/js-inlining-heuristic.h", "src/compiler/js-inlining.h", @@ -3181,7 +3199,6 @@ v8_header_set("v8_internal_headers") { "src/compiler/turboshaft/store-store-elimination-phase.h", "src/compiler/turboshaft/store-store-elimination-reducer.h", "src/compiler/turboshaft/structural-optimization-reducer.h", - "src/compiler/turboshaft/tag-untag-lowering-reducer.h", "src/compiler/turboshaft/tracing.h", "src/compiler/turboshaft/type-assertions-phase.h", "src/compiler/turboshaft/type-inference-analysis.h", @@ -3361,6 +3378,7 @@ v8_header_set("v8_internal_headers") { "src/heap/marking-worklist.h", "src/heap/marking.h", "src/heap/memory-allocator.h", + "src/heap/memory-balancer.h", "src/heap/memory-chunk-inl.h", "src/heap/memory-chunk-layout.h", "src/heap/memory-chunk.h", @@ -3377,6 +3395,7 @@ v8_header_set("v8_internal_headers") { "src/heap/paged-spaces-inl.h", "src/heap/paged-spaces.h", "src/heap/parallel-work-item.h", + "src/heap/parked-scope-inl.h", "src/heap/parked-scope.h", "src/heap/pretenuring-handler-inl.h", "src/heap/pretenuring-handler.h", @@ -3649,6 +3668,7 @@ v8_header_set("v8_internal_headers") { "src/objects/tagged-index.h", "src/objects/tagged-value-inl.h", "src/objects/tagged-value.h", + "src/objects/tagged.h", "src/objects/template-objects-inl.h", "src/objects/template-objects.h", "src/objects/templates-inl.h", @@ -3733,6 +3753,10 @@ v8_header_set("v8_internal_headers") { "src/runtime/runtime.h", "src/sandbox/bounded-size-inl.h", "src/sandbox/bounded-size.h", + "src/sandbox/code-pointer-inl.h", + "src/sandbox/code-pointer-table-inl.h", + "src/sandbox/code-pointer-table.h", + "src/sandbox/code-pointer.h", "src/sandbox/external-entity-table-inl.h", "src/sandbox/external-entity-table.h", "src/sandbox/external-pointer-inl.h", @@ -3752,6 +3776,7 @@ v8_header_set("v8_internal_headers") { "src/snapshot/embedded/embedded-file-writer-interface.h", "src/snapshot/object-deserializer.h", "src/snapshot/read-only-deserializer.h", + "src/snapshot/read-only-serializer-deserializer.h", "src/snapshot/read-only-serializer.h", "src/snapshot/references.h", "src/snapshot/roots-serializer.h", @@ -3856,7 +3881,9 @@ v8_header_set("v8_internal_headers") { "src/maglev/maglev-register-frame-array.h", "src/maglev/maglev.h", ] - if (v8_current_cpu == "arm64") { + if (v8_current_cpu == "arm") { + sources += [ "src/maglev/arm/maglev-assembler-arm-inl.h" ] + } else if (v8_current_cpu == "arm64") { sources += [ "src/maglev/arm64/maglev-assembler-arm64-inl.h" ] } else if (v8_current_cpu == "x64") { sources += [ "src/maglev/x64/maglev-assembler-x64-inl.h" ] @@ -3871,6 +3898,7 @@ v8_header_set("v8_internal_headers") { "src/asmjs/asm-scanner.h", "src/asmjs/asm-types.h", "src/compiler/int64-lowering.h", + "src/compiler/turboshaft/wasm-js-lowering-reducer.h", "src/compiler/wasm-address-reassociation.h", "src/compiler/wasm-call-descriptors.h", "src/compiler/wasm-compiler-definitions.h", @@ -3881,6 +3909,7 @@ v8_header_set("v8_internal_headers") { "src/compiler/wasm-graph-assembler.h", "src/compiler/wasm-inlining-into-js.h", "src/compiler/wasm-inlining.h", + "src/compiler/wasm-js-lowering.h", "src/compiler/wasm-load-elimination.h", "src/compiler/wasm-loop-peeling.h", "src/compiler/wasm-typer.h", @@ -4538,6 +4567,7 @@ if (v8_enable_webassembly) { "src/compiler/wasm-graph-assembler.cc", "src/compiler/wasm-inlining-into-js.cc", "src/compiler/wasm-inlining.cc", + "src/compiler/wasm-js-lowering.cc", "src/compiler/wasm-load-elimination.cc", "src/compiler/wasm-loop-peeling.cc", "src/compiler/wasm-typer.cc", @@ -4889,6 +4919,7 @@ v8_source_set("v8_base_without_compiler") { "src/heap/marking-worklist.cc", "src/heap/marking.cc", "src/heap/memory-allocator.cc", + "src/heap/memory-balancer.cc", "src/heap/memory-chunk-layout.cc", "src/heap/memory-chunk.cc", "src/heap/memory-measurement.cc", @@ -5100,6 +5131,7 @@ v8_source_set("v8_base_without_compiler") { "src/runtime/runtime-typedarray.cc", "src/runtime/runtime-weak-refs.cc", "src/runtime/runtime.cc", + "src/sandbox/code-pointer-table.cc", "src/sandbox/external-pointer-table.cc", "src/sandbox/sandbox.cc", "src/sandbox/testing.cc", @@ -5174,7 +5206,12 @@ v8_source_set("v8_base_without_compiler") { "src/maglev/maglev-regalloc.cc", "src/maglev/maglev.cc", ] - if (v8_current_cpu == "arm64") { + if (v8_current_cpu == "arm") { + sources += [ + "src/maglev/arm/maglev-assembler-arm.cc", + "src/maglev/arm/maglev-ir-arm.cc", + ] + } else if (v8_current_cpu == "arm64") { sources += [ "src/maglev/arm64/maglev-assembler-arm64.cc", "src/maglev/arm64/maglev-ir-arm64.cc", @@ -5589,7 +5626,9 @@ v8_source_set("v8_base_without_compiler") { v8_current_cpu == "ppc" || v8_current_cpu == "ppc64" || v8_current_cpu == "s390" || v8_current_cpu == "s390x" || v8_current_cpu == "riscv64" || v8_current_cpu == "riscv32") { - libs += [ "atomic" ] + if (!is_clang) { + libs += [ "atomic" ] + } } if (v8_enable_vtunetracemark && (is_linux || is_chromeos || is_win)) { @@ -5936,8 +5975,8 @@ v8_component("v8_libbase") { "src/base/platform/platform-fuchsia.cc", ] deps += [ - "//third_party/fuchsia-sdk/sdk/fidl/fuchsia.kernel", - "//third_party/fuchsia-sdk/sdk/pkg/fdio", + "//third_party/fuchsia-sdk/sdk/fidl/fuchsia.kernel:fuchsia.kernel_cpp", + "//third_party/fuchsia-sdk/sdk/pkg/component_incoming_cpp", "//third_party/fuchsia-sdk/sdk/pkg/zx", ] } else if (is_mac) { @@ -5989,7 +6028,9 @@ v8_component("v8_libbase") { } if (v8_current_cpu == "riscv64" || v8_current_cpu == "riscv32") { - libs += [ "atomic" ] + if (!is_clang) { + libs += [ "atomic" ] + } } if (is_tsan && !build_with_chromium) { @@ -6099,7 +6140,9 @@ v8_component("v8_libplatform") { } if (v8_current_cpu == "riscv64" || v8_current_cpu == "riscv32") { - libs = [ "atomic" ] + if (!is_clang) { + libs = [ "atomic" ] + } } } @@ -7038,7 +7081,9 @@ v8_executable("cppgc_hello_world") { sources = [ "samples/cppgc/hello-world.cc" ] if (v8_current_cpu == "riscv64" || v8_current_cpu == "riscv32") { - libs = [ "atomic" ] + if (!is_clang) { + libs = [ "atomic" ] + } } configs = [ diff --git a/other/SSE2/third_party/ffmpeg/chromium/scripts/build_ffmpeg.py b/other/SSE2/third_party/ffmpeg/chromium/scripts/build_ffmpeg.py deleted file mode 100755 index 7a0db30a..00000000 --- a/other/SSE2/third_party/ffmpeg/chromium/scripts/build_ffmpeg.py +++ /dev/null @@ -1,1076 +0,0 @@ -#!/usr/bin/env python3 -# -# Copyright 2023 The Chromium Authors, Alex313031, and Midzer. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -from __future__ import print_function - -import atexit -import collections -import functools -import glob -import optparse -import os -import platform -import re -import shlex -import shutil -import signal -import subprocess -import sys -import tempfile - -SCRIPTS_DIR = os.path.abspath(os.path.dirname(__file__)) -FFMPEG_DIR = os.path.abspath(os.path.join(SCRIPTS_DIR, '..', '..')) -CHROMIUM_ROOT_DIR = os.path.abspath(os.path.join(FFMPEG_DIR, '..', '..')) -NDK_ROOT_DIR = os.path.abspath( - os.path.join(CHROMIUM_ROOT_DIR, 'third_party', 'android_ndk')) -SUCCESS_TOKEN = 'THIS_BUILD_WORKED' - -sys.path.append(os.path.join(CHROMIUM_ROOT_DIR, 'build')) -import gn_helpers - -BRANDINGS = [ - 'Chrome', - 'ChromeOS', - 'Chromium', -] - -ARCH_MAP = { - 'android': ['ia32', 'x64', 'arm-neon', 'arm64'], - 'linux': [ - 'ia32', 'x64', 'noasm-x64', 'arm', 'arm-neon', 'arm64' - ], - 'mac': ['x64', 'arm64'], - 'win': ['ia32', 'x64', 'arm64'], -} - -USAGE_BEGIN = """Usage: %prog TARGET_OS TARGET_ARCH [options] -- [configure_args]""" -USAGE_END = """ -Valid combinations are android [%(android)s] - linux [%(linux)s] - mac [%(mac)s] - win [%(win)s] - -If no target architecture is specified all will be built. - -Platform specific build notes: - android: - Script can be run on a normal x64 Ubuntu box with an Android-ready Chromium - checkout: https://chromium.googlesource.com/chromium/src/+/master/docs/android_build_instructions.md - - linux ia32/x64: - Script can run on a normal Ubuntu box. - - linux arm/arm-neon/arm64/mipsel/mips64el: - Script can run on a normal Ubuntu with ARM/ARM64 or MIPS32/MIPS64 ready Chromium checkout: - build/linux/sysroot_scripts/install-sysroot.py --arch=arm - build/linux/sysroot_scripts/install-sysroot.py --arch=arm64 - build/linux/sysroot_scripts/install-sysroot.py --arch=mips - build/linux/sysroot_scripts/install-sysroot.py --arch=mips64el - - mac: - Script must be run on Linux or macOS. Additionally, ensure the Chromium - (not Apple) version of clang is in the path; usually found under - src/third_party/llvm-build/Release+Asserts/bin - - The arm64 version has to be built with an SDK that can build mac/arm64 - binaries -- currently Xcode 12 beta and its included 11.0 SDK. You must - pass --enable-cross-compile to be able to build ffmpeg for mac/arm64 on an - Intel Mac. On a Mac, run like so: - PATH=$PWD/../../third_party/llvm-build/Release+Asserts/bin:$PATH \ - SDKROOT=/Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.0.sdk \ - chromium/scripts/build_ffmpeg.py mac arm64 -- --enable-cross-compile - - On Linux, the normal robosushi flow will work for arm64. - - win: - Script may be run unders Linux or Windows; if cross-compiling you will need - to follow the Chromium instruction for Cross-compiling Chrome/win: - https://chromium.googlesource.com/chromium/src/+/master/docs/win_cross.md - - Once you have a working Chromium build that can cross-compile, you'll also - need to run $chrome_dir/tools/clang/scripts/update.py --package=objdump to - pick up the llvm-ar and llvm-nm tools. You can then build as normal. - - If not cross-compiling, script must be run on Windows with VS2015 or higher - under Cygwin (or MinGW, but as of 1.0.11, it has serious performance issues - with make which makes building take hours). - - Additionally, ensure you have the correct toolchain environment for building. - The x86 toolchain environment is required for ia32 builds and the x64 one - for x64 builds. This can be verified by running "cl.exe" and checking if - the version string ends with "for x64" or "for x86." - - Building on Windows also requires some additional Cygwin packages plus a - wrapper script for converting Cygwin paths to DOS paths. - - Add these packages at install time: diffutils, nasm, make, python. - - Copy chromium/scripts/cygwin-wrapper to /usr/local/bin - -Resulting binaries will be placed in: - build.TARGET_ARCH.TARGET_OS/Chrome/ - build.TARGET_ARCH.TARGET_OS/ChromeOS/ - build.TARGET_ARCH.TARGET_OS/Chromium/ - """ - - -def PrintAndCheckCall(argv, *args, **kwargs): - print('Running %s' % '\n '.join(argv)) - subprocess.check_call(argv, *args, **kwargs) - - -def DetermineHostOsAndArch(): - if platform.system() == 'Linux': - host_os = 'linux' - elif platform.system() == 'Darwin': - host_os = 'mac' - elif platform.system() == 'Windows' or 'CYGWIN_NT' in platform.system(): - host_os = 'win' - else: - return None - - if re.match(r'i.86', platform.machine()): - host_arch = 'ia32' - elif platform.machine() == 'x86_64' or platform.machine() == 'AMD64': - host_arch = 'x64' - elif platform.machine() == 'aarch64': - host_arch = 'arm64' - elif platform.machine() == 'mips32': - host_arch = 'mipsel' - elif platform.machine() == 'mips64': - host_arch = 'mips64el' - elif platform.machine().startswith('arm'): - host_arch = 'arm' - else: - return None - - return (host_os, host_arch) - - -def GetDsoName(target_os, dso_name, dso_version): - if target_os in ('linux', 'linux-noasm', 'android'): - return 'lib%s.so.%s' % (dso_name, dso_version) - elif target_os == 'mac': - return 'lib%s.%s.dylib' % (dso_name, dso_version) - elif target_os == 'win': - return '%s-%s.dll' % (dso_name, dso_version) - else: - raise ValueError('Unexpected target_os %s' % target_os) - - -def RewriteFile(path, search_replace): - with open(path) as f: - contents = f.read() - with open(path, 'w') as f: - for search, replace in search_replace: - contents = re.sub(search, replace, contents) - f.write(contents) - - -# Class for determining the 32-bit and 64-bit Android API levels that Chromium -# uses. Since @functools.cache is not available for easy memoization of the -# determination result, we use a lazy singleton instance constructed by calling -# Get(). -class AndroidApiLevels: - __instance = None - - # Extracts the Android API levels from the Chromium Android GN config. - # Before Q1 2021, these were grep'able from build/config/android/config.gni. - # With conditional logic introduced in that gni file, we seek to avoid fragility - # going forwards, at the cost of creating a full temporary GN Chromium Android - # build configuration just to extract the API levels here. Caches the results - # in api32 and api64 instance variables. - def Setup(self): - print('Creating a temporary GN config to retrieve Android API levels:') - - # Make a temporary GN build output folder - # No tempfile.TemporaryDirectory until python 3.2, so instead: - tmp_dir = tempfile.mkdtemp(prefix = 'android_build_ffmpeg_for_api_level_config') - print('Created temporary directory ' + tmp_dir) - - # Populate that GN build output folder with generated config for Android as - # target OS. - with open(os.path.join(tmp_dir, 'args.gn'), 'w') as args_gn_file: - args_gn_file.write('target_os = "android"\n') - print('Created ' + os.path.realpath(args_gn_file.name)) - - # Ask GN to generate build files. - PrintAndCheckCall(['gn', 'gen', tmp_dir], cwd=CHROMIUM_ROOT_DIR) - - # Query the API levels in the generated build config. - print('Retrieving config vars') - config_output = subprocess.check_output( - ['gn', 'args', tmp_dir, '--short', '--list'], - cwd=CHROMIUM_ROOT_DIR).decode('utf-8') - - # Remove the temporary GN build output folder - print('removing temp dir ' + tmp_dir) - shutil.rmtree(tmp_dir, ignore_errors=False) - - api64_match = re.search(r'android64_ndk_api_level\s*=\s*(\d{2})', - config_output) - api32_match = re.search(r'android32_ndk_api_level\s*=\s*(\d{2})', - config_output) - if not api32_match or not api64_match: - raise Exception('Failed to find the android api levels') - - self.api32 = api32_match.group(1) - self.api64 = api64_match.group(1) - - def ApiLevels(self): - return (self.api32, self.api64) - - @classmethod - def Get(cls): - if cls.__instance is None: - cls.__instance = AndroidApiLevels() - cls.__instance.Setup() - return cls.__instance.ApiLevels() - - -# Sets up cross-compilation (specific to host being linux-x64_64) for compiling -# Android. -# Returns the necessary configure flags as a list. -# See also https://developer.android.com/ndk/guides/other_build_systems -# As of M90, //third_party/android_ndk no longer includes mipsel or mips64el -# toolchains; they were not previously supported by default by this script, and -# currently are unsupported due to lack of toolchain in checkout. -def SetupAndroidToolchain(target_arch): - api_level, api64_level = AndroidApiLevels.Get() - print('Determined Android API levels: 32bit=' + api_level + - ', 64bit=' + api64_level) - - # Toolchain prefix misery, for when just one pattern is not enough :/ - toolchain_level = api_level - toolchain_bin_prefix = target_arch - - if target_arch == 'arm-neon' or target_arch == 'arm': - toolchain_bin_prefix = 'arm-linux-androideabi' - elif target_arch == 'arm64': - toolchain_level = api64_level - toolchain_bin_prefix = 'aarch64-linux-android' - elif target_arch == 'ia32': - toolchain_bin_prefix = 'i686-linux-android' - elif target_arch == 'x64': - toolchain_level = api64_level - toolchain_bin_prefix = 'x86_64-linux-android' - elif target_arch == 'mipsel': # Unsupported beginning in M90 - toolchain_bin_prefix = 'mipsel-linux-android' - elif target_arch == 'mips64el': # Unsupported beginning in M90 - toolchain_level = api64_level - toolchain_bin_prefix = 'mips64el-linux-android' - - clang_toolchain_dir = NDK_ROOT_DIR + '/toolchains/llvm/prebuilt/linux-x86_64/' - - # Big old nasty hack here, beware! The new android ndk has some foolery with - # libgcc.a -- clang still uses gcc for its linker when cross compiling. - # It can't just be that simple though - the |libgcc.a| file is actually a - # super secret linkerscript which links libgcc_real.a, because apparently - # someone decided that more flags are needed, including -lunwind; thats where - # our story begins. ffmpeg doesn't use linunwind, and we dont really have a - # good way to get a cross-compiled version anyway, but this silly linker - # script insists that we must link with it, or face all sorts of horrible - # consequences -- namely configure failures. Anyway, there is a way around it: - # the "big old nasty hack" mentioned what feels like forever ago now. It's - # simple, we uhh, kill tha batman. Actually we just make a fake libunwind.a - # linker script and drop it someplace nobody will ever find, like I dunno, say - # /tmp/fakelinkerscripts or something. Then we add that path to the ldflags - # flags and everything works again. - fakedir = '/tmp/fakelinkerscripts' - os.system('mkdir -p {fakedir} && touch {fakedir}/libunwind.a'.format( - fakedir=fakedir)) - - return [ - '--enable-pic', - '--cc=' + clang_toolchain_dir + 'bin/clang', - '--cxx=' + clang_toolchain_dir + 'bin/clang++', - '--ld=' + clang_toolchain_dir + 'bin/clang', - '--enable-cross-compile', - '--sysroot=' + clang_toolchain_dir + 'sysroot', - '--extra-cflags=-I' + clang_toolchain_dir + 'sysroot/usr/include', - '--extra-cflags=-I' + clang_toolchain_dir + 'sysroot/usr/include/' + - toolchain_bin_prefix, - '--extra-cflags=--target=' + toolchain_bin_prefix + toolchain_level, - '--extra-ldflags=--target=' + toolchain_bin_prefix + toolchain_level, - '--extra-ldflags=-L{}'.format(fakedir), - '--extra-ldflags=-L' + clang_toolchain_dir + toolchain_bin_prefix, - '--extra-ldflags=--gcc-toolchain=' + clang_toolchain_dir, - '--target-os=android', - ] - - -def SetupWindowsCrossCompileToolchain(target_arch): - # First retrieve various MSVC and Windows SDK paths. - output = subprocess.check_output([ - os.path.join(CHROMIUM_ROOT_DIR, 'build', 'vs_toolchain.py'), - 'get_toolchain_dir' - ]).decode('utf-8') - - new_args = [ - '--enable-cross-compile', - '--cc=clang-cl', - '--ld=lld-link', - '--nm=llvm-nm', - '--ar=llvm-ar', - - # Separate from optflags because configure strips it from msvc builds... - '--extra-cflags=-O3', - ] - - if target_arch == 'ia32': - new_args += ['--extra-cflags=-m32'] - if target_arch == 'ia32': - target_arch = 'x86' - if target_arch == 'arm64': - new_args += [ - # With ASM enabled, an ARCH must be specified. - '--arch=aarch64', - # When cross-compiling (from Linux), armasm64.exe is not available. - '--as=clang-cl', - # FFMPEG is not yet enlightened for ARM64 Windows. - # Imitate Android workaround. - '--extra-cflags=--target=arm64-windows' - ] - - # Turn this into a dictionary. - win_dirs = gn_helpers.FromGNArgs(output) - - # Use those paths with a second script which will tell us the proper lib paths - # to specify for ldflags. - output = subprocess.check_output([ - 'python3', - os.path.join(CHROMIUM_ROOT_DIR, 'build', 'toolchain', 'win', - 'setup_toolchain.py'), win_dirs['vs_path'], - win_dirs['sdk_path'], win_dirs['runtime_dirs'], 'win', target_arch, 'none' - ]).decode('utf-8') - - flags = gn_helpers.FromGNArgs(output) - - # Q1 2021 update to LLVM now lets us use a sysroot for cross-compilation - # targeting Windows, instead of specificying a variety of individual include - # folders which now include whitespace within paths within the SDK. Either - # injection of such paths into environment variable or using the new sysroot - # option is required, since using a /tmp symlink solution to avoid the spaces - # broke cross-compilation for win-arm64. For at least now, we'll use the - # sysroot approach, until and unless the environment variable injection - # approach is determined to be better or more consistent. - new_args += [ - '--extra-cflags=/winsysroot' + win_dirs['vs_path'], - '--extra-ldflags=/winsysroot:' + win_dirs['vs_path'], - ] - - # FFmpeg configure doesn't like arguments with spaces in them even if quoted - # or double-quoted or escape-quoted (whole argument and/or the internal - # spaces). To automate this for now, every path that has a space in it is - # replaced with a symbolic link created in the OS' temp folder to the real - # path. - def do_remove_temp_link(temp_name): - assert os.path.exists(temp_name) - assert os.path.islink(temp_name) - print('Removing temporary link ' + temp_name) - os.remove(temp_name) - - def do_make_temp_link(real_target): - temp_file = tempfile.NamedTemporaryFile(prefix='windows_build_ffmpeg') - temp_name = temp_file.name - # Destroy |temp_file|, but reuse its name for the symbolic link which - # survives this helper method. - temp_file.close() - os.symlink(real_target, temp_name) - assert os.path.exists(temp_name) - assert os.path.islink(temp_name) - atexit.register(do_remove_temp_link, temp_name) - return temp_name - - return new_args - - -def SetupMacCrossCompileToolchain(target_arch): - # First compute the various SDK paths. - mac_min_ver = '10.10' - developer_dir = os.path.join(CHROMIUM_ROOT_DIR, 'build', 'mac_files', - 'xcode_binaries', 'Contents', 'Developer') - sdk_dir = os.path.join(developer_dir, 'Platforms', 'MacOSX.platform', - 'Developer', 'SDKs', 'MacOSX.sdk') - - if target_arch == 'x64': - target_triple = 'x86_64-apple-macosx' - elif target_arch == 'arm64': - target_triple = 'arm64-apple-macosx' - else: - raise Exception("unknown arch " + target_arch) - - # We're guessing about the right sdk path, so warn if we don't find it. - if not os.path.exists(sdk_dir): - print (sdk_dir) - raise Exception("Can't find the mac sdk. Please see crbug.com/841826") - - frameworks_dir = os.path.join(sdk_dir, "System", "Library", "Frameworks") - libs_dir = os.path.join(sdk_dir, "usr", "lib") - - new_args = [ - '--enable-cross-compile', - '--cc=clang', - # This is replaced with fake_linker.py further down. We need a real linker - # at configure time for a few configure checks. These checks only link - # very basic programs, so it's ok to use ld64.lld, even though it's not - # generally production quality. - '--ld=ld64.lld', - '--nm=llvm-nm', - '--ar=llvm-ar', - '--target-os=darwin', - - '--extra-cflags=--target=' + target_triple, - '--extra-cflags=-F' + frameworks_dir, - '--extra-cflags=-mmacosx-version-min=' + mac_min_ver - ] - - # We need to pass -nostdinc so that clang does not pick up linux headers, - # but then it also can't find its own headers like stddef.h. So tell it - # where to look for those headers. - clang_dir = glob.glob(os.path.join(CHROMIUM_ROOT_DIR, 'third_party', - 'llvm-build', 'Release+Asserts', 'lib', 'clang', '*', 'include'))[0] - - new_args += [ - '--extra-cflags=-fblocks', - '--extra-cflags=-nostdinc', - '--extra-cflags=-isystem%s/usr/include' % sdk_dir, - '--extra-cflags=-isystem' + clang_dir, - '--extra-ldflags=-syslibroot', '--extra-ldflags=' + sdk_dir, - '--extra-ldflags=' + '-L' + libs_dir, - '--extra-ldflags=-lSystem', - '--extra-ldflags=-macosx_version_min', '--extra-ldflags=' + mac_min_ver, - '--extra-ldflags=-sdk_version', '--extra-ldflags=' + mac_min_ver, - # ld64.lld requires -platform_version - # - '--extra-ldflags=-platform_version', '--extra-ldflags=macos', - '--extra-ldflags=' + mac_min_ver, '--extra-ldflags=' + mac_min_ver] - - return new_args - - -def BuildFFmpeg(target_os, target_arch, host_os, host_arch, parallel_jobs, - config_only, config, configure_flags, options): - config_dir = 'build.%s.%s/%s' % (target_arch, target_os, config) - - # See if the token file exists, and skip building if '--fast' is given. - token_file = os.path.join(config_dir, SUCCESS_TOKEN) - if os.path.exists(token_file) and options.fast: - print('Success token exists, skipping build of %s' % config_dir) - return - - shutil.rmtree(config_dir, ignore_errors=True) - os.makedirs(config_dir) - - PrintAndCheckCall( - [os.path.join(FFMPEG_DIR, 'configure')] + configure_flags, cwd=config_dir) - - # These rewrites force disable various features and should be applied before - # attempting the standalone ffmpeg build to make sure compilation succeeds. - pre_make_rewrites = [ - (r'(#define HAVE_VALGRIND_VALGRIND_H [01])', - r'#define HAVE_VALGRIND_VALGRIND_H 0 /* \1 -- forced to 0. See ' - r'https://crbug.com/590440 */') - ] - pre_make_asm_rewrites = [ - (r'(%define HAVE_VALGRIND_VALGRIND_H [01])', - r'%define HAVE_VALGRIND_VALGRIND_H 0 ; \1 -- forced to 0. See ' - r'https://crbug.com/590440') - ] - - if target_os == 'android': - pre_make_rewrites += [ - (r'(#define HAVE_POSIX_MEMALIGN [01])', - r'#define HAVE_POSIX_MEMALIGN 0 /* \1 -- forced to 0. See ' - r'https://crbug.com/604451 */') - ] - - # Linux configs is also used on Fuchsia. They are mostly compatible with - # Fuchsia except that Fuchsia doesn't support sysctl(). On Linux sysctl() - # isn't actually used, so it's safe to set HAVE_SYSCTL to 0. Linux is also - # removing soon, so this is needed to silence a deprecation - # #warning which will be converted to an error via -Werror. - # There is also no prctl.h - if target_os in ['linux', 'linux-noasm']: - pre_make_rewrites += [ - (r'(#define HAVE_SYSCTL [01])', - r'#define HAVE_SYSCTL 0 /* \1 -- forced to 0 for Fuchsia */'), - (r'(#define HAVE_PRCTL [01])', - r'#define HAVE_PRCTL 0 /* \1 -- forced to 0 for Fuchsia */') - ] - - # Turn off bcrypt, since we don't have it on Windows builders, but it does - # get detected when cross-compiling. - if target_os == 'win': - pre_make_rewrites += [ - (r'(#define HAVE_BCRYPT [01])', - r'#define HAVE_BCRYPT 0') - ] - - # Sanitizers can't compile the h264 code when EBP is used. - # Pre-make as ffmpeg fails to compile otherwise. - if target_arch == 'ia32': - pre_make_rewrites += [ - (r'(#define HAVE_EBP_AVAILABLE [01])', - r'/* \1 -- ebp selection is done by the chrome build */') - ] - - RewriteFile(os.path.join(config_dir, 'config.h'), pre_make_rewrites) - asm_path = os.path.join(config_dir, 'config.asm') - if os.path.exists(asm_path): - RewriteFile(asm_path, pre_make_asm_rewrites) - - # Windows linking resolves external symbols. Since generate_gn.py does not - # need a functioning set of libraries, ignore unresolved symbols here. - # This is especially useful here to avoid having to build a local libopus for - # windows. We munge the output of configure here to avoid this LDFLAGS setting - # triggering mis-detection during configure execution. - if target_os == 'win': - RewriteFile( - os.path.join(config_dir, 'ffbuild/config.mak'), [(r'(LDFLAGS=.*)', - r'\1 -FORCE:UNRESOLVED')]) - - # TODO(https://crbug.com/840976): Linking when targetting mac on linux is - # currently broken. - # Replace the linker step with something that just creates the target. - if target_os == 'mac' and host_os == 'linux': - RewriteFile( - os.path.join(config_dir, 'ffbuild/config.mak'), [(r'LD=ld64.lld', - r'LD=' + os.path.join(SCRIPTS_DIR, 'fake_linker.py'))]) - - # The FFMPEG roll build hits a bug in lld-link that does not impact the - # overall Chromium build. - # Replace the linker step with something that just creates the target. - if target_os == 'win' and target_arch == 'arm64' and host_os == 'linux': - RewriteFile( - os.path.join(config_dir, 'ffbuild/config.mak'), [(r'LD=lld-link', - r'LD=' + os.path.join(SCRIPTS_DIR, 'fake_linker.py'))]) - - if target_os in (host_os, host_os + '-noasm', 'android', - 'win', 'mac') and not config_only: - PrintAndCheckCall( - ['make', '-j%d' % parallel_jobs], cwd=config_dir) - elif config_only: - print('Skipping build step as requested.') - else: - print('Skipping compile as host configuration differs from target.\n' - 'Please compare the generated config.h with the previous version.\n' - 'You may also patch the script to properly cross-compile.\n' - 'Host OS : %s\n' - 'Target OS : %s\n' - 'Host arch : %s\n' - 'Target arch : %s\n' % (host_os, target_os, host_arch, target_arch)) - - # These rewrites are necessary to faciliate various Chrome build options. - post_make_rewrites = [ - (r'(#define FFMPEG_CONFIGURATION .*)', - r'/* \1 -- elide long configuration string from binary */') - ] - - if target_arch in ('arm', 'arm-neon', 'arm64'): - post_make_rewrites += [ - (r'(#define HAVE_VFP_ARGS [01])', - r'/* \1 -- softfp/hardfp selection is done by the chrome build */') - ] - - RewriteFile(os.path.join(config_dir, 'config.h'), post_make_rewrites) - - # Yay! create the token file so that we can skip this in the future. - with open(token_file, 'w'): - pass - - -def main(argv): - clean_arch_map = {k: '|'.join(v) for k, v in ARCH_MAP.items()} - formatted_usage_end = USAGE_END % clean_arch_map - parser = optparse.OptionParser(usage=USAGE_BEGIN + formatted_usage_end) - parser.add_option( - '--branding', - action='append', - dest='brandings', - choices=BRANDINGS, - help='Branding to build; determines e.g. supported codecs') - parser.add_option( - '--config-only', - action='store_true', - help='Skip the build step. Useful when a given platform ' - 'is not necessary for generate_gn.py') - parser.add_option( - '--fast', - action='store_true', - help='Skip building (successfully) if the success token file exists') - options, args = parser.parse_args(argv) - - if len(args) < 1: - parser.print_help() - return 1 - - target_os = args[0] - target_arch = '' - if len(args) >= 2: - target_arch = args[1] - configure_args = args[2:] - - - if target_os not in ('android', 'linux', 'linux-noasm', 'mac', 'win', 'all'): - parser.print_help() - return 1 - - host_tuple = DetermineHostOsAndArch() - if not host_tuple: - print('Unrecognized host OS and architecture.', file=sys.stderr) - return 1 - - host_os, host_arch = host_tuple - parallel_jobs = 8 - - if target_os.split('-', 1)[0] != host_os and (host_os != 'linux' or - host_arch != 'x64'): - print('Cross compilation can only be done from a linux x64 host.') - return 1 - - for os in ARCH_MAP.keys(): - if os != target_os and target_os != 'all': - continue - for arch in ARCH_MAP[os]: - if target_arch and arch != target_arch: - continue - - print('System information:\n' - 'Host OS : %s\n' - 'Target OS : %s\n' - 'Host arch : %s\n' - 'Target arch : %s\n' % (host_os, os, host_arch, arch)) - ConfigureAndBuild( - arch, - os, - host_os, - host_arch, - parallel_jobs, - configure_args, - options=options) - - -def ConfigureAndBuild(target_arch, target_os, host_os, host_arch, parallel_jobs, - configure_args, options): - if target_os == 'linux' and target_arch == 'noasm-x64': - target_os = 'linux-noasm' - target_arch = 'x64' - - configure_flags = collections.defaultdict(list) - - # Common configuration. Note: --disable-everything does not in fact disable - # everything, just non-library components such as decoders and demuxers. - configure_flags['Common'].extend([ - '--disable-everything', - '--disable-all', - '--disable-doc', - '--disable-htmlpages', - '--disable-manpages', - '--disable-podpages', - '--disable-txtpages', - '--disable-static', - '--enable-avcodec', - '--enable-avformat', - '--enable-avutil', - '--enable-fft', - '--enable-rdft', - '--enable-static', - '--enable-libopus', - - # Disable features. - '--disable-debug', - '--disable-bzlib', - '--disable-error-resilience', - '--disable-iconv', - '--disable-network', - '--disable-schannel', - '--disable-sdl2', - '--disable-symver', - '--disable-xlib', - '--disable-zlib', - '--disable-securetransport', - '--disable-faan', - '--disable-alsa', - - # Disable automatically detected external libraries. This prevents - # automatic inclusion of things like hardware decoders. Each roll should - # audit new [autodetect] configure options and add any desired options to - # this file. - '--disable-autodetect', - - # Common codecs. - '--enable-decoder=vorbis,libopus,flac', - '--enable-decoder=pcm_u8,pcm_s16le,pcm_s24le,pcm_s32le,pcm_f32le,mp3', - '--enable-decoder=pcm_s16be,pcm_s24be,pcm_mulaw,pcm_alaw', - '--enable-demuxer=ogg,matroska,wav,flac,mp3,mov', - '--enable-parser=opus,vorbis,flac,mpegaudio,vp9', - - # Setup include path so Chromium's libopus can be used. - '--extra-cflags=-I' + os.path.join(CHROMIUM_ROOT_DIR, - 'third_party/opus/src/include'), - - # Disable usage of Linux Performance API. Not used in production code, but - # missing system headers break some Android builds. - '--disable-linux-perf', - - # Force usage of nasm. - '--x86asmexe=nasm', - ]) - - if target_os == 'android': - configure_flags['Common'].extend([ - # This replaces --optflags="-Os" since it implies it and since if it is - # also specified, configure ends up dropping all optflags :/ - '--enable-small', - ]) - - configure_flags['Common'].extend(SetupAndroidToolchain(target_arch)) - else: - configure_flags['Common'].extend([ - # --optflags doesn't append multiple entries, so set all at once. - '--optflags="-O3"', - '--extra-cflags=-msse2', - '--extra-cflags=-O3', - '--enable-decoder=theora,vp8', - '--enable-parser=vp3,vp8', - ]) - - if target_os in ('linux', 'linux-noasm', 'android'): - if target_arch == 'x64': - if target_os == 'android': - configure_flags['Common'].extend([ - '--arch=x86_64', - ]) - else: - configure_flags['Common'].extend([ - '--enable-lto', - '--extra-cflags=-O3', - '--extra-cflags=-msse2', - '--arch=x86_64', - '--target-os=linux', - ]) - - if host_arch != 'x64': - configure_flags['Common'].extend([ - '--enable-cross-compile', - '--cross-prefix=/usr/bin/x86_64-linux-gnu-', - '--extra-cflags=--target=x86_64-linux-gnu', - '--extra-ldflags=--target=x86_64-linux-gnu', - ]) - elif target_arch == 'ia32': - configure_flags['Common'].extend([ - '--arch=i686', - '--extra-cflags="-m32"', - '--extra-ldflags="-m32"', - ]) - # Android ia32 can't handle textrels and ffmpeg can't compile without - # them. http://crbug.com/559379 - if target_os == 'android': - configure_flags['Common'].extend([ - '--disable-x86asm', - ]) - elif target_arch == 'arm' or target_arch == 'arm-neon': - # TODO(ihf): ARM compile flags are tricky. The final options - # overriding everything live in chroot /build/*/etc/make.conf - # (some of them coming from src/overlays/overlay-/make.conf). - # We try to follow these here closely. In particular we need to - # set ffmpeg internal #defines to conform to make.conf. - # TODO(ihf): For now it is not clear if thumb or arm settings would be - # faster. I ran experiments in other contexts and performance seemed - # to be close and compiler version dependent. In practice thumb builds are - # much smaller than optimized arm builds, hence we go with the global - # CrOS settings. - configure_flags['Common'].extend([ - '--arch=arm', - '--enable-armv6', - '--enable-armv6t2', - '--enable-vfp', - '--enable-thumb', - '--extra-cflags=-march=armv7-a', - ]) - - if target_os == 'android': - configure_flags['Common'].extend([ - # Runtime neon detection requires /proc/cpuinfo access, so ensure - # av_get_cpu_flags() is run outside of the sandbox when enabled. - '--enable-neon', - '--extra-cflags=-mtune=generic-armv7-a', - # Enabling softfp lets us choose either softfp or hardfp when doing - # the chrome build. - '--extra-cflags=-mfloat-abi=softfp', - ]) - if target_arch == 'arm': - print('arm-neon is the only supported arm arch for Android.\n') - return 1 - - if target_arch == 'arm-neon': - configure_flags['Common'].extend([ - '--extra-cflags=-mfpu=neon', - ]) - else: - configure_flags['Common'].extend([ - '--extra-cflags=-mfpu=vfpv3-d16', - ]) - else: - if host_arch != 'arm': - configure_flags['Common'].extend([ - '--enable-cross-compile', - '--target-os=linux', - '--extra-cflags=--target=arm-linux-gnueabihf', - '--extra-ldflags=--target=arm-linux-gnueabihf', - '--sysroot=' + os.path.join(CHROMIUM_ROOT_DIR, - 'build/linux/debian_bullseye_armhf-sysroot'), - '--extra-cflags=-mtune=cortex-a8', - # NOTE: we don't need softfp for this hardware. - '--extra-cflags=-mfloat-abi=hard', - # For some reason configure drops this... - '--extra-cflags=-O3', - ]) - - if target_arch == 'arm-neon': - configure_flags['Common'].extend([ - '--enable-neon', - '--extra-cflags=-mfpu=neon', - ]) - else: - configure_flags['Common'].extend([ - '--disable-neon', - '--extra-cflags=-mfpu=vfpv3-d16', - ]) - elif target_arch == 'arm64': - if target_os != 'android': - if host_arch != 'arm64': - configure_flags['Common'].extend([ - '--enable-cross-compile', - '--cross-prefix=/usr/bin/aarch64-linux-gnu-', - '--extra-cflags=--target=aarch64-linux-gnu', - '--extra-ldflags=--target=aarch64-linux-gnu', - ]) - - configure_flags['Common'].extend([ - '--target-os=linux', - '--sysroot=' + os.path.join(CHROMIUM_ROOT_DIR, - 'build/linux/debian_bullseye_arm64-sysroot'), - ]) - configure_flags['Common'].extend([ - '--arch=aarch64', - '--enable-armv8', - '--extra-cflags=-march=armv8-a', - ]) - elif target_arch == 'mipsel': - # These flags taken from android chrome build with target_cpu='mipsel' - configure_flags['Common'].extend([ - '--arch=mipsel', - '--disable-mips32r6', - '--disable-mips32r5', - '--disable-mips32r2', - '--disable-mipsdsp', - '--disable-mipsdspr2', - '--disable-msa', - '--enable-mipsfpu', - '--extra-cflags=-march=mipsel', - '--extra-cflags=-mcpu=mips32', - # Required to avoid errors about dynamic relocation w/o -fPIC. - '--extra-ldflags=-z notext', - ]) - if target_os == 'linux': - configure_flags['Common'].extend([ - '--enable-cross-compile', - '--target-os=linux', - '--sysroot=' + os.path.join(CHROMIUM_ROOT_DIR, - 'build/linux/debian_bullseye_mips-sysroot'), - '--extra-cflags=--target=mipsel-linux-gnu', - '--extra-ldflags=--target=mipsel-linux-gnu', - ]) - elif target_arch == 'mips64el': - # These flags taken from android chrome build with target_cpu='mips64el' - configure_flags['Common'].extend([ - '--arch=mips64el', - '--enable-mipsfpu', - '--disable-mipsdsp', - '--disable-mipsdspr2', - '--extra-cflags=-march=mips64el', - # Required to avoid errors about dynamic relocation w/o -fPIC. - '--extra-ldflags=-z notext', - ]) - if target_os == 'android': - configure_flags['Common'].extend([ - '--enable-mips64r6', - '--extra-cflags=-mcpu=mips64r6', - '--disable-mips64r2', - '--enable-msa', - ]) - if target_os == 'linux': - configure_flags['Common'].extend([ - '--enable-cross-compile', - '--target-os=linux', - '--sysroot=' + os.path.join( - CHROMIUM_ROOT_DIR, 'build/linux/debian_bullseye_mips64el-sysroot'), - '--enable-mips64r2', - '--disable-mips64r6', - '--disable-msa', - '--extra-cflags=-mcpu=mips64r2', - '--extra-cflags=--target=mips64el-linux-gnuabi64', - '--extra-ldflags=--target=mips64el-linux-gnuabi64', - ]) - else: - print( - 'Error: Unknown target arch %r for target OS %r!' % (target_arch, - target_os), - file=sys.stderr) - return 1 - - if target_os == 'linux-noasm': - configure_flags['Common'].extend([ - '--disable-asm', - '--disable-inline-asm', - ]) - - if 'win' not in target_os and 'android' not in target_os: - configure_flags['Common'].extend([ - '--enable-pic', - '--cc=clang', - '--cxx=clang++', - '--ld=clang', - ]) - - # Clang Linux will use the first 'ld' it finds on the path, which will - # typically be the system one, so explicitly configure use of Clang's - # ld.lld, to ensure that things like cross-compilation and LTO work. - # This does not work for ia32 and is always used on mac. - if target_arch != 'ia32' and target_os != 'mac': - configure_flags['Common'].append('--extra-ldflags=-fuse-ld=lld') - - # Should be run on Mac, unless we're cross-compiling on Linux. - if target_os == 'mac': - if host_os != 'mac' and host_os != 'linux': - print( - 'Script should be run on a Mac or Linux host.\n', - file=sys.stderr) - return 1 - - if host_os != 'mac': - configure_flags['Common'].extend( - SetupMacCrossCompileToolchain(target_arch)) - else: - # ffmpeg links against Chromium's libopus, which isn't built when this - # script runs. Suppress all undefined symbols (which matches the default - # on Linux), to get things to build. This also requires opting in to - # flat namespaces. - configure_flags['Common'].extend([ - '--extra-ldflags=-Wl,-flat_namespace -Wl,-undefined,warning', - ]) - - if target_arch == 'x64': - configure_flags['Common'].extend([ - '--arch=x86_64', - '--extra-cflags=-m64', - '--extra-ldflags=-arch x86_64', - ]) - elif target_arch == 'arm64': - configure_flags['Common'].extend([ - '--arch=arm64', - '--extra-cflags=-arch arm64', - '--extra-ldflags=-arch arm64', - ]) - else: - print( - 'Error: Unknown target arch %r for target OS %r!' % (target_arch, - target_os), - file=sys.stderr) - - # Should be run on Windows. - if target_os == 'win': - configure_flags['Common'].extend([ - '--toolchain=msvc', - '--extra-cflags=-I' + os.path.join(FFMPEG_DIR, 'chromium/include/win'), - ]) - - if target_arch == 'x64': - configure_flags['Common'].extend(['--target-os=win64']) - elif target_arch == 'x86': - configure_flags['Common'].extend(['--target-os=win32']) - - if host_os != 'win': - configure_flags['Common'].extend( - SetupWindowsCrossCompileToolchain(target_arch)) - - if 'CYGWIN_NT' in platform.system(): - configure_flags['Common'].extend([ - '--cc=cygwin-wrapper cl', - '--ld=cygwin-wrapper link', - '--nm=cygwin-wrapper dumpbin -symbols', - '--ar=cygwin-wrapper lib', - ]) - - # Google Chrome & ChromeOS specific configuration. - configure_flags['Chrome'].extend([ - '--enable-decoder=aac,h264,mp3,eac3,ac3,hevc,mpeg4,mpegvideo,mp2,mp1,flac', - '--enable-demuxer=aac,mp3,mov,dtshd,dts,avi,mpegvideo,m4v,h264,vc1,flac', - '--enable-parser=aac,h264,hevc,mpegaudio,mpeg4video,mpegvideo,ac3,h261,vc1,h263,flac', - ]) - - # Google ChromeOS specific configuration. - # We want to make sure to play everything Android generates and plays. - # http://developer.android.com/guide/appendix/media-formats.html - configure_flags['ChromeOS'].extend([ - # Enable playing avi files. - '--enable-decoder=mpeg4', - '--enable-parser=h263,mpeg4video', - '--enable-demuxer=avi', - # Enable playing Android 3gp files. - '--enable-demuxer=amr', - '--enable-decoder=amrnb,amrwb', - # Wav files for playing phone messages. - '--enable-decoder=gsm_ms', - '--enable-parser=gsm', - ]) - - configure_flags['ChromeAndroid'].extend([ - '--enable-demuxer=aac', - '--enable-parser=aac', - '--enable-decoder=aac', - - # TODO(dalecurtis, watk): Figure out if we need h264 parser for now? - ]) - - def do_build_ffmpeg(branding, configure_flags): - if options.brandings and branding not in options.brandings: - print('%s skipped' % branding) - return - - print('%s configure/build:' % branding) - BuildFFmpeg(target_os, target_arch, host_os, host_arch, parallel_jobs, - options.config_only, branding, configure_flags, options) - - # Only build Chromium, Chrome for ia32, x86 non-android platforms. - if target_os != 'android': - do_build_ffmpeg( - 'Chromium', configure_flags['Common'] + configure_flags['Chromium'] + - configure_args) - do_build_ffmpeg( - 'Chrome', - configure_flags['Common'] + configure_flags['Chrome'] + configure_args) - else: - do_build_ffmpeg('Chromium', configure_flags['Common'] + configure_args) - do_build_ffmpeg( - 'Chrome', configure_flags['Common'] + configure_flags['ChromeAndroid'] + - configure_args) - - if target_os in ['linux', 'linux-noasm']: - # ChromeOS enables MPEG4 which requires error resilience :( - chrome_os_flags = ( - configure_flags['Common'] + configure_flags['Chrome'] + - configure_flags['ChromeOS'] + configure_args) - chrome_os_flags.remove('--disable-error-resilience') - do_build_ffmpeg('ChromeOS', chrome_os_flags) - - print('Done. If desired you may copy config.h/config.asm into the ' - 'source/config tree using copy_config.sh.') - return 0 - - -if __name__ == '__main__': - sys.exit(main(sys.argv[1:])) diff --git a/other/SSE3/third_party/ffmpeg/chromium/scripts/build_ffmpeg.py b/other/SSE3/third_party/ffmpeg/chromium/scripts/build_ffmpeg.py deleted file mode 100755 index 20811335..00000000 --- a/other/SSE3/third_party/ffmpeg/chromium/scripts/build_ffmpeg.py +++ /dev/null @@ -1,1076 +0,0 @@ -#!/usr/bin/env python3 -# -# Copyright 2023 The Chromium Authors, Alex313031, and Midzer. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -from __future__ import print_function - -import atexit -import collections -import functools -import glob -import optparse -import os -import platform -import re -import shlex -import shutil -import signal -import subprocess -import sys -import tempfile - -SCRIPTS_DIR = os.path.abspath(os.path.dirname(__file__)) -FFMPEG_DIR = os.path.abspath(os.path.join(SCRIPTS_DIR, '..', '..')) -CHROMIUM_ROOT_DIR = os.path.abspath(os.path.join(FFMPEG_DIR, '..', '..')) -NDK_ROOT_DIR = os.path.abspath( - os.path.join(CHROMIUM_ROOT_DIR, 'third_party', 'android_ndk')) -SUCCESS_TOKEN = 'THIS_BUILD_WORKED' - -sys.path.append(os.path.join(CHROMIUM_ROOT_DIR, 'build')) -import gn_helpers - -BRANDINGS = [ - 'Chrome', - 'ChromeOS', - 'Chromium', -] - -ARCH_MAP = { - 'android': ['ia32', 'x64', 'arm-neon', 'arm64'], - 'linux': [ - 'ia32', 'x64', 'noasm-x64', 'arm', 'arm-neon', 'arm64' - ], - 'mac': ['x64', 'arm64'], - 'win': ['ia32', 'x64', 'arm64'], -} - -USAGE_BEGIN = """Usage: %prog TARGET_OS TARGET_ARCH [options] -- [configure_args]""" -USAGE_END = """ -Valid combinations are android [%(android)s] - linux [%(linux)s] - mac [%(mac)s] - win [%(win)s] - -If no target architecture is specified all will be built. - -Platform specific build notes: - android: - Script can be run on a normal x64 Ubuntu box with an Android-ready Chromium - checkout: https://chromium.googlesource.com/chromium/src/+/master/docs/android_build_instructions.md - - linux ia32/x64: - Script can run on a normal Ubuntu box. - - linux arm/arm-neon/arm64/mipsel/mips64el: - Script can run on a normal Ubuntu with ARM/ARM64 or MIPS32/MIPS64 ready Chromium checkout: - build/linux/sysroot_scripts/install-sysroot.py --arch=arm - build/linux/sysroot_scripts/install-sysroot.py --arch=arm64 - build/linux/sysroot_scripts/install-sysroot.py --arch=mips - build/linux/sysroot_scripts/install-sysroot.py --arch=mips64el - - mac: - Script must be run on Linux or macOS. Additionally, ensure the Chromium - (not Apple) version of clang is in the path; usually found under - src/third_party/llvm-build/Release+Asserts/bin - - The arm64 version has to be built with an SDK that can build mac/arm64 - binaries -- currently Xcode 12 beta and its included 11.0 SDK. You must - pass --enable-cross-compile to be able to build ffmpeg for mac/arm64 on an - Intel Mac. On a Mac, run like so: - PATH=$PWD/../../third_party/llvm-build/Release+Asserts/bin:$PATH \ - SDKROOT=/Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.0.sdk \ - chromium/scripts/build_ffmpeg.py mac arm64 -- --enable-cross-compile - - On Linux, the normal robosushi flow will work for arm64. - - win: - Script may be run unders Linux or Windows; if cross-compiling you will need - to follow the Chromium instruction for Cross-compiling Chrome/win: - https://chromium.googlesource.com/chromium/src/+/master/docs/win_cross.md - - Once you have a working Chromium build that can cross-compile, you'll also - need to run $chrome_dir/tools/clang/scripts/update.py --package=objdump to - pick up the llvm-ar and llvm-nm tools. You can then build as normal. - - If not cross-compiling, script must be run on Windows with VS2015 or higher - under Cygwin (or MinGW, but as of 1.0.11, it has serious performance issues - with make which makes building take hours). - - Additionally, ensure you have the correct toolchain environment for building. - The x86 toolchain environment is required for ia32 builds and the x64 one - for x64 builds. This can be verified by running "cl.exe" and checking if - the version string ends with "for x64" or "for x86." - - Building on Windows also requires some additional Cygwin packages plus a - wrapper script for converting Cygwin paths to DOS paths. - - Add these packages at install time: diffutils, nasm, make, python. - - Copy chromium/scripts/cygwin-wrapper to /usr/local/bin - -Resulting binaries will be placed in: - build.TARGET_ARCH.TARGET_OS/Chrome/ - build.TARGET_ARCH.TARGET_OS/ChromeOS/ - build.TARGET_ARCH.TARGET_OS/Chromium/ - """ - - -def PrintAndCheckCall(argv, *args, **kwargs): - print('Running %s' % '\n '.join(argv)) - subprocess.check_call(argv, *args, **kwargs) - - -def DetermineHostOsAndArch(): - if platform.system() == 'Linux': - host_os = 'linux' - elif platform.system() == 'Darwin': - host_os = 'mac' - elif platform.system() == 'Windows' or 'CYGWIN_NT' in platform.system(): - host_os = 'win' - else: - return None - - if re.match(r'i.86', platform.machine()): - host_arch = 'ia32' - elif platform.machine() == 'x86_64' or platform.machine() == 'AMD64': - host_arch = 'x64' - elif platform.machine() == 'aarch64': - host_arch = 'arm64' - elif platform.machine() == 'mips32': - host_arch = 'mipsel' - elif platform.machine() == 'mips64': - host_arch = 'mips64el' - elif platform.machine().startswith('arm'): - host_arch = 'arm' - else: - return None - - return (host_os, host_arch) - - -def GetDsoName(target_os, dso_name, dso_version): - if target_os in ('linux', 'linux-noasm', 'android'): - return 'lib%s.so.%s' % (dso_name, dso_version) - elif target_os == 'mac': - return 'lib%s.%s.dylib' % (dso_name, dso_version) - elif target_os == 'win': - return '%s-%s.dll' % (dso_name, dso_version) - else: - raise ValueError('Unexpected target_os %s' % target_os) - - -def RewriteFile(path, search_replace): - with open(path) as f: - contents = f.read() - with open(path, 'w') as f: - for search, replace in search_replace: - contents = re.sub(search, replace, contents) - f.write(contents) - - -# Class for determining the 32-bit and 64-bit Android API levels that Chromium -# uses. Since @functools.cache is not available for easy memoization of the -# determination result, we use a lazy singleton instance constructed by calling -# Get(). -class AndroidApiLevels: - __instance = None - - # Extracts the Android API levels from the Chromium Android GN config. - # Before Q1 2021, these were grep'able from build/config/android/config.gni. - # With conditional logic introduced in that gni file, we seek to avoid fragility - # going forwards, at the cost of creating a full temporary GN Chromium Android - # build configuration just to extract the API levels here. Caches the results - # in api32 and api64 instance variables. - def Setup(self): - print('Creating a temporary GN config to retrieve Android API levels:') - - # Make a temporary GN build output folder - # No tempfile.TemporaryDirectory until python 3.2, so instead: - tmp_dir = tempfile.mkdtemp(prefix = 'android_build_ffmpeg_for_api_level_config') - print('Created temporary directory ' + tmp_dir) - - # Populate that GN build output folder with generated config for Android as - # target OS. - with open(os.path.join(tmp_dir, 'args.gn'), 'w') as args_gn_file: - args_gn_file.write('target_os = "android"\n') - print('Created ' + os.path.realpath(args_gn_file.name)) - - # Ask GN to generate build files. - PrintAndCheckCall(['gn', 'gen', tmp_dir], cwd=CHROMIUM_ROOT_DIR) - - # Query the API levels in the generated build config. - print('Retrieving config vars') - config_output = subprocess.check_output( - ['gn', 'args', tmp_dir, '--short', '--list'], - cwd=CHROMIUM_ROOT_DIR).decode('utf-8') - - # Remove the temporary GN build output folder - print('removing temp dir ' + tmp_dir) - shutil.rmtree(tmp_dir, ignore_errors=False) - - api64_match = re.search(r'android64_ndk_api_level\s*=\s*(\d{2})', - config_output) - api32_match = re.search(r'android32_ndk_api_level\s*=\s*(\d{2})', - config_output) - if not api32_match or not api64_match: - raise Exception('Failed to find the android api levels') - - self.api32 = api32_match.group(1) - self.api64 = api64_match.group(1) - - def ApiLevels(self): - return (self.api32, self.api64) - - @classmethod - def Get(cls): - if cls.__instance is None: - cls.__instance = AndroidApiLevels() - cls.__instance.Setup() - return cls.__instance.ApiLevels() - - -# Sets up cross-compilation (specific to host being linux-x64_64) for compiling -# Android. -# Returns the necessary configure flags as a list. -# See also https://developer.android.com/ndk/guides/other_build_systems -# As of M90, //third_party/android_ndk no longer includes mipsel or mips64el -# toolchains; they were not previously supported by default by this script, and -# currently are unsupported due to lack of toolchain in checkout. -def SetupAndroidToolchain(target_arch): - api_level, api64_level = AndroidApiLevels.Get() - print('Determined Android API levels: 32bit=' + api_level + - ', 64bit=' + api64_level) - - # Toolchain prefix misery, for when just one pattern is not enough :/ - toolchain_level = api_level - toolchain_bin_prefix = target_arch - - if target_arch == 'arm-neon' or target_arch == 'arm': - toolchain_bin_prefix = 'arm-linux-androideabi' - elif target_arch == 'arm64': - toolchain_level = api64_level - toolchain_bin_prefix = 'aarch64-linux-android' - elif target_arch == 'ia32': - toolchain_bin_prefix = 'i686-linux-android' - elif target_arch == 'x64': - toolchain_level = api64_level - toolchain_bin_prefix = 'x86_64-linux-android' - elif target_arch == 'mipsel': # Unsupported beginning in M90 - toolchain_bin_prefix = 'mipsel-linux-android' - elif target_arch == 'mips64el': # Unsupported beginning in M90 - toolchain_level = api64_level - toolchain_bin_prefix = 'mips64el-linux-android' - - clang_toolchain_dir = NDK_ROOT_DIR + '/toolchains/llvm/prebuilt/linux-x86_64/' - - # Big old nasty hack here, beware! The new android ndk has some foolery with - # libgcc.a -- clang still uses gcc for its linker when cross compiling. - # It can't just be that simple though - the |libgcc.a| file is actually a - # super secret linkerscript which links libgcc_real.a, because apparently - # someone decided that more flags are needed, including -lunwind; thats where - # our story begins. ffmpeg doesn't use linunwind, and we dont really have a - # good way to get a cross-compiled version anyway, but this silly linker - # script insists that we must link with it, or face all sorts of horrible - # consequences -- namely configure failures. Anyway, there is a way around it: - # the "big old nasty hack" mentioned what feels like forever ago now. It's - # simple, we uhh, kill tha batman. Actually we just make a fake libunwind.a - # linker script and drop it someplace nobody will ever find, like I dunno, say - # /tmp/fakelinkerscripts or something. Then we add that path to the ldflags - # flags and everything works again. - fakedir = '/tmp/fakelinkerscripts' - os.system('mkdir -p {fakedir} && touch {fakedir}/libunwind.a'.format( - fakedir=fakedir)) - - return [ - '--enable-pic', - '--cc=' + clang_toolchain_dir + 'bin/clang', - '--cxx=' + clang_toolchain_dir + 'bin/clang++', - '--ld=' + clang_toolchain_dir + 'bin/clang', - '--enable-cross-compile', - '--sysroot=' + clang_toolchain_dir + 'sysroot', - '--extra-cflags=-I' + clang_toolchain_dir + 'sysroot/usr/include', - '--extra-cflags=-I' + clang_toolchain_dir + 'sysroot/usr/include/' + - toolchain_bin_prefix, - '--extra-cflags=--target=' + toolchain_bin_prefix + toolchain_level, - '--extra-ldflags=--target=' + toolchain_bin_prefix + toolchain_level, - '--extra-ldflags=-L{}'.format(fakedir), - '--extra-ldflags=-L' + clang_toolchain_dir + toolchain_bin_prefix, - '--extra-ldflags=--gcc-toolchain=' + clang_toolchain_dir, - '--target-os=android', - ] - - -def SetupWindowsCrossCompileToolchain(target_arch): - # First retrieve various MSVC and Windows SDK paths. - output = subprocess.check_output([ - os.path.join(CHROMIUM_ROOT_DIR, 'build', 'vs_toolchain.py'), - 'get_toolchain_dir' - ]).decode('utf-8') - - new_args = [ - '--enable-cross-compile', - '--cc=clang-cl', - '--ld=lld-link', - '--nm=llvm-nm', - '--ar=llvm-ar', - - # Separate from optflags because configure strips it from msvc builds... - '--extra-cflags=-O3', - ] - - if target_arch == 'ia32': - new_args += ['--extra-cflags=-m32'] - if target_arch == 'ia32': - target_arch = 'x86' - if target_arch == 'arm64': - new_args += [ - # With ASM enabled, an ARCH must be specified. - '--arch=aarch64', - # When cross-compiling (from Linux), armasm64.exe is not available. - '--as=clang-cl', - # FFMPEG is not yet enlightened for ARM64 Windows. - # Imitate Android workaround. - '--extra-cflags=--target=arm64-windows' - ] - - # Turn this into a dictionary. - win_dirs = gn_helpers.FromGNArgs(output) - - # Use those paths with a second script which will tell us the proper lib paths - # to specify for ldflags. - output = subprocess.check_output([ - 'python3', - os.path.join(CHROMIUM_ROOT_DIR, 'build', 'toolchain', 'win', - 'setup_toolchain.py'), win_dirs['vs_path'], - win_dirs['sdk_path'], win_dirs['runtime_dirs'], 'win', target_arch, 'none' - ]).decode('utf-8') - - flags = gn_helpers.FromGNArgs(output) - - # Q1 2021 update to LLVM now lets us use a sysroot for cross-compilation - # targeting Windows, instead of specificying a variety of individual include - # folders which now include whitespace within paths within the SDK. Either - # injection of such paths into environment variable or using the new sysroot - # option is required, since using a /tmp symlink solution to avoid the spaces - # broke cross-compilation for win-arm64. For at least now, we'll use the - # sysroot approach, until and unless the environment variable injection - # approach is determined to be better or more consistent. - new_args += [ - '--extra-cflags=/winsysroot' + win_dirs['vs_path'], - '--extra-ldflags=/winsysroot:' + win_dirs['vs_path'], - ] - - # FFmpeg configure doesn't like arguments with spaces in them even if quoted - # or double-quoted or escape-quoted (whole argument and/or the internal - # spaces). To automate this for now, every path that has a space in it is - # replaced with a symbolic link created in the OS' temp folder to the real - # path. - def do_remove_temp_link(temp_name): - assert os.path.exists(temp_name) - assert os.path.islink(temp_name) - print('Removing temporary link ' + temp_name) - os.remove(temp_name) - - def do_make_temp_link(real_target): - temp_file = tempfile.NamedTemporaryFile(prefix='windows_build_ffmpeg') - temp_name = temp_file.name - # Destroy |temp_file|, but reuse its name for the symbolic link which - # survives this helper method. - temp_file.close() - os.symlink(real_target, temp_name) - assert os.path.exists(temp_name) - assert os.path.islink(temp_name) - atexit.register(do_remove_temp_link, temp_name) - return temp_name - - return new_args - - -def SetupMacCrossCompileToolchain(target_arch): - # First compute the various SDK paths. - mac_min_ver = '10.10' - developer_dir = os.path.join(CHROMIUM_ROOT_DIR, 'build', 'mac_files', - 'xcode_binaries', 'Contents', 'Developer') - sdk_dir = os.path.join(developer_dir, 'Platforms', 'MacOSX.platform', - 'Developer', 'SDKs', 'MacOSX.sdk') - - if target_arch == 'x64': - target_triple = 'x86_64-apple-macosx' - elif target_arch == 'arm64': - target_triple = 'arm64-apple-macosx' - else: - raise Exception("unknown arch " + target_arch) - - # We're guessing about the right sdk path, so warn if we don't find it. - if not os.path.exists(sdk_dir): - print (sdk_dir) - raise Exception("Can't find the mac sdk. Please see crbug.com/841826") - - frameworks_dir = os.path.join(sdk_dir, "System", "Library", "Frameworks") - libs_dir = os.path.join(sdk_dir, "usr", "lib") - - new_args = [ - '--enable-cross-compile', - '--cc=clang', - # This is replaced with fake_linker.py further down. We need a real linker - # at configure time for a few configure checks. These checks only link - # very basic programs, so it's ok to use ld64.lld, even though it's not - # generally production quality. - '--ld=ld64.lld', - '--nm=llvm-nm', - '--ar=llvm-ar', - '--target-os=darwin', - - '--extra-cflags=--target=' + target_triple, - '--extra-cflags=-F' + frameworks_dir, - '--extra-cflags=-mmacosx-version-min=' + mac_min_ver - ] - - # We need to pass -nostdinc so that clang does not pick up linux headers, - # but then it also can't find its own headers like stddef.h. So tell it - # where to look for those headers. - clang_dir = glob.glob(os.path.join(CHROMIUM_ROOT_DIR, 'third_party', - 'llvm-build', 'Release+Asserts', 'lib', 'clang', '*', 'include'))[0] - - new_args += [ - '--extra-cflags=-fblocks', - '--extra-cflags=-nostdinc', - '--extra-cflags=-isystem%s/usr/include' % sdk_dir, - '--extra-cflags=-isystem' + clang_dir, - '--extra-ldflags=-syslibroot', '--extra-ldflags=' + sdk_dir, - '--extra-ldflags=' + '-L' + libs_dir, - '--extra-ldflags=-lSystem', - '--extra-ldflags=-macosx_version_min', '--extra-ldflags=' + mac_min_ver, - '--extra-ldflags=-sdk_version', '--extra-ldflags=' + mac_min_ver, - # ld64.lld requires -platform_version - # - '--extra-ldflags=-platform_version', '--extra-ldflags=macos', - '--extra-ldflags=' + mac_min_ver, '--extra-ldflags=' + mac_min_ver] - - return new_args - - -def BuildFFmpeg(target_os, target_arch, host_os, host_arch, parallel_jobs, - config_only, config, configure_flags, options): - config_dir = 'build.%s.%s/%s' % (target_arch, target_os, config) - - # See if the token file exists, and skip building if '--fast' is given. - token_file = os.path.join(config_dir, SUCCESS_TOKEN) - if os.path.exists(token_file) and options.fast: - print('Success token exists, skipping build of %s' % config_dir) - return - - shutil.rmtree(config_dir, ignore_errors=True) - os.makedirs(config_dir) - - PrintAndCheckCall( - [os.path.join(FFMPEG_DIR, 'configure')] + configure_flags, cwd=config_dir) - - # These rewrites force disable various features and should be applied before - # attempting the standalone ffmpeg build to make sure compilation succeeds. - pre_make_rewrites = [ - (r'(#define HAVE_VALGRIND_VALGRIND_H [01])', - r'#define HAVE_VALGRIND_VALGRIND_H 0 /* \1 -- forced to 0. See ' - r'https://crbug.com/590440 */') - ] - pre_make_asm_rewrites = [ - (r'(%define HAVE_VALGRIND_VALGRIND_H [01])', - r'%define HAVE_VALGRIND_VALGRIND_H 0 ; \1 -- forced to 0. See ' - r'https://crbug.com/590440') - ] - - if target_os == 'android': - pre_make_rewrites += [ - (r'(#define HAVE_POSIX_MEMALIGN [01])', - r'#define HAVE_POSIX_MEMALIGN 0 /* \1 -- forced to 0. See ' - r'https://crbug.com/604451 */') - ] - - # Linux configs is also used on Fuchsia. They are mostly compatible with - # Fuchsia except that Fuchsia doesn't support sysctl(). On Linux sysctl() - # isn't actually used, so it's safe to set HAVE_SYSCTL to 0. Linux is also - # removing soon, so this is needed to silence a deprecation - # #warning which will be converted to an error via -Werror. - # There is also no prctl.h - if target_os in ['linux', 'linux-noasm']: - pre_make_rewrites += [ - (r'(#define HAVE_SYSCTL [01])', - r'#define HAVE_SYSCTL 0 /* \1 -- forced to 0 for Fuchsia */'), - (r'(#define HAVE_PRCTL [01])', - r'#define HAVE_PRCTL 0 /* \1 -- forced to 0 for Fuchsia */') - ] - - # Turn off bcrypt, since we don't have it on Windows builders, but it does - # get detected when cross-compiling. - if target_os == 'win': - pre_make_rewrites += [ - (r'(#define HAVE_BCRYPT [01])', - r'#define HAVE_BCRYPT 0') - ] - - # Sanitizers can't compile the h264 code when EBP is used. - # Pre-make as ffmpeg fails to compile otherwise. - if target_arch == 'ia32': - pre_make_rewrites += [ - (r'(#define HAVE_EBP_AVAILABLE [01])', - r'/* \1 -- ebp selection is done by the chrome build */') - ] - - RewriteFile(os.path.join(config_dir, 'config.h'), pre_make_rewrites) - asm_path = os.path.join(config_dir, 'config.asm') - if os.path.exists(asm_path): - RewriteFile(asm_path, pre_make_asm_rewrites) - - # Windows linking resolves external symbols. Since generate_gn.py does not - # need a functioning set of libraries, ignore unresolved symbols here. - # This is especially useful here to avoid having to build a local libopus for - # windows. We munge the output of configure here to avoid this LDFLAGS setting - # triggering mis-detection during configure execution. - if target_os == 'win': - RewriteFile( - os.path.join(config_dir, 'ffbuild/config.mak'), [(r'(LDFLAGS=.*)', - r'\1 -FORCE:UNRESOLVED')]) - - # TODO(https://crbug.com/840976): Linking when targetting mac on linux is - # currently broken. - # Replace the linker step with something that just creates the target. - if target_os == 'mac' and host_os == 'linux': - RewriteFile( - os.path.join(config_dir, 'ffbuild/config.mak'), [(r'LD=ld64.lld', - r'LD=' + os.path.join(SCRIPTS_DIR, 'fake_linker.py'))]) - - # The FFMPEG roll build hits a bug in lld-link that does not impact the - # overall Chromium build. - # Replace the linker step with something that just creates the target. - if target_os == 'win' and target_arch == 'arm64' and host_os == 'linux': - RewriteFile( - os.path.join(config_dir, 'ffbuild/config.mak'), [(r'LD=lld-link', - r'LD=' + os.path.join(SCRIPTS_DIR, 'fake_linker.py'))]) - - if target_os in (host_os, host_os + '-noasm', 'android', - 'win', 'mac') and not config_only: - PrintAndCheckCall( - ['make', '-j%d' % parallel_jobs], cwd=config_dir) - elif config_only: - print('Skipping build step as requested.') - else: - print('Skipping compile as host configuration differs from target.\n' - 'Please compare the generated config.h with the previous version.\n' - 'You may also patch the script to properly cross-compile.\n' - 'Host OS : %s\n' - 'Target OS : %s\n' - 'Host arch : %s\n' - 'Target arch : %s\n' % (host_os, target_os, host_arch, target_arch)) - - # These rewrites are necessary to faciliate various Chrome build options. - post_make_rewrites = [ - (r'(#define FFMPEG_CONFIGURATION .*)', - r'/* \1 -- elide long configuration string from binary */') - ] - - if target_arch in ('arm', 'arm-neon', 'arm64'): - post_make_rewrites += [ - (r'(#define HAVE_VFP_ARGS [01])', - r'/* \1 -- softfp/hardfp selection is done by the chrome build */') - ] - - RewriteFile(os.path.join(config_dir, 'config.h'), post_make_rewrites) - - # Yay! create the token file so that we can skip this in the future. - with open(token_file, 'w'): - pass - - -def main(argv): - clean_arch_map = {k: '|'.join(v) for k, v in ARCH_MAP.items()} - formatted_usage_end = USAGE_END % clean_arch_map - parser = optparse.OptionParser(usage=USAGE_BEGIN + formatted_usage_end) - parser.add_option( - '--branding', - action='append', - dest='brandings', - choices=BRANDINGS, - help='Branding to build; determines e.g. supported codecs') - parser.add_option( - '--config-only', - action='store_true', - help='Skip the build step. Useful when a given platform ' - 'is not necessary for generate_gn.py') - parser.add_option( - '--fast', - action='store_true', - help='Skip building (successfully) if the success token file exists') - options, args = parser.parse_args(argv) - - if len(args) < 1: - parser.print_help() - return 1 - - target_os = args[0] - target_arch = '' - if len(args) >= 2: - target_arch = args[1] - configure_args = args[2:] - - - if target_os not in ('android', 'linux', 'linux-noasm', 'mac', 'win', 'all'): - parser.print_help() - return 1 - - host_tuple = DetermineHostOsAndArch() - if not host_tuple: - print('Unrecognized host OS and architecture.', file=sys.stderr) - return 1 - - host_os, host_arch = host_tuple - parallel_jobs = 8 - - if target_os.split('-', 1)[0] != host_os and (host_os != 'linux' or - host_arch != 'x64'): - print('Cross compilation can only be done from a linux x64 host.') - return 1 - - for os in ARCH_MAP.keys(): - if os != target_os and target_os != 'all': - continue - for arch in ARCH_MAP[os]: - if target_arch and arch != target_arch: - continue - - print('System information:\n' - 'Host OS : %s\n' - 'Target OS : %s\n' - 'Host arch : %s\n' - 'Target arch : %s\n' % (host_os, os, host_arch, arch)) - ConfigureAndBuild( - arch, - os, - host_os, - host_arch, - parallel_jobs, - configure_args, - options=options) - - -def ConfigureAndBuild(target_arch, target_os, host_os, host_arch, parallel_jobs, - configure_args, options): - if target_os == 'linux' and target_arch == 'noasm-x64': - target_os = 'linux-noasm' - target_arch = 'x64' - - configure_flags = collections.defaultdict(list) - - # Common configuration. Note: --disable-everything does not in fact disable - # everything, just non-library components such as decoders and demuxers. - configure_flags['Common'].extend([ - '--disable-everything', - '--disable-all', - '--disable-doc', - '--disable-htmlpages', - '--disable-manpages', - '--disable-podpages', - '--disable-txtpages', - '--disable-static', - '--enable-avcodec', - '--enable-avformat', - '--enable-avutil', - '--enable-fft', - '--enable-rdft', - '--enable-static', - '--enable-libopus', - - # Disable features. - '--disable-debug', - '--disable-bzlib', - '--disable-error-resilience', - '--disable-iconv', - '--disable-network', - '--disable-schannel', - '--disable-sdl2', - '--disable-symver', - '--disable-xlib', - '--disable-zlib', - '--disable-securetransport', - '--disable-faan', - '--disable-alsa', - - # Disable automatically detected external libraries. This prevents - # automatic inclusion of things like hardware decoders. Each roll should - # audit new [autodetect] configure options and add any desired options to - # this file. - '--disable-autodetect', - - # Common codecs. - '--enable-decoder=vorbis,libopus,flac', - '--enable-decoder=pcm_u8,pcm_s16le,pcm_s24le,pcm_s32le,pcm_f32le,mp3', - '--enable-decoder=pcm_s16be,pcm_s24be,pcm_mulaw,pcm_alaw', - '--enable-demuxer=ogg,matroska,wav,flac,mp3,mov', - '--enable-parser=opus,vorbis,flac,mpegaudio,vp9', - - # Setup include path so Chromium's libopus can be used. - '--extra-cflags=-I' + os.path.join(CHROMIUM_ROOT_DIR, - 'third_party/opus/src/include'), - - # Disable usage of Linux Performance API. Not used in production code, but - # missing system headers break some Android builds. - '--disable-linux-perf', - - # Force usage of nasm. - '--x86asmexe=nasm', - ]) - - if target_os == 'android': - configure_flags['Common'].extend([ - # This replaces --optflags="-Os" since it implies it and since if it is - # also specified, configure ends up dropping all optflags :/ - '--enable-small', - ]) - - configure_flags['Common'].extend(SetupAndroidToolchain(target_arch)) - else: - configure_flags['Common'].extend([ - # --optflags doesn't append multiple entries, so set all at once. - '--optflags="-O3"', - '--extra-cflags=-msse3', - '--extra-cflags=-O3', - '--enable-decoder=theora,vp8', - '--enable-parser=vp3,vp8', - ]) - - if target_os in ('linux', 'linux-noasm', 'android'): - if target_arch == 'x64': - if target_os == 'android': - configure_flags['Common'].extend([ - '--arch=x86_64', - ]) - else: - configure_flags['Common'].extend([ - '--enable-lto', - '--extra-cflags=-O3', - '--extra-cflags=-msse3', - '--arch=x86_64', - '--target-os=linux', - ]) - - if host_arch != 'x64': - configure_flags['Common'].extend([ - '--enable-cross-compile', - '--cross-prefix=/usr/bin/x86_64-linux-gnu-', - '--extra-cflags=--target=x86_64-linux-gnu', - '--extra-ldflags=--target=x86_64-linux-gnu', - ]) - elif target_arch == 'ia32': - configure_flags['Common'].extend([ - '--arch=i686', - '--extra-cflags="-m32"', - '--extra-ldflags="-m32"', - ]) - # Android ia32 can't handle textrels and ffmpeg can't compile without - # them. http://crbug.com/559379 - if target_os == 'android': - configure_flags['Common'].extend([ - '--disable-x86asm', - ]) - elif target_arch == 'arm' or target_arch == 'arm-neon': - # TODO(ihf): ARM compile flags are tricky. The final options - # overriding everything live in chroot /build/*/etc/make.conf - # (some of them coming from src/overlays/overlay-/make.conf). - # We try to follow these here closely. In particular we need to - # set ffmpeg internal #defines to conform to make.conf. - # TODO(ihf): For now it is not clear if thumb or arm settings would be - # faster. I ran experiments in other contexts and performance seemed - # to be close and compiler version dependent. In practice thumb builds are - # much smaller than optimized arm builds, hence we go with the global - # CrOS settings. - configure_flags['Common'].extend([ - '--arch=arm', - '--enable-armv6', - '--enable-armv6t2', - '--enable-vfp', - '--enable-thumb', - '--extra-cflags=-march=armv7-a', - ]) - - if target_os == 'android': - configure_flags['Common'].extend([ - # Runtime neon detection requires /proc/cpuinfo access, so ensure - # av_get_cpu_flags() is run outside of the sandbox when enabled. - '--enable-neon', - '--extra-cflags=-mtune=generic-armv7-a', - # Enabling softfp lets us choose either softfp or hardfp when doing - # the chrome build. - '--extra-cflags=-mfloat-abi=softfp', - ]) - if target_arch == 'arm': - print('arm-neon is the only supported arm arch for Android.\n') - return 1 - - if target_arch == 'arm-neon': - configure_flags['Common'].extend([ - '--extra-cflags=-mfpu=neon', - ]) - else: - configure_flags['Common'].extend([ - '--extra-cflags=-mfpu=vfpv3-d16', - ]) - else: - if host_arch != 'arm': - configure_flags['Common'].extend([ - '--enable-cross-compile', - '--target-os=linux', - '--extra-cflags=--target=arm-linux-gnueabihf', - '--extra-ldflags=--target=arm-linux-gnueabihf', - '--sysroot=' + os.path.join(CHROMIUM_ROOT_DIR, - 'build/linux/debian_bullseye_armhf-sysroot'), - '--extra-cflags=-mtune=cortex-a8', - # NOTE: we don't need softfp for this hardware. - '--extra-cflags=-mfloat-abi=hard', - # For some reason configure drops this... - '--extra-cflags=-O3', - ]) - - if target_arch == 'arm-neon': - configure_flags['Common'].extend([ - '--enable-neon', - '--extra-cflags=-mfpu=neon', - ]) - else: - configure_flags['Common'].extend([ - '--disable-neon', - '--extra-cflags=-mfpu=vfpv3-d16', - ]) - elif target_arch == 'arm64': - if target_os != 'android': - if host_arch != 'arm64': - configure_flags['Common'].extend([ - '--enable-cross-compile', - '--cross-prefix=/usr/bin/aarch64-linux-gnu-', - '--extra-cflags=--target=aarch64-linux-gnu', - '--extra-ldflags=--target=aarch64-linux-gnu', - ]) - - configure_flags['Common'].extend([ - '--target-os=linux', - '--sysroot=' + os.path.join(CHROMIUM_ROOT_DIR, - 'build/linux/debian_bullseye_arm64-sysroot'), - ]) - configure_flags['Common'].extend([ - '--arch=aarch64', - '--enable-armv8', - '--extra-cflags=-march=armv8-a', - ]) - elif target_arch == 'mipsel': - # These flags taken from android chrome build with target_cpu='mipsel' - configure_flags['Common'].extend([ - '--arch=mipsel', - '--disable-mips32r6', - '--disable-mips32r5', - '--disable-mips32r2', - '--disable-mipsdsp', - '--disable-mipsdspr2', - '--disable-msa', - '--enable-mipsfpu', - '--extra-cflags=-march=mipsel', - '--extra-cflags=-mcpu=mips32', - # Required to avoid errors about dynamic relocation w/o -fPIC. - '--extra-ldflags=-z notext', - ]) - if target_os == 'linux': - configure_flags['Common'].extend([ - '--enable-cross-compile', - '--target-os=linux', - '--sysroot=' + os.path.join(CHROMIUM_ROOT_DIR, - 'build/linux/debian_bullseye_mips-sysroot'), - '--extra-cflags=--target=mipsel-linux-gnu', - '--extra-ldflags=--target=mipsel-linux-gnu', - ]) - elif target_arch == 'mips64el': - # These flags taken from android chrome build with target_cpu='mips64el' - configure_flags['Common'].extend([ - '--arch=mips64el', - '--enable-mipsfpu', - '--disable-mipsdsp', - '--disable-mipsdspr2', - '--extra-cflags=-march=mips64el', - # Required to avoid errors about dynamic relocation w/o -fPIC. - '--extra-ldflags=-z notext', - ]) - if target_os == 'android': - configure_flags['Common'].extend([ - '--enable-mips64r6', - '--extra-cflags=-mcpu=mips64r6', - '--disable-mips64r2', - '--enable-msa', - ]) - if target_os == 'linux': - configure_flags['Common'].extend([ - '--enable-cross-compile', - '--target-os=linux', - '--sysroot=' + os.path.join( - CHROMIUM_ROOT_DIR, 'build/linux/debian_bullseye_mips64el-sysroot'), - '--enable-mips64r2', - '--disable-mips64r6', - '--disable-msa', - '--extra-cflags=-mcpu=mips64r2', - '--extra-cflags=--target=mips64el-linux-gnuabi64', - '--extra-ldflags=--target=mips64el-linux-gnuabi64', - ]) - else: - print( - 'Error: Unknown target arch %r for target OS %r!' % (target_arch, - target_os), - file=sys.stderr) - return 1 - - if target_os == 'linux-noasm': - configure_flags['Common'].extend([ - '--disable-asm', - '--disable-inline-asm', - ]) - - if 'win' not in target_os and 'android' not in target_os: - configure_flags['Common'].extend([ - '--enable-pic', - '--cc=clang', - '--cxx=clang++', - '--ld=clang', - ]) - - # Clang Linux will use the first 'ld' it finds on the path, which will - # typically be the system one, so explicitly configure use of Clang's - # ld.lld, to ensure that things like cross-compilation and LTO work. - # This does not work for ia32 and is always used on mac. - if target_arch != 'ia32' and target_os != 'mac': - configure_flags['Common'].append('--extra-ldflags=-fuse-ld=lld') - - # Should be run on Mac, unless we're cross-compiling on Linux. - if target_os == 'mac': - if host_os != 'mac' and host_os != 'linux': - print( - 'Script should be run on a Mac or Linux host.\n', - file=sys.stderr) - return 1 - - if host_os != 'mac': - configure_flags['Common'].extend( - SetupMacCrossCompileToolchain(target_arch)) - else: - # ffmpeg links against Chromium's libopus, which isn't built when this - # script runs. Suppress all undefined symbols (which matches the default - # on Linux), to get things to build. This also requires opting in to - # flat namespaces. - configure_flags['Common'].extend([ - '--extra-ldflags=-Wl,-flat_namespace -Wl,-undefined,warning', - ]) - - if target_arch == 'x64': - configure_flags['Common'].extend([ - '--arch=x86_64', - '--extra-cflags=-m64', - '--extra-ldflags=-arch x86_64', - ]) - elif target_arch == 'arm64': - configure_flags['Common'].extend([ - '--arch=arm64', - '--extra-cflags=-arch arm64', - '--extra-ldflags=-arch arm64', - ]) - else: - print( - 'Error: Unknown target arch %r for target OS %r!' % (target_arch, - target_os), - file=sys.stderr) - - # Should be run on Windows. - if target_os == 'win': - configure_flags['Common'].extend([ - '--toolchain=msvc', - '--extra-cflags=-I' + os.path.join(FFMPEG_DIR, 'chromium/include/win'), - ]) - - if target_arch == 'x64': - configure_flags['Common'].extend(['--target-os=win64']) - elif target_arch == 'x86': - configure_flags['Common'].extend(['--target-os=win32']) - - if host_os != 'win': - configure_flags['Common'].extend( - SetupWindowsCrossCompileToolchain(target_arch)) - - if 'CYGWIN_NT' in platform.system(): - configure_flags['Common'].extend([ - '--cc=cygwin-wrapper cl', - '--ld=cygwin-wrapper link', - '--nm=cygwin-wrapper dumpbin -symbols', - '--ar=cygwin-wrapper lib', - ]) - - # Google Chrome & ChromeOS specific configuration. - configure_flags['Chrome'].extend([ - '--enable-decoder=aac,h264,mp3,eac3,ac3,hevc,mpeg4,mpegvideo,mp2,mp1,flac', - '--enable-demuxer=aac,mp3,mov,dtshd,dts,avi,mpegvideo,m4v,h264,vc1,flac', - '--enable-parser=aac,h264,hevc,mpegaudio,mpeg4video,mpegvideo,ac3,h261,vc1,h263,flac', - ]) - - # Google ChromeOS specific configuration. - # We want to make sure to play everything Android generates and plays. - # http://developer.android.com/guide/appendix/media-formats.html - configure_flags['ChromeOS'].extend([ - # Enable playing avi files. - '--enable-decoder=mpeg4', - '--enable-parser=h263,mpeg4video', - '--enable-demuxer=avi', - # Enable playing Android 3gp files. - '--enable-demuxer=amr', - '--enable-decoder=amrnb,amrwb', - # Wav files for playing phone messages. - '--enable-decoder=gsm_ms', - '--enable-parser=gsm', - ]) - - configure_flags['ChromeAndroid'].extend([ - '--enable-demuxer=aac', - '--enable-parser=aac', - '--enable-decoder=aac', - - # TODO(dalecurtis, watk): Figure out if we need h264 parser for now? - ]) - - def do_build_ffmpeg(branding, configure_flags): - if options.brandings and branding not in options.brandings: - print('%s skipped' % branding) - return - - print('%s configure/build:' % branding) - BuildFFmpeg(target_os, target_arch, host_os, host_arch, parallel_jobs, - options.config_only, branding, configure_flags, options) - - # Only build Chromium, Chrome for ia32, x86 non-android platforms. - if target_os != 'android': - do_build_ffmpeg( - 'Chromium', configure_flags['Common'] + configure_flags['Chromium'] + - configure_args) - do_build_ffmpeg( - 'Chrome', - configure_flags['Common'] + configure_flags['Chrome'] + configure_args) - else: - do_build_ffmpeg('Chromium', configure_flags['Common'] + configure_args) - do_build_ffmpeg( - 'Chrome', configure_flags['Common'] + configure_flags['ChromeAndroid'] + - configure_args) - - if target_os in ['linux', 'linux-noasm']: - # ChromeOS enables MPEG4 which requires error resilience :( - chrome_os_flags = ( - configure_flags['Common'] + configure_flags['Chrome'] + - configure_flags['ChromeOS'] + configure_args) - chrome_os_flags.remove('--disable-error-resilience') - do_build_ffmpeg('ChromeOS', chrome_os_flags) - - print('Done. If desired you may copy config.h/config.asm into the ' - 'source/config tree using copy_config.sh.') - return 0 - - -if __name__ == '__main__': - sys.exit(main(sys.argv[1:])) diff --git a/other/SSE3/v8/BUILD.gn b/other/SSE3/v8/BUILD.gn index ed7a0e9a..1a65b3e2 100644 --- a/other/SSE3/v8/BUILD.gn +++ b/other/SSE3/v8/BUILD.gn @@ -12,10 +12,6 @@ import("//build/config/riscv.gni") import("//build/config/sanitizers/sanitizers.gni") import("//build_overrides/build.gni") -if (is_android) { - import("//build/config/android/rules.gni") -} - import("gni/snapshot_toolchain.gni") import("gni/v8.gni") @@ -323,6 +319,10 @@ declare_args() { # Sets -DV8_ENABLE_SANDBOX. v8_enable_sandbox = "" + # Enable experimental code pointer sandboxing for the V8 sandbox. + # Sets -DV8_CODE_POINTER_SANDBOXING + v8_code_pointer_sandboxing = false + # Expose the memory corruption API to JavaScript. Useful for testing the sandbox. # WARNING This will expose builtins that (by design) cause memory corruption. # Sets -DV8_EXPOSE_MEMORY_CORRUPTION_API @@ -372,13 +372,6 @@ declare_args() { # (incomplete and experimental). v8_enable_cet_shadow_stack = false - # Get VMEX priviledge at startup. - # It allows to run V8 without "deprecated-ambient-replace-as-executable". - # Sets -DV8_USE_VMEX_RESOURCE. - # TODO(victorgomes): Remove this flag once Chormium no longer needs - # the deprecated feature. - v8_fuchsia_use_vmex_resource = is_fuchsia && !build_with_chromium - # Enables pointer compression for 8GB heaps. # Sets -DV8_COMPRESS_POINTERS_8GB. v8_enable_pointer_compression_8gb = "" @@ -397,6 +390,10 @@ declare_args() { # iOS (non-simulator) does not have executable pages for 3rd party # applications yet so disable jit. v8_jitless = v8_enable_lite_mode || target_is_ios_device + + # Enable Maglev's graph printer. + # Sets -DV8_MAGLEV_GRAPH_PRINTER. + v8_enable_maglev_graph_printer = !build_with_chromium } # Derived defaults. @@ -476,13 +473,13 @@ if (v8_enable_short_builtin_calls == "") { if (v8_enable_external_code_space == "") { v8_enable_external_code_space = v8_enable_pointer_compression && - (v8_current_cpu == "x64" || - (target_os != "fuchsia" && v8_current_cpu == "arm64")) + (v8_current_cpu == "x64" || v8_current_cpu == "arm64") } if (v8_enable_maglev == "") { v8_enable_maglev = v8_enable_turbofan && - (v8_current_cpu == "x64" || v8_current_cpu == "arm64") && - v8_enable_pointer_compression + (v8_current_cpu == "arm" || + ((v8_current_cpu == "x64" || v8_current_cpu == "arm64") && + v8_enable_pointer_compression)) } assert(v8_enable_turbofan || !v8_enable_maglev, "Maglev is not available when Turbofan is disabled.") @@ -645,6 +642,9 @@ assert(!v8_enable_sandbox || v8_enable_pointer_compression_shared_cage, assert(!v8_enable_sandbox || v8_enable_external_code_space, "The sandbox requires the external code space") +assert(!v8_code_pointer_sandboxing || v8_enable_sandbox, + "Code pointer sandboxing requires the sandbox") + assert(!v8_expose_memory_corruption_api || v8_enable_sandbox, "The Memory Corruption API requires the sandbox") @@ -678,10 +678,6 @@ if (v8_enable_single_generation == true) { "Requires unconditional write barriers or none (which disables incremental marking)") } -if (v8_fuchsia_use_vmex_resource) { - assert(target_os == "fuchsia", "VMEX resource only available on Fuchsia") -} - assert(!v8_enable_snapshot_compression || v8_use_zlib, "Snapshot compression requires zlib") @@ -724,7 +720,9 @@ config("internal_config") { } if (v8_current_cpu == "riscv64" || v8_current_cpu == "riscv32") { - libs = [ "atomic" ] + if (!is_clang) { + libs = [ "atomic" ] + } } } @@ -796,7 +794,9 @@ config("external_config") { } if (current_cpu == "riscv64" || current_cpu == "riscv32") { - libs = [ "atomic" ] + if (!is_clang) { + libs = [ "atomic" ] + } } } @@ -1142,9 +1142,6 @@ config("features") { if (v8_advanced_bigint_algorithms) { defines += [ "V8_ADVANCED_BIGINT_ALGORITHMS" ] } - if (v8_fuchsia_use_vmex_resource) { - defines += [ "V8_USE_VMEX_RESOURCE" ] - } if (v8_expose_memory_corruption_api) { defines += [ "V8_EXPOSE_MEMORY_CORRUPTION_API" ] } @@ -1169,6 +1166,12 @@ config("features") { if (v8_enable_wasm_simd256_revec) { defines += [ "V8_ENABLE_WASM_SIMD256_REVEC" ] } + if (v8_code_pointer_sandboxing) { + defines += [ "V8_CODE_POINTER_SANDBOXING" ] + } + if (v8_enable_maglev_graph_printer) { + defines += [ "V8_ENABLE_MAGLEV_GRAPH_PRINTER" ] + } } config("toolchain") { @@ -1313,6 +1316,12 @@ config("toolchain") { defines += [ "V8_TARGET_ARCH_RISCV32" ] defines += [ "__riscv_xlen=32" ] defines += [ "CAN_USE_FPU_INSTRUCTIONS" ] + + # TODO(riscv32): Add condition riscv_use_rvv and riscv_rvv_vlen here after + # 4538202 merge. + if (target_is_simulator) { + defines += [ "CAN_USE_RVV_INSTRUCTIONS" ] + } } if (v8_current_cpu == "x86") { @@ -1331,7 +1340,7 @@ config("toolchain") { cflags += [ "/O2", "/arch:SSE3" ] ldflags += [ "/STACK:2097152" ] } - if (is_linux) { + if (is_linux || is_chromeos) { # Full optimization for V8. cflags += [ "-O3", "-msse3" ] ldflags += [ "-Wl,-O3", "-msse3" ] @@ -1339,7 +1348,6 @@ config("toolchain") { } if (is_android && v8_android_log_stdout) { defines += [ "V8_ANDROID_LOG_STDOUT" ] - cflags += [ "-O3" ] } # V8_TARGET_OS_ defines. The target OS may differ from host OS e.g. in @@ -1408,15 +1416,18 @@ config("toolchain") { "-Wmissing-field-initializers", "-Wunreachable-code", - # Google3 enables this warning, so we should also enable it to find issue - # earlier. See https://reviews.llvm.org/D56731 for details about this - # warning. - "-Wctad-maybe-unsupported", - # TODO(v8:12245): Fix shadowing instances and remove. "-Wno-shadow", ] + # TODO(fuchsia:127411): Re-enable once FIDL bindings are compatible. + if (!is_fuchsia) { + # Google3 enables this warning, so we should also enable it to find issue + # earlier. See https://reviews.llvm.org/D56731 for details about this + # warning. + cflags += [ "-Wctad-maybe-unsupported" ] + } + if (v8_current_cpu == "x64" || v8_current_cpu == "arm64" || v8_current_cpu == "mips64el" || v8_current_cpu == "riscv64") { cflags += [ "-Wshorten-64-to-32" ] @@ -1760,6 +1771,7 @@ if (v8_postmortem_support) { "src/objects/string-inl.h", "src/objects/struct.h", "src/objects/struct-inl.h", + "src/objects/tagged.h", ] outputs = [ "$target_gen_dir/debug-support.cc" ] @@ -1826,9 +1838,11 @@ torque_files = [ "src/builtins/iterator.tq", "src/builtins/iterator-from.tq", "src/builtins/iterator-helpers.tq", + "src/builtins/map-groupby.tq", "src/builtins/math.tq", "src/builtins/number.tq", "src/builtins/object-fromentries.tq", + "src/builtins/object-groupby.tq", "src/builtins/object.tq", "src/builtins/promise-abstract-operations.tq", "src/builtins/promise-all.tq", @@ -1864,6 +1878,8 @@ torque_files = [ "src/builtins/regexp-split.tq", "src/builtins/regexp-test.tq", "src/builtins/regexp.tq", + "src/builtins/set-intersection.tq", + "src/builtins/set-union.tq", "src/builtins/string-at.tq", "src/builtins/string-endswith.tq", "src/builtins/string-html.tq", @@ -2003,6 +2019,7 @@ if (v8_enable_i18n_support) { if (v8_enable_webassembly) { torque_files += [ + "src/builtins/js-to-wasm.tq", "src/builtins/wasm.tq", "src/debug/debug-wasm-objects.tq", "src/wasm/wasm-objects.tq", @@ -3082,6 +3099,7 @@ v8_header_set("v8_internal_headers") { "src/compiler/js-create-lowering.h", "src/compiler/js-generic-lowering.h", "src/compiler/js-graph.h", + "src/compiler/js-heap-broker-inl.h", "src/compiler/js-heap-broker.h", "src/compiler/js-inlining-heuristic.h", "src/compiler/js-inlining.h", @@ -3181,7 +3199,6 @@ v8_header_set("v8_internal_headers") { "src/compiler/turboshaft/store-store-elimination-phase.h", "src/compiler/turboshaft/store-store-elimination-reducer.h", "src/compiler/turboshaft/structural-optimization-reducer.h", - "src/compiler/turboshaft/tag-untag-lowering-reducer.h", "src/compiler/turboshaft/tracing.h", "src/compiler/turboshaft/type-assertions-phase.h", "src/compiler/turboshaft/type-inference-analysis.h", @@ -3361,6 +3378,7 @@ v8_header_set("v8_internal_headers") { "src/heap/marking-worklist.h", "src/heap/marking.h", "src/heap/memory-allocator.h", + "src/heap/memory-balancer.h", "src/heap/memory-chunk-inl.h", "src/heap/memory-chunk-layout.h", "src/heap/memory-chunk.h", @@ -3377,6 +3395,7 @@ v8_header_set("v8_internal_headers") { "src/heap/paged-spaces-inl.h", "src/heap/paged-spaces.h", "src/heap/parallel-work-item.h", + "src/heap/parked-scope-inl.h", "src/heap/parked-scope.h", "src/heap/pretenuring-handler-inl.h", "src/heap/pretenuring-handler.h", @@ -3649,6 +3668,7 @@ v8_header_set("v8_internal_headers") { "src/objects/tagged-index.h", "src/objects/tagged-value-inl.h", "src/objects/tagged-value.h", + "src/objects/tagged.h", "src/objects/template-objects-inl.h", "src/objects/template-objects.h", "src/objects/templates-inl.h", @@ -3733,6 +3753,10 @@ v8_header_set("v8_internal_headers") { "src/runtime/runtime.h", "src/sandbox/bounded-size-inl.h", "src/sandbox/bounded-size.h", + "src/sandbox/code-pointer-inl.h", + "src/sandbox/code-pointer-table-inl.h", + "src/sandbox/code-pointer-table.h", + "src/sandbox/code-pointer.h", "src/sandbox/external-entity-table-inl.h", "src/sandbox/external-entity-table.h", "src/sandbox/external-pointer-inl.h", @@ -3752,6 +3776,7 @@ v8_header_set("v8_internal_headers") { "src/snapshot/embedded/embedded-file-writer-interface.h", "src/snapshot/object-deserializer.h", "src/snapshot/read-only-deserializer.h", + "src/snapshot/read-only-serializer-deserializer.h", "src/snapshot/read-only-serializer.h", "src/snapshot/references.h", "src/snapshot/roots-serializer.h", @@ -3856,7 +3881,9 @@ v8_header_set("v8_internal_headers") { "src/maglev/maglev-register-frame-array.h", "src/maglev/maglev.h", ] - if (v8_current_cpu == "arm64") { + if (v8_current_cpu == "arm") { + sources += [ "src/maglev/arm/maglev-assembler-arm-inl.h" ] + } else if (v8_current_cpu == "arm64") { sources += [ "src/maglev/arm64/maglev-assembler-arm64-inl.h" ] } else if (v8_current_cpu == "x64") { sources += [ "src/maglev/x64/maglev-assembler-x64-inl.h" ] @@ -3871,6 +3898,7 @@ v8_header_set("v8_internal_headers") { "src/asmjs/asm-scanner.h", "src/asmjs/asm-types.h", "src/compiler/int64-lowering.h", + "src/compiler/turboshaft/wasm-js-lowering-reducer.h", "src/compiler/wasm-address-reassociation.h", "src/compiler/wasm-call-descriptors.h", "src/compiler/wasm-compiler-definitions.h", @@ -3881,6 +3909,7 @@ v8_header_set("v8_internal_headers") { "src/compiler/wasm-graph-assembler.h", "src/compiler/wasm-inlining-into-js.h", "src/compiler/wasm-inlining.h", + "src/compiler/wasm-js-lowering.h", "src/compiler/wasm-load-elimination.h", "src/compiler/wasm-loop-peeling.h", "src/compiler/wasm-typer.h", @@ -4538,6 +4567,7 @@ if (v8_enable_webassembly) { "src/compiler/wasm-graph-assembler.cc", "src/compiler/wasm-inlining-into-js.cc", "src/compiler/wasm-inlining.cc", + "src/compiler/wasm-js-lowering.cc", "src/compiler/wasm-load-elimination.cc", "src/compiler/wasm-loop-peeling.cc", "src/compiler/wasm-typer.cc", @@ -4889,6 +4919,7 @@ v8_source_set("v8_base_without_compiler") { "src/heap/marking-worklist.cc", "src/heap/marking.cc", "src/heap/memory-allocator.cc", + "src/heap/memory-balancer.cc", "src/heap/memory-chunk-layout.cc", "src/heap/memory-chunk.cc", "src/heap/memory-measurement.cc", @@ -5100,6 +5131,7 @@ v8_source_set("v8_base_without_compiler") { "src/runtime/runtime-typedarray.cc", "src/runtime/runtime-weak-refs.cc", "src/runtime/runtime.cc", + "src/sandbox/code-pointer-table.cc", "src/sandbox/external-pointer-table.cc", "src/sandbox/sandbox.cc", "src/sandbox/testing.cc", @@ -5174,7 +5206,12 @@ v8_source_set("v8_base_without_compiler") { "src/maglev/maglev-regalloc.cc", "src/maglev/maglev.cc", ] - if (v8_current_cpu == "arm64") { + if (v8_current_cpu == "arm") { + sources += [ + "src/maglev/arm/maglev-assembler-arm.cc", + "src/maglev/arm/maglev-ir-arm.cc", + ] + } else if (v8_current_cpu == "arm64") { sources += [ "src/maglev/arm64/maglev-assembler-arm64.cc", "src/maglev/arm64/maglev-ir-arm64.cc", @@ -5589,7 +5626,9 @@ v8_source_set("v8_base_without_compiler") { v8_current_cpu == "ppc" || v8_current_cpu == "ppc64" || v8_current_cpu == "s390" || v8_current_cpu == "s390x" || v8_current_cpu == "riscv64" || v8_current_cpu == "riscv32") { - libs += [ "atomic" ] + if (!is_clang) { + libs += [ "atomic" ] + } } if (v8_enable_vtunetracemark && (is_linux || is_chromeos || is_win)) { @@ -5936,8 +5975,8 @@ v8_component("v8_libbase") { "src/base/platform/platform-fuchsia.cc", ] deps += [ - "//third_party/fuchsia-sdk/sdk/fidl/fuchsia.kernel", - "//third_party/fuchsia-sdk/sdk/pkg/fdio", + "//third_party/fuchsia-sdk/sdk/fidl/fuchsia.kernel:fuchsia.kernel_cpp", + "//third_party/fuchsia-sdk/sdk/pkg/component_incoming_cpp", "//third_party/fuchsia-sdk/sdk/pkg/zx", ] } else if (is_mac) { @@ -5989,7 +6028,9 @@ v8_component("v8_libbase") { } if (v8_current_cpu == "riscv64" || v8_current_cpu == "riscv32") { - libs += [ "atomic" ] + if (!is_clang) { + libs += [ "atomic" ] + } } if (is_tsan && !build_with_chromium) { @@ -6099,7 +6140,9 @@ v8_component("v8_libplatform") { } if (v8_current_cpu == "riscv64" || v8_current_cpu == "riscv32") { - libs = [ "atomic" ] + if (!is_clang) { + libs = [ "atomic" ] + } } } @@ -7038,7 +7081,9 @@ v8_executable("cppgc_hello_world") { sources = [ "samples/cppgc/hello-world.cc" ] if (v8_current_cpu == "riscv64" || v8_current_cpu == "riscv32") { - libs = [ "atomic" ] + if (!is_clang) { + libs = [ "atomic" ] + } } configs = [ diff --git a/src/chrome/app/chrome_main_delegate.cc b/src/chrome/app/chrome_main_delegate.cc index 122514b7..b4c90b00 100644 --- a/src/chrome/app/chrome_main_delegate.cc +++ b/src/chrome/app/chrome_main_delegate.cc @@ -121,6 +121,7 @@ #include "base/message_loop/message_pump_default.h" #include "base/message_loop/message_pump_kqueue.h" #include "base/message_loop/message_pump_mac.h" +#include "base/synchronization/condition_variable.h" #include "chrome/app/chrome_main_mac.h" #include "chrome/browser/chrome_browser_application_mac.h" #include "chrome/browser/headless/headless_mode_util.h" @@ -156,10 +157,9 @@ #include "chrome/browser/ash/boot_times_recorder.h" #include "chrome/browser/ash/dbus/ash_dbus_helper.h" #include "chrome/browser/ash/startup_settings_cache.h" -#include "chromeos/ash/components/memory/kstaled.h" #include "chromeos/ash/components/memory/memory.h" +#include "chromeos/ash/components/memory/mglru.h" #include "chromeos/ash/components/memory/swap_configuration.h" -#include "chromeos/hugepage_text/hugepage_text.h" #include "ui/lottie/resource.h" // nogncheck #endif @@ -217,6 +217,7 @@ #endif // BUILDFLAG(ENABLE_PROCESS_SINGLETON) #if BUILDFLAG(IS_CHROMEOS_LACROS) +#include "base/scoped_add_feature_flags.h" #include "chrome/common/chrome_paths_lacros.h" #include "chromeos/crosapi/cpp/crosapi_constants.h" // nogncheck #include "chromeos/crosapi/mojom/crosapi.mojom.h" // nogncheck @@ -230,6 +231,7 @@ #include "content/public/browser/zygote_host/zygote_host_linux.h" #include "media/base/media_switches.h" #include "ui/base/resource/data_pack_with_resource_sharing_lacros.h" +#include "ui/base/ui_base_features.h" #include "ui/gfx/switches.h" #endif @@ -592,8 +594,7 @@ void InitLogging(const std::string& process_type) { // the min level on ChromeOS. if (process_type.empty()) { LOG(WARNING) << "This is " << chrome::kBrandName << " version: " - << chrome::kChromeVersion - << " (not a warning)"; + << chrome::kChromeVersion << " (not a warning)"; } } #endif // !BUILDFLAG(IS_ANDROID) @@ -778,6 +779,13 @@ absl::optional ChromeMainDelegate::PostEarlyInitialization( // Redirect logs from system directory to cryptohome. if (chromeos::IsLaunchedWithPostLoginParams()) RedirectLacrosLogging(); + + // Must be added before feature list is created otherwise the added flag won't + // be picked up. + if (chromeos::BrowserParamsProxy::Get()->IsVariableRefreshRateEnabled()) { + base::ScopedAddFeatureFlags(base::CommandLine::ForCurrentProcess()) + .EnableIfNotSet(features::kEnableVariableRefreshRate); + } #endif // BUILDFLAG(IS_CHROMEOS_LACROS) // The DBus initialization above is needed for FeatureList creation here; @@ -930,7 +938,7 @@ void ChromeMainDelegate::CommonEarlyInitialization() { if (is_browser_process) { #if BUILDFLAG(IS_CHROMEOS_ASH) ash::ConfigureSwap(arc::IsArcAvailable()); - ash::InitializeKstaled(); + ash::InitializeMGLRU(); #endif } @@ -965,6 +973,7 @@ void ChromeMainDelegate::CommonEarlyInitialization() { base::PlatformThread::InitFeaturesPostFieldTrial(); base::MessagePumpCFRunLoopBase::InitializeFeatures(); base::MessagePumpKqueue::InitializeFeatures(); + base::ConditionVariable::InitializeFeatures(); #endif } @@ -1648,10 +1657,6 @@ void ChromeMainDelegate::ProcessExiting(const std::string& process_type) { #if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) void ChromeMainDelegate::ZygoteStarting( std::vector>* delegates) { -#if BUILDFLAG(IS_CHROMEOS_ASH) - chromeos::InitHugepagesAndMlockSelf(); -#endif - #if BUILDFLAG(ENABLE_NACL) nacl::AddNaClZygoteForkDelegates(delegates); #endif diff --git a/src/v8/BUILD.gn b/src/v8/BUILD.gn index 3b0d0e4f..e3c19d58 100644 --- a/src/v8/BUILD.gn +++ b/src/v8/BUILD.gn @@ -12,10 +12,6 @@ import("//build/config/riscv.gni") import("//build/config/sanitizers/sanitizers.gni") import("//build_overrides/build.gni") -if (is_android) { - import("//build/config/android/rules.gni") -} - import("gni/snapshot_toolchain.gni") import("gni/v8.gni") @@ -323,6 +319,10 @@ declare_args() { # Sets -DV8_ENABLE_SANDBOX. v8_enable_sandbox = "" + # Enable experimental code pointer sandboxing for the V8 sandbox. + # Sets -DV8_CODE_POINTER_SANDBOXING + v8_code_pointer_sandboxing = false + # Expose the memory corruption API to JavaScript. Useful for testing the sandbox. # WARNING This will expose builtins that (by design) cause memory corruption. # Sets -DV8_EXPOSE_MEMORY_CORRUPTION_API @@ -372,13 +372,6 @@ declare_args() { # (incomplete and experimental). v8_enable_cet_shadow_stack = false - # Get VMEX priviledge at startup. - # It allows to run V8 without "deprecated-ambient-replace-as-executable". - # Sets -DV8_USE_VMEX_RESOURCE. - # TODO(victorgomes): Remove this flag once Chormium no longer needs - # the deprecated feature. - v8_fuchsia_use_vmex_resource = is_fuchsia && !build_with_chromium - # Enables pointer compression for 8GB heaps. # Sets -DV8_COMPRESS_POINTERS_8GB. v8_enable_pointer_compression_8gb = "" @@ -397,6 +390,10 @@ declare_args() { # iOS (non-simulator) does not have executable pages for 3rd party # applications yet so disable jit. v8_jitless = v8_enable_lite_mode || target_is_ios_device + + # Enable Maglev's graph printer. + # Sets -DV8_MAGLEV_GRAPH_PRINTER. + v8_enable_maglev_graph_printer = !build_with_chromium } # Derived defaults. @@ -476,13 +473,13 @@ if (v8_enable_short_builtin_calls == "") { if (v8_enable_external_code_space == "") { v8_enable_external_code_space = v8_enable_pointer_compression && - (v8_current_cpu == "x64" || - (target_os != "fuchsia" && v8_current_cpu == "arm64")) + (v8_current_cpu == "x64" || v8_current_cpu == "arm64") } if (v8_enable_maglev == "") { v8_enable_maglev = v8_enable_turbofan && - (v8_current_cpu == "x64" || v8_current_cpu == "arm64") && - v8_enable_pointer_compression + (v8_current_cpu == "arm" || + ((v8_current_cpu == "x64" || v8_current_cpu == "arm64") && + v8_enable_pointer_compression)) } assert(v8_enable_turbofan || !v8_enable_maglev, "Maglev is not available when Turbofan is disabled.") @@ -645,6 +642,9 @@ assert(!v8_enable_sandbox || v8_enable_pointer_compression_shared_cage, assert(!v8_enable_sandbox || v8_enable_external_code_space, "The sandbox requires the external code space") +assert(!v8_code_pointer_sandboxing || v8_enable_sandbox, + "Code pointer sandboxing requires the sandbox") + assert(!v8_expose_memory_corruption_api || v8_enable_sandbox, "The Memory Corruption API requires the sandbox") @@ -678,10 +678,6 @@ if (v8_enable_single_generation == true) { "Requires unconditional write barriers or none (which disables incremental marking)") } -if (v8_fuchsia_use_vmex_resource) { - assert(target_os == "fuchsia", "VMEX resource only available on Fuchsia") -} - assert(!v8_enable_snapshot_compression || v8_use_zlib, "Snapshot compression requires zlib") @@ -724,7 +720,9 @@ config("internal_config") { } if (v8_current_cpu == "riscv64" || v8_current_cpu == "riscv32") { - libs = [ "atomic" ] + if (!is_clang) { + libs = [ "atomic" ] + } } } @@ -796,7 +794,9 @@ config("external_config") { } if (current_cpu == "riscv64" || current_cpu == "riscv32") { - libs = [ "atomic" ] + if (!is_clang) { + libs = [ "atomic" ] + } } } @@ -1142,9 +1142,6 @@ config("features") { if (v8_advanced_bigint_algorithms) { defines += [ "V8_ADVANCED_BIGINT_ALGORITHMS" ] } - if (v8_fuchsia_use_vmex_resource) { - defines += [ "V8_USE_VMEX_RESOURCE" ] - } if (v8_expose_memory_corruption_api) { defines += [ "V8_EXPOSE_MEMORY_CORRUPTION_API" ] } @@ -1169,6 +1166,12 @@ config("features") { if (v8_enable_wasm_simd256_revec) { defines += [ "V8_ENABLE_WASM_SIMD256_REVEC" ] } + if (v8_code_pointer_sandboxing) { + defines += [ "V8_CODE_POINTER_SANDBOXING" ] + } + if (v8_enable_maglev_graph_printer) { + defines += [ "V8_ENABLE_MAGLEV_GRAPH_PRINTER" ] + } } config("toolchain") { @@ -1313,6 +1316,12 @@ config("toolchain") { defines += [ "V8_TARGET_ARCH_RISCV32" ] defines += [ "__riscv_xlen=32" ] defines += [ "CAN_USE_FPU_INSTRUCTIONS" ] + + # TODO(riscv32): Add condition riscv_use_rvv and riscv_rvv_vlen here after + # 4538202 merge. + if (target_is_simulator) { + defines += [ "CAN_USE_RVV_INSTRUCTIONS" ] + } } if (v8_current_cpu == "x86") { @@ -1331,7 +1340,7 @@ config("toolchain") { cflags += [ "/O2", "/arch:AVX" ] ldflags += [ "/STACK:2097152" ] } - if (is_linux) { + if (is_linux || is_chromeos) { # Full optimization for V8. cflags += [ "-O3", "-mavx", "-maes" ] ldflags += [ "-Wl,-O3", "-mavx", "-maes" ] @@ -1339,7 +1348,6 @@ config("toolchain") { } if (is_android && v8_android_log_stdout) { defines += [ "V8_ANDROID_LOG_STDOUT" ] - cflags += [ "-O3" ] } # V8_TARGET_OS_ defines. The target OS may differ from host OS e.g. in @@ -1408,15 +1416,18 @@ config("toolchain") { "-Wmissing-field-initializers", "-Wunreachable-code", - # Google3 enables this warning, so we should also enable it to find issue - # earlier. See https://reviews.llvm.org/D56731 for details about this - # warning. - "-Wctad-maybe-unsupported", - # TODO(v8:12245): Fix shadowing instances and remove. "-Wno-shadow", ] + # TODO(fuchsia:127411): Re-enable once FIDL bindings are compatible. + if (!is_fuchsia) { + # Google3 enables this warning, so we should also enable it to find issue + # earlier. See https://reviews.llvm.org/D56731 for details about this + # warning. + cflags += [ "-Wctad-maybe-unsupported" ] + } + if (v8_current_cpu == "x64" || v8_current_cpu == "arm64" || v8_current_cpu == "mips64el" || v8_current_cpu == "riscv64") { cflags += [ "-Wshorten-64-to-32" ] @@ -1760,6 +1771,7 @@ if (v8_postmortem_support) { "src/objects/string-inl.h", "src/objects/struct.h", "src/objects/struct-inl.h", + "src/objects/tagged.h", ] outputs = [ "$target_gen_dir/debug-support.cc" ] @@ -1826,9 +1838,11 @@ torque_files = [ "src/builtins/iterator.tq", "src/builtins/iterator-from.tq", "src/builtins/iterator-helpers.tq", + "src/builtins/map-groupby.tq", "src/builtins/math.tq", "src/builtins/number.tq", "src/builtins/object-fromentries.tq", + "src/builtins/object-groupby.tq", "src/builtins/object.tq", "src/builtins/promise-abstract-operations.tq", "src/builtins/promise-all.tq", @@ -1864,6 +1878,8 @@ torque_files = [ "src/builtins/regexp-split.tq", "src/builtins/regexp-test.tq", "src/builtins/regexp.tq", + "src/builtins/set-intersection.tq", + "src/builtins/set-union.tq", "src/builtins/string-at.tq", "src/builtins/string-endswith.tq", "src/builtins/string-html.tq", @@ -2003,6 +2019,7 @@ if (v8_enable_i18n_support) { if (v8_enable_webassembly) { torque_files += [ + "src/builtins/js-to-wasm.tq", "src/builtins/wasm.tq", "src/debug/debug-wasm-objects.tq", "src/wasm/wasm-objects.tq", @@ -3082,6 +3099,7 @@ v8_header_set("v8_internal_headers") { "src/compiler/js-create-lowering.h", "src/compiler/js-generic-lowering.h", "src/compiler/js-graph.h", + "src/compiler/js-heap-broker-inl.h", "src/compiler/js-heap-broker.h", "src/compiler/js-inlining-heuristic.h", "src/compiler/js-inlining.h", @@ -3181,7 +3199,6 @@ v8_header_set("v8_internal_headers") { "src/compiler/turboshaft/store-store-elimination-phase.h", "src/compiler/turboshaft/store-store-elimination-reducer.h", "src/compiler/turboshaft/structural-optimization-reducer.h", - "src/compiler/turboshaft/tag-untag-lowering-reducer.h", "src/compiler/turboshaft/tracing.h", "src/compiler/turboshaft/type-assertions-phase.h", "src/compiler/turboshaft/type-inference-analysis.h", @@ -3361,6 +3378,7 @@ v8_header_set("v8_internal_headers") { "src/heap/marking-worklist.h", "src/heap/marking.h", "src/heap/memory-allocator.h", + "src/heap/memory-balancer.h", "src/heap/memory-chunk-inl.h", "src/heap/memory-chunk-layout.h", "src/heap/memory-chunk.h", @@ -3377,6 +3395,7 @@ v8_header_set("v8_internal_headers") { "src/heap/paged-spaces-inl.h", "src/heap/paged-spaces.h", "src/heap/parallel-work-item.h", + "src/heap/parked-scope-inl.h", "src/heap/parked-scope.h", "src/heap/pretenuring-handler-inl.h", "src/heap/pretenuring-handler.h", @@ -3649,6 +3668,7 @@ v8_header_set("v8_internal_headers") { "src/objects/tagged-index.h", "src/objects/tagged-value-inl.h", "src/objects/tagged-value.h", + "src/objects/tagged.h", "src/objects/template-objects-inl.h", "src/objects/template-objects.h", "src/objects/templates-inl.h", @@ -3733,6 +3753,10 @@ v8_header_set("v8_internal_headers") { "src/runtime/runtime.h", "src/sandbox/bounded-size-inl.h", "src/sandbox/bounded-size.h", + "src/sandbox/code-pointer-inl.h", + "src/sandbox/code-pointer-table-inl.h", + "src/sandbox/code-pointer-table.h", + "src/sandbox/code-pointer.h", "src/sandbox/external-entity-table-inl.h", "src/sandbox/external-entity-table.h", "src/sandbox/external-pointer-inl.h", @@ -3752,6 +3776,7 @@ v8_header_set("v8_internal_headers") { "src/snapshot/embedded/embedded-file-writer-interface.h", "src/snapshot/object-deserializer.h", "src/snapshot/read-only-deserializer.h", + "src/snapshot/read-only-serializer-deserializer.h", "src/snapshot/read-only-serializer.h", "src/snapshot/references.h", "src/snapshot/roots-serializer.h", @@ -3856,7 +3881,9 @@ v8_header_set("v8_internal_headers") { "src/maglev/maglev-register-frame-array.h", "src/maglev/maglev.h", ] - if (v8_current_cpu == "arm64") { + if (v8_current_cpu == "arm") { + sources += [ "src/maglev/arm/maglev-assembler-arm-inl.h" ] + } else if (v8_current_cpu == "arm64") { sources += [ "src/maglev/arm64/maglev-assembler-arm64-inl.h" ] } else if (v8_current_cpu == "x64") { sources += [ "src/maglev/x64/maglev-assembler-x64-inl.h" ] @@ -3871,6 +3898,7 @@ v8_header_set("v8_internal_headers") { "src/asmjs/asm-scanner.h", "src/asmjs/asm-types.h", "src/compiler/int64-lowering.h", + "src/compiler/turboshaft/wasm-js-lowering-reducer.h", "src/compiler/wasm-address-reassociation.h", "src/compiler/wasm-call-descriptors.h", "src/compiler/wasm-compiler-definitions.h", @@ -3881,6 +3909,7 @@ v8_header_set("v8_internal_headers") { "src/compiler/wasm-graph-assembler.h", "src/compiler/wasm-inlining-into-js.h", "src/compiler/wasm-inlining.h", + "src/compiler/wasm-js-lowering.h", "src/compiler/wasm-load-elimination.h", "src/compiler/wasm-loop-peeling.h", "src/compiler/wasm-typer.h", @@ -4538,6 +4567,7 @@ if (v8_enable_webassembly) { "src/compiler/wasm-graph-assembler.cc", "src/compiler/wasm-inlining-into-js.cc", "src/compiler/wasm-inlining.cc", + "src/compiler/wasm-js-lowering.cc", "src/compiler/wasm-load-elimination.cc", "src/compiler/wasm-loop-peeling.cc", "src/compiler/wasm-typer.cc", @@ -4889,6 +4919,7 @@ v8_source_set("v8_base_without_compiler") { "src/heap/marking-worklist.cc", "src/heap/marking.cc", "src/heap/memory-allocator.cc", + "src/heap/memory-balancer.cc", "src/heap/memory-chunk-layout.cc", "src/heap/memory-chunk.cc", "src/heap/memory-measurement.cc", @@ -5100,6 +5131,7 @@ v8_source_set("v8_base_without_compiler") { "src/runtime/runtime-typedarray.cc", "src/runtime/runtime-weak-refs.cc", "src/runtime/runtime.cc", + "src/sandbox/code-pointer-table.cc", "src/sandbox/external-pointer-table.cc", "src/sandbox/sandbox.cc", "src/sandbox/testing.cc", @@ -5174,7 +5206,12 @@ v8_source_set("v8_base_without_compiler") { "src/maglev/maglev-regalloc.cc", "src/maglev/maglev.cc", ] - if (v8_current_cpu == "arm64") { + if (v8_current_cpu == "arm") { + sources += [ + "src/maglev/arm/maglev-assembler-arm.cc", + "src/maglev/arm/maglev-ir-arm.cc", + ] + } else if (v8_current_cpu == "arm64") { sources += [ "src/maglev/arm64/maglev-assembler-arm64.cc", "src/maglev/arm64/maglev-ir-arm64.cc", @@ -5589,7 +5626,9 @@ v8_source_set("v8_base_without_compiler") { v8_current_cpu == "ppc" || v8_current_cpu == "ppc64" || v8_current_cpu == "s390" || v8_current_cpu == "s390x" || v8_current_cpu == "riscv64" || v8_current_cpu == "riscv32") { - libs += [ "atomic" ] + if (!is_clang) { + libs += [ "atomic" ] + } } if (v8_enable_vtunetracemark && (is_linux || is_chromeos || is_win)) { @@ -5936,8 +5975,8 @@ v8_component("v8_libbase") { "src/base/platform/platform-fuchsia.cc", ] deps += [ - "//third_party/fuchsia-sdk/sdk/fidl/fuchsia.kernel", - "//third_party/fuchsia-sdk/sdk/pkg/fdio", + "//third_party/fuchsia-sdk/sdk/fidl/fuchsia.kernel:fuchsia.kernel_cpp", + "//third_party/fuchsia-sdk/sdk/pkg/component_incoming_cpp", "//third_party/fuchsia-sdk/sdk/pkg/zx", ] } else if (is_mac) { @@ -5989,7 +6028,9 @@ v8_component("v8_libbase") { } if (v8_current_cpu == "riscv64" || v8_current_cpu == "riscv32") { - libs += [ "atomic" ] + if (!is_clang) { + libs += [ "atomic" ] + } } if (is_tsan && !build_with_chromium) { @@ -6099,7 +6140,9 @@ v8_component("v8_libplatform") { } if (v8_current_cpu == "riscv64" || v8_current_cpu == "riscv32") { - libs = [ "atomic" ] + if (!is_clang) { + libs = [ "atomic" ] + } } } @@ -7038,7 +7081,9 @@ v8_executable("cppgc_hello_world") { sources = [ "samples/cppgc/hello-world.cc" ] if (v8_current_cpu == "riscv64" || v8_current_cpu == "riscv32") { - libs = [ "atomic" ] + if (!is_clang) { + libs = [ "atomic" ] + } } configs = [