diff --git a/DEPS b/DEPS index b60c80280ff..ee16733aa74 100644 --- a/DEPS +++ b/DEPS @@ -514,6 +514,17 @@ Var("dart_root") + "/third_party/pkg/tar": Var("dart_root") + "/third_party/pkg/yaml": Var("dart_git") + "yaml.git" + "@" + Var("yaml_rev"), + Var("dart_root") + "/buildtools/sysroot/linux": { + "packages": [ + { + "package": "fuchsia/third_party/sysroot/linux", + "version": "git_revision:fa7a5a9710540f30ff98ae48b62f2cdf72ed2acd", + }, + ], + "condition": "host_os == linux", + "dep_type": "cipd", + }, + # Keep consistent with pkg/test_runner/lib/src/options.dart. Var("dart_root") + "/buildtools/linux-x64/clang": { "packages": [ @@ -767,34 +778,6 @@ hooks = [ 'pattern': '.', 'action': ['python3', 'sdk/tools/generate_sdk_version_file.py'], }, - { - 'name': 'sysroot_arm', - 'pattern': '.', - 'condition': 'checkout_linux', - 'action': ['python3', 'sdk/build/linux/sysroot_scripts/install-sysroot.py', - '--arch=arm'], - }, - { - 'name': 'sysroot_arm64', - 'pattern': '.', - 'condition': 'checkout_linux', - 'action': ['python3', 'sdk/build/linux/sysroot_scripts/install-sysroot.py', - '--arch=arm64'], - }, - { - 'name': 'sysroot_x86', - 'pattern': '.', - 'condition': 'checkout_linux', - 'action': ['python3', 'sdk/build/linux/sysroot_scripts/install-sysroot.py', - '--arch=x86'], - }, - { - 'name': 'sysroot_x64', - 'pattern': '.', - 'condition': 'checkout_linux', - 'action': ['python3', 'sdk/build/linux/sysroot_scripts/install-sysroot.py', - '--arch=x64'], - }, { 'name': 'buildtools', 'pattern': '.', diff --git a/build/config/sysroot.gni b/build/config/sysroot.gni index ba510206492..7cd849166dd 100644 --- a/build/config/sysroot.gni +++ b/build/config/sysroot.gni @@ -37,22 +37,7 @@ if (is_linux) { assert(false) } } else if (dart_sysroot == "debian") { - if (current_cpu == "x86") { - target_sysroot = rebase_path("//build/linux/debian_stretch_i386-sysroot", - root_build_dir) - } else if (current_cpu == "x64") { - target_sysroot = rebase_path("//build/linux/debian_stretch_amd64-sysroot", - root_build_dir) - } else if (current_cpu == "arm") { - target_sysroot = rebase_path("//build/linux/debian_stretch_arm-sysroot", - root_build_dir) - } else if (current_cpu == "arm64") { - target_sysroot = rebase_path("//build/linux/debian_stretch_arm64-sysroot", - root_build_dir) - } else { - print("There is no $dart_sysroot sysroot present for $current_cpu") - assert(false) - } + target_sysroot = rebase_path("//buildtools/sysroot/linux", root_build_dir) } else if (dart_sysroot != "") { print("There is no $dart_sysroot sysroot support") assert(false) diff --git a/build/linux/sysroot_scripts/README.dart.md b/build/linux/sysroot_scripts/README.dart.md deleted file mode 100644 index c71ad34b804..00000000000 --- a/build/linux/sysroot_scripts/README.dart.md +++ /dev/null @@ -1,5 +0,0 @@ -This directory contains a script and a json file describing the sysroots that -Dart downloads and builds against on Linux. Dart uses the sysroots vended by -Chromium. See: - -https://chromium.googlesource.com/chromium/src/build/+/master/linux/sysroot_scripts diff --git a/build/linux/sysroot_scripts/install-sysroot.py b/build/linux/sysroot_scripts/install-sysroot.py deleted file mode 100755 index aea292d4832..00000000000 --- a/build/linux/sysroot_scripts/install-sysroot.py +++ /dev/null @@ -1,171 +0,0 @@ -#!/usr/bin/env python3 -# Copyright (c) 2013 The Chromium Authors. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -"""Install Debian sysroots for building chromium. -""" - -# The sysroot is needed to ensure that binaries that get built will run on -# the oldest stable version of Debian that we currently support. -# This script can be run manually but is more often run as part of gclient -# hooks. When run from hooks this script is a no-op on non-linux platforms. - -# The sysroot image could be constructed from scratch based on the current state -# of the Debian archive but for consistency we use a pre-built root image (we -# don't want upstream changes to Debian to effect the chromium build until we -# choose to pull them in). The images will normally need to be rebuilt every -# time chrome's build dependencies are changed but should also be updated -# periodically to include upstream security fixes from Debian. - -# This script looks at sysroots.json next to it to find the name of a .tar.xz -# to download and the location to extract it to. The extracted sysroot could for -# example be in build/linux/debian_bullseye_amd64-sysroot/. - -from __future__ import print_function - -import hashlib -import json -import platform -import optparse -import os -import re -import shutil -import subprocess -import sys -try: - # For Python 3.0 and later - from urllib.request import urlopen -except ImportError: - # Fall back to Python 2's urllib2 - from urllib2 import urlopen - -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) - -URL_PREFIX = 'https://commondatastorage.googleapis.com' -URL_PATH = 'chrome-linux-sysroot/toolchain' - -VALID_ARCHS = ('arm', 'arm64', 'i386', 'amd64', 'mips', 'mips64el') - -ARCH_TRANSLATIONS = { - 'x64': 'amd64', - 'x86': 'i386', - 'mipsel': 'mips', - 'mips64': 'mips64el', -} - -DEFAULT_TARGET_PLATFORM = 'stretch' - - -class Error(Exception): - pass - - -def GetSha1(filename): - sha1 = hashlib.sha1() - with open(filename, 'rb') as f: - while True: - # Read in 1mb chunks, so it doesn't all have to be loaded into memory. - chunk = f.read(1024*1024) - if not chunk: - break - sha1.update(chunk) - return sha1.hexdigest() - - -def main(args): - parser = optparse.OptionParser('usage: %prog [OPTIONS]', description=__doc__) - parser.add_option('--arch', - help='Sysroot architecture: %s' % ', '.join(VALID_ARCHS)) - parser.add_option('--all', action='store_true', - help='Install all sysroot images (useful when updating the' - ' images)') - parser.add_option('--print-hash', - help='Print the hash of the sysroot for the given arch.') - options, _ = parser.parse_args(args) - - if options.print_hash: - arch = options.print_hash - print(GetSysrootDict(DEFAULT_TARGET_PLATFORM, - ARCH_TRANSLATIONS.get(arch, arch))['Sha1Sum']) - return 0 - if options.arch: - InstallSysroot(DEFAULT_TARGET_PLATFORM, - ARCH_TRANSLATIONS.get(options.arch, options.arch)) - elif options.all: - for arch in VALID_ARCHS: - InstallSysroot(DEFAULT_TARGET_PLATFORM, arch) - else: - print('You much specify one of the options.') - return 1 - - return 0 - - -def GetSysrootDict(target_platform, target_arch): - if target_arch not in VALID_ARCHS: - raise Error('Unknown architecture: %s' % target_arch) - - sysroots_file = os.path.join(SCRIPT_DIR, 'sysroots.json') - sysroots = json.load(open(sysroots_file)) - sysroot_key = '%s_%s' % (target_platform, target_arch) - if sysroot_key not in sysroots: - raise Error('No sysroot for: %s %s' % (target_platform, target_arch)) - return sysroots[sysroot_key] - - -def InstallSysroot(target_platform, target_arch): - sysroot_dict = GetSysrootDict(target_platform, target_arch) - revision = sysroot_dict['Revision'] - tarball_filename = sysroot_dict['Tarball'] - tarball_sha1sum = sysroot_dict['Sha1Sum'] - # TODO(thestig) Consider putting this elsewhere to avoid having to recreate - # it on every build. - linux_dir = os.path.dirname(SCRIPT_DIR) - sysroot = os.path.join(linux_dir, sysroot_dict['SysrootDir']) - - url = '%s/%s/%s/%s' % (URL_PREFIX, URL_PATH, revision, - tarball_filename) - - stamp = os.path.join(sysroot, '.stamp') - if os.path.exists(stamp): - with open(stamp) as s: - if s.read() == url: - return - - print('Installing Debian %s %s root image: %s' % \ - (target_platform, target_arch, sysroot)) - if os.path.isdir(sysroot): - shutil.rmtree(sysroot) - os.mkdir(sysroot) - tarball = os.path.join(sysroot, tarball_filename) - print('Downloading %s' % url) - sys.stdout.flush() - sys.stderr.flush() - for _ in range(3): - try: - response = urlopen(url) - with open(tarball, "wb") as f: - f.write(response.read()) - break - except Exception: # Ignore exceptions. - pass - else: - raise Error('Failed to download %s' % url) - sha1sum = GetSha1(tarball) - if sha1sum != tarball_sha1sum: - raise Error('Tarball sha1sum is wrong.' - 'Expected %s, actual: %s' % (tarball_sha1sum, sha1sum)) - subprocess.check_call(['tar', 'xf', tarball, '-C', sysroot]) - os.remove(tarball) - - with open(stamp, 'w') as s: - s.write(url) - - -if __name__ == '__main__': - try: - sys.exit(main(sys.argv[1:])) - except Error as e: - sys.stderr.write(str(e) + '\n') - sys.exit(1) diff --git a/build/linux/sysroot_scripts/sysroots.json b/build/linux/sysroot_scripts/sysroots.json deleted file mode 100644 index dc6de3e0f35..00000000000 --- a/build/linux/sysroot_scripts/sysroots.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "stretch_amd64": { - "Revision": "1126d9b629c97385a503debac7a1b59e60a3ab1b", - "Sha1Sum": "a73bcd43fc4910afe264f730f7c06f5ef5c965cd", - "SysrootDir": "debian_stretch_amd64-sysroot", - "Tarball": "debian_stretch_amd64_sysroot.tar.xz" - }, - "stretch_arm": { - "Revision": "1126d9b629c97385a503debac7a1b59e60a3ab1b", - "Sha1Sum": "7c5c22fbfca6fd825a63363bc906fbfa800d7f95", - "SysrootDir": "debian_stretch_arm-sysroot", - "Tarball": "debian_stretch_arm_sysroot.tar.xz" - }, - "stretch_arm64": { - "Revision": "1126d9b629c97385a503debac7a1b59e60a3ab1b", - "Sha1Sum": "ab8063f2d9d6b777797653041851c3f9274a33af", - "SysrootDir": "debian_stretch_arm64-sysroot", - "Tarball": "debian_stretch_arm64_sysroot.tar.xz" - }, - "stretch_i386": { - "Revision": "1126d9b629c97385a503debac7a1b59e60a3ab1b", - "Sha1Sum": "72ed2ce337bd40e8e7a89e5501b0b63050453d6c", - "SysrootDir": "debian_stretch_i386-sysroot", - "Tarball": "debian_stretch_i386_sysroot.tar.xz" - }, - "stretch_mips": { - "Revision": "1126d9b629c97385a503debac7a1b59e60a3ab1b", - "Sha1Sum": "fe5949ed3795aa64913a27389052637ea2629da3", - "SysrootDir": "debian_stretch_mips-sysroot", - "Tarball": "debian_stretch_mips_sysroot.tar.xz" - }, - "stretch_mips64el": { - "Revision": "1126d9b629c97385a503debac7a1b59e60a3ab1b", - "Sha1Sum": "5d95b45a9633c3c874d3ab9326306b0e951f01f1", - "SysrootDir": "debian_stretch_mips64el-sysroot", - "Tarball": "debian_stretch_mips64el_sysroot.tar.xz" - } -} diff --git a/tools/gn.py b/tools/gn.py index 730267196ab..aae350a3181 100755 --- a/tools/gn.py +++ b/tools/gn.py @@ -178,14 +178,11 @@ def UseSysroot(args, gn_args): # Don't use the sysroot if we're given another sysroot. if TargetSysroot(args): return False - # Our Debian Jesse sysroot doesn't work with GCC 9 + # Don't use the sysroot if we're given another toolchain. if not gn_args['is_clang']: return False - # Our Debian Jesse sysroot has incorrect annotations on realloc. - if gn_args['is_ubsan']: - return False - # Our Debian Jesse sysroot doesn't support RISCV - if gn_args['target_cpu'] in ['riscv32', 'riscv64']: + # Fuchsia's Linux sysroot doesn't support RISCV32 + if gn_args['target_cpu'] in ['riscv32']: return False # Otherwise use the sysroot. return True