diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2022-09-29 16:16:15 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2022-11-09 10:04:06 +0000 |
commit | a95a7417ad456115a1ef2da4bb8320531c0821f1 (patch) | |
tree | edcd59279e486d2fd4a8f88a7ed025bcf925c6e6 /chromium/tools/clang | |
parent | 33fc33aa94d4add0878ec30dc818e34e1dd3cc2a (diff) | |
download | qtwebengine-chromium-a95a7417ad456115a1ef2da4bb8320531c0821f1.tar.gz |
BASELINE: Update Chromium to 106.0.5249.126
Change-Id: Ib0bb21c437a7d1686e21c33f2d329f2ac425b7ab
Reviewed-on: https://codereview.qt-project.org/c/qt/qtwebengine-chromium/+/438936
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'chromium/tools/clang')
19 files changed, 473 insertions, 537 deletions
diff --git a/chromium/tools/clang/blink_gc_plugin/CMakeLists.txt b/chromium/tools/clang/blink_gc_plugin/CMakeLists.txt index 1ccb2ee6764..27ab135243a 100644 --- a/chromium/tools/clang/blink_gc_plugin/CMakeLists.txt +++ b/chromium/tools/clang/blink_gc_plugin/CMakeLists.txt @@ -31,6 +31,6 @@ endforeach() set_property(TARGET clang APPEND PROPERTY SOURCES ${absolute_sources}) cr_add_test(blink_gc_plugin_test - python tests/test.py + python3 tests/test.py ${CMAKE_BINARY_DIR}/bin/clang ) diff --git a/chromium/tools/clang/blink_gc_plugin/process-graph.py b/chromium/tools/clang/blink_gc_plugin/process-graph.py index eac8f363c64..c5976892a58 100755 --- a/chromium/tools/clang/blink_gc_plugin/process-graph.py +++ b/chromium/tools/clang/blink_gc_plugin/process-graph.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # Copyright 2014 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. diff --git a/chromium/tools/clang/plugins/CMakeLists.txt b/chromium/tools/clang/plugins/CMakeLists.txt index 0c79c004b19..63f5deed03d 100644 --- a/chromium/tools/clang/plugins/CMakeLists.txt +++ b/chromium/tools/clang/plugins/CMakeLists.txt @@ -23,6 +23,6 @@ endforeach() set_property(TARGET clang APPEND PROPERTY SOURCES ${absolute_sources}) cr_add_test(plugins_test - python tests/test.py + python3 tests/test.py ${CMAKE_BINARY_DIR}/bin/clang ) diff --git a/chromium/tools/clang/plugins/FindBadConstructsAction.cpp b/chromium/tools/clang/plugins/FindBadConstructsAction.cpp index f1618de6480..3ba4e6e69a1 100644 --- a/chromium/tools/clang/plugins/FindBadConstructsAction.cpp +++ b/chromium/tools/clang/plugins/FindBadConstructsAction.cpp @@ -53,12 +53,8 @@ bool FindBadConstructsAction::ParseArgs(const CompilerInstance& instance, options_.check_gmock_objects = true; } else if (args[i] == "check-layout-object-methods") { options_.check_layout_object_methods = true; - } else if (args[i] == "checked-ptr-as-trivial-member") { - options_.checked_ptr_as_trivial_member = true; - } else if (args[i] == "raw-ptr-template-as-trivial-member") { - options_.raw_ptr_template_as_trivial_member = true; - } else if (args[i] == "use-classify-type") { - // This option is ignored, will be removed soon. + } else if (args[i] == "raw-ref-template-as-trivial-member") { + options_.raw_ref_template_as_trivial_member = true; } else { parsed = false; llvm::errs() << "Unknown clang plugin argument: " << args[i] << "\n"; diff --git a/chromium/tools/clang/plugins/FindBadConstructsConsumer.cpp b/chromium/tools/clang/plugins/FindBadConstructsConsumer.cpp index 0dadc5eb5fc..1f004360ff5 100644 --- a/chromium/tools/clang/plugins/FindBadConstructsConsumer.cpp +++ b/chromium/tools/clang/plugins/FindBadConstructsConsumer.cpp @@ -70,10 +70,8 @@ bool IsGmockObject(const CXXRecordDecl* decl) { } bool IsPodOrTemplateType(const CXXRecordDecl& record) { - return record.isPOD() || - record.getDescribedClassTemplate() || - record.getTemplateSpecializationKind() || - record.isDependentType(); + return record.isPOD() || record.getDescribedClassTemplate() || + record.getTemplateSpecializationKind() || record.isDependentType(); } // Use a local RAV implementation to simply collect all FunctionDecls marked for @@ -226,13 +224,16 @@ void FindBadConstructsConsumer::Traverse(ASTContext& context) { layout_visitor_->VisitLayoutObjectMethods(context); } RecursiveASTVisitor::TraverseDecl(context.getTranslationUnitDecl()); - if (ipc_visitor_) ipc_visitor_->set_context(nullptr); + if (ipc_visitor_) + ipc_visitor_->set_context(nullptr); } bool FindBadConstructsConsumer::TraverseDecl(Decl* decl) { - if (ipc_visitor_) ipc_visitor_->BeginDecl(decl); + if (ipc_visitor_) + ipc_visitor_->BeginDecl(decl); bool result = RecursiveASTVisitor::TraverseDecl(decl); - if (ipc_visitor_) ipc_visitor_->EndDecl(); + if (ipc_visitor_) + ipc_visitor_->EndDecl(); return result; } @@ -249,12 +250,14 @@ bool FindBadConstructsConsumer::VisitTagDecl(clang::TagDecl* tag_decl) { bool FindBadConstructsConsumer::VisitTemplateSpecializationType( TemplateSpecializationType* spec) { - if (ipc_visitor_) ipc_visitor_->VisitTemplateSpecializationType(spec); + if (ipc_visitor_) + ipc_visitor_->VisitTemplateSpecializationType(spec); return true; } bool FindBadConstructsConsumer::VisitCallExpr(CallExpr* call_expr) { - if (ipc_visitor_) ipc_visitor_->VisitCallExpr(call_expr); + if (ipc_visitor_) + ipc_visitor_->VisitCallExpr(call_expr); return true; } @@ -369,8 +372,7 @@ void FindBadConstructsConsumer::CheckCtorDtorWeight( // destructor can be inlined. int templated_base_classes = 0; for (CXXRecordDecl::base_class_const_iterator it = record->bases_begin(); - it != record->bases_end(); - ++it) { + it != record->bases_end(); ++it) { if (it->getTypeSourceInfo()->getTypeLoc().getTypeLocClass() == TypeLoc::TemplateSpecialization) { ++templated_base_classes; @@ -382,8 +384,7 @@ void FindBadConstructsConsumer::CheckCtorDtorWeight( int non_trivial_member = 0; int templated_non_trivial_member = 0; for (RecordDecl::field_iterator it = record->field_begin(); - it != record->field_end(); - ++it) { + it != record->field_end(); ++it) { switch (ClassifyType(it->getType().getTypePtr())) { case TypeClassification::kTrivial: trivial_member += 1; @@ -429,8 +430,7 @@ void FindBadConstructsConsumer::CheckCtorDtorWeight( // Iterate across all the constructors in this file and yell if we // find one that tries to be inline. for (CXXRecordDecl::ctor_iterator it = record->ctor_begin(); - it != record->ctor_end(); - ++it) { + it != record->ctor_end(); ++it) { // The current check is buggy. An implicit copy constructor does not // have an inline body, so this check never fires for classes with a // user-declared out-of-line constructor. @@ -462,8 +462,9 @@ void FindBadConstructsConsumer::CheckCtorDtorWeight( diag_inline_complex_ctor_); } } else if (it->isInlined() && !it->isInlineSpecified() && - !it->isDeleted() && (!it->isCopyOrMoveConstructor() || - it->isExplicitlyDefaulted())) { + !it->isDeleted() && + (!it->isCopyOrMoveConstructor() || + it->isExplicitlyDefaulted())) { // isInlined() is a more reliable check than hasInlineBody(), but // unfortunately, it results in warnings for implicit copy/move // constructors in the previously mentioned situation. To preserve @@ -528,8 +529,7 @@ void FindBadConstructsConsumer::CheckVirtualMethods( } for (CXXRecordDecl::method_iterator it = record->method_begin(); - it != record->method_end(); - ++it) { + it != record->method_end(); ++it) { if (it->isCopyAssignmentOperator() || isa<CXXConstructorDecl>(*it)) { // Ignore constructors and assignment operators. } else if (isa<CXXDestructorDecl>(*it) && @@ -708,13 +708,16 @@ FindBadConstructsConsumer::ClassifyType(const Type* type) { if (name == "std::basic_string") return TypeClassification::kNonTrivialExternTemplate; - // `base::raw_ptr` is non-trivial if the `use_backup_ref_ptr` flag is - // enabled, and trivial otherwise. Since there are many existing types - // using this that we don't wish to burden with defining custom - // ctors/dtors, and we'd rather not vary on triviality by build config, - // treat this as always trivial. - if (name == "base::raw_ptr") + // `base::raw_ptr` and `base::raw_ref` are non-trivial if the + // `use_backup_ref_ptr` flag is enabled, and trivial otherwise. Since + // there are many existing types using this that we don't wish to burden + // with defining custom ctors/dtors, and we'd rather not vary on + // triviality by build config, treat this as always trivial. + if (name == "base::raw_ptr" || + (options_.raw_ref_template_as_trivial_member && + name == "base::raw_ref")) { return TypeClassification::kTrivialTemplate; + } return TypeClassification::kNonTrivial; } @@ -837,9 +840,8 @@ FindBadConstructsConsumer::CheckRecordForRefcountIssue( // Returns true if |base| specifies one of the Chromium reference counted // classes (base::RefCounted / base::RefCountedThreadSafe). -bool FindBadConstructsConsumer::IsRefCounted( - const CXXBaseSpecifier* base, - CXXBasePath& path) { +bool FindBadConstructsConsumer::IsRefCounted(const CXXBaseSpecifier* base, + CXXBasePath& path) { const TemplateSpecializationType* base_type = dyn_cast<TemplateSpecializationType>( UnwrapType(base->getType().getTypePtr())); @@ -990,8 +992,7 @@ void FindBadConstructsConsumer::CheckRefCountedDtors( } for (CXXBasePaths::const_paths_iterator it = dtor_paths.begin(); - it != dtor_paths.end(); - ++it) { + it != dtor_paths.end(); ++it) { // The record with the problem will always be the last record // in the path, since it is the record that stopped the search. const CXXRecordDecl* problem_record = dyn_cast<CXXRecordDecl>( diff --git a/chromium/tools/clang/plugins/Options.h b/chromium/tools/clang/plugins/Options.h index e3e29e14742..78fd7fb9d05 100644 --- a/chromium/tools/clang/plugins/Options.h +++ b/chromium/tools/clang/plugins/Options.h @@ -12,8 +12,7 @@ struct Options { bool check_ipc = false; bool check_gmock_objects = false; bool check_layout_object_methods = false; - bool checked_ptr_as_trivial_member = false; - bool raw_ptr_template_as_trivial_member = false; + bool raw_ref_template_as_trivial_member = false; }; } // namespace chrome_checker diff --git a/chromium/tools/clang/pylib/clang/compile_db_test.py b/chromium/tools/clang/pylib/clang/compile_db_test.py index 06b7e43ef8e..2ae494236c6 100755 --- a/chromium/tools/clang/pylib/clang/compile_db_test.py +++ b/chromium/tools/clang/pylib/clang/compile_db_test.py @@ -1,4 +1,4 @@ -#!/usr/bin/env vpython +#!/usr/bin/env vpython3 # Copyright 2019 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. diff --git a/chromium/tools/clang/rewrite_raw_ptr_fields/RewriteRawPtrFields.cpp b/chromium/tools/clang/rewrite_raw_ptr_fields/RewriteRawPtrFields.cpp index c7e2d9662d8..b854538dbe7 100644 --- a/chromium/tools/clang/rewrite_raw_ptr_fields/RewriteRawPtrFields.cpp +++ b/chromium/tools/clang/rewrite_raw_ptr_fields/RewriteRawPtrFields.cpp @@ -852,6 +852,14 @@ class FieldDeclRewriter : public MatchFinder::MatchCallback { const clang::TypeSourceInfo* type_source_info = field_decl->getTypeSourceInfo(); + if (auto* ivar_decl = clang::dyn_cast<clang::ObjCIvarDecl>(field_decl)) { + // Objective-C @synthesize statements should not be rewritten. They return + // null for getTypeSourceInfo(). + if (ivar_decl->getSynthesize()) { + assert(!type_source_info); + return; + } + } assert(type_source_info && "assuming |type_source_info| is always present"); clang::QualType pointer_type = type_source_info->getType(); diff --git a/chromium/tools/clang/rewrite_raw_ptr_fields/manual-fields-to-ignore.txt b/chromium/tools/clang/rewrite_raw_ptr_fields/manual-fields-to-ignore.txt index 1a88fb4b414..71549e3c53f 100644 --- a/chromium/tools/clang/rewrite_raw_ptr_fields/manual-fields-to-ignore.txt +++ b/chromium/tools/clang/rewrite_raw_ptr_fields/manual-fields-to-ignore.txt @@ -67,6 +67,7 @@ views::LayoutManager::view_setting_visibility_on_ FullscreenController::deactivated_contents_ content::RenderWidgetHostInputEventRouter::touch_target_ content::RenderWidgetHostInputEventRouter::touchpad_gesture_target_ +base::MessagePumpLibevent::run_state_ # Populated manually - incompatibilities with tracing in not-rewritten platform specific code TabStripModelChange::RemovedTab::contents @@ -235,6 +236,36 @@ device::(anonymous namespace)::CBORExtract_RequiredInOptionalMap_Test::TestBody( # Populated manually - pointer to Objective-C object gfx::ScopedNSGraphicsContextSaveGState::context_ base::mac::ScopedNSAutoreleasePool::autorelease_pool_ +content::ThemeHelperMac::theme_observer_ +content::PopupMenuHelper::menu_runner_ +content::ShellJavaScriptDialog::helper_ +ui::ClipboardFormatType::data_ +ui::WeakPtrNSObjectFactory::handle_ +content::NativeEventProcessorObserver::event_ +image_editor::EventCaptureMac::web_contents_view_ +image_editor::EventCaptureMac::window_ +content::ScopedNotifyNativeEventProcessorObserver::event_ +device::fido::mac::TouchIdCredentialStore::authentication_context_ + +# Populated manually - struct is part of separate binary and must be a POD +# https://source.chromium.org/chromium/chromium/src/+/main:chrome/common/mac/app_mode_common.mm;l=64 +app_mode::ChromeAppModeInfo::argv + +# Populated manually - requires @property rewrite +# In Objective-C the instance variable type and property type must be the same. +# Currently, the rewriter can only rewrite the instance variable declaration. +# So the types do not match, and causes a compiler error. +# These fields can be rewritten once the rewriter can rewrite @property declarations. +ObjCPropertyTestBase::_basePointer +ObjCPropertyTestDerived::_derivedPointer +ObjCPropertyTestDerived::_protoPointer +NativeWidgetMacNSWindow::_bridge +AlertBridgeHelper::_alertBridge +BridgedContentView::_bridge +WindowControlsOverlayNSView::_bridge +AXPlatformNodeCocoa::_node +ShellNativeAppWindowController::_appWindow +WatchedLifetimeMenuController::_deallocCalled ####### # BackupRefPtr-specific sections @@ -309,6 +340,11 @@ disk_cache::MappedFile::buffer_ network::MojoToNetPendingBuffer::buffer_ network::NetToMojoPendingBuffer::buffer_ +# Populated manually - Field initialized with non-nullptr value in constexpr. +enterprise_connectors::ServiceProvider::analysis +enterprise_connectors::ServiceProvider::reporting +enterprise_connectors::ServiceProvider::file_system + # Populated manually - based on sampling profiler data and tab_search:top100:2020 profiler data (anonymous namespace)::TlsVectorEntry::data LinkNodeBase::next_ diff --git a/chromium/tools/clang/rewrite_raw_ptr_fields/manual-paths-to-ignore.txt b/chromium/tools/clang/rewrite_raw_ptr_fields/manual-paths-to-ignore.txt index 0a7941f3f14..df0e1d1b79b 100644 --- a/chromium/tools/clang/rewrite_raw_ptr_fields/manual-paths-to-ignore.txt +++ b/chromium/tools/clang/rewrite_raw_ptr_fields/manual-paths-to-ignore.txt @@ -23,6 +23,7 @@ base/allocator/ # TODO(bartekn): Update the list of dependencies. base/logging.h base/synchronization/lock_impl.h +base/check.h # Exclude - deprecated and contains legacy C++ and pre-C++11 code. ppapi/ diff --git a/chromium/tools/clang/rewrite_raw_ptr_fields/rewrite-multiple-platforms.sh b/chromium/tools/clang/rewrite_raw_ptr_fields/rewrite-multiple-platforms.sh index 7d809473f5f..9f22361fb40 100755 --- a/chromium/tools/clang/rewrite_raw_ptr_fields/rewrite-multiple-platforms.sh +++ b/chromium/tools/clang/rewrite_raw_ptr_fields/rewrite-multiple-platforms.sh @@ -70,6 +70,31 @@ chrome_pgo_phase = 0 EOF ;; + linux) + cat <<EOF +target_os = "linux" +dcheck_always_on = true +is_chrome_branded = true +is_debug = false +is_official_build = true +use_goma = false +chrome_pgo_phase = 0 +EOF + ;; + + cros) + cat <<EOF +target_os = "chromeos" +chromeos_is_browser_only = true +dcheck_always_on = true +is_chrome_branded = true +is_debug = false +is_official_build = true +use_goma = false +chrome_pgo_phase = 0 +EOF + ;; + mac) cat <<EOF target_os = "mac" diff --git a/chromium/tools/clang/scripts/build.py b/chromium/tools/clang/scripts/build.py index 9313a10005f..970f53cfc14 100755 --- a/chromium/tools/clang/scripts/build.py +++ b/chromium/tools/clang/scripts/build.py @@ -27,7 +27,8 @@ import tempfile from update import (CDS_URL, CHROMIUM_DIR, CLANG_REVISION, LLVM_BUILD_DIR, FORCE_HEAD_REVISION_FILE, PACKAGE_VERSION, RELEASE_VERSION, - STAMP_FILE, DownloadUrl, DownloadAndUnpack, EnsureDirExists, + STAMP_FILE, THIS_DIR, DownloadUrl, DownloadAndUnpack, + DownloadAndUnpackPackage, EnsureDirExists, GetDefaultHostOs, ReadStampFile, RmTree, WriteStampFile) # Path constants. (All of these should be absolute paths.) @@ -147,7 +148,10 @@ def CheckoutLLVM(commit, dir): print('Removing %s.' % dir) RmTree(dir) - clone_cmd = ['git', 'clone', 'https://github.com/llvm/llvm-project/', dir] + clone_cmd = [ + 'git', 'clone', 'https://chromium.googlesource.com/external/' + + 'github.com/llvm/llvm-project', dir + ] if RunCommand(clone_cmd, fail_hard=False): os.chdir(dir) @@ -166,11 +170,11 @@ def UrlOpen(url): def GetLatestLLVMCommit(): """Get the latest commit hash in the LLVM monorepo.""" - ref = json.loads( - UrlOpen(('https://api.github.com/repos/' - 'llvm/llvm-project/git/refs/heads/main'))) - assert ref['object']['type'] == 'commit' - return ref['object']['sha'] + main = json.loads( + UrlOpen('https://chromium.googlesource.com/external/' + + 'github.com/llvm/llvm-project/' + + '+/refs/heads/main?format=JSON').replace(")]}'", "")) + return main['commit'] def GetCommitDescription(commit): @@ -183,14 +187,6 @@ def GetCommitDescription(commit): universal_newlines=True).rstrip() -def DeleteChromeToolsShim(): - # TODO: These dirs are no longer used. Remove this code after a while. - OLD_SHIM_DIR = os.path.join(LLVM_DIR, 'tools', 'zzz-chrometools') - shutil.rmtree(OLD_SHIM_DIR, ignore_errors=True) - CHROME_TOOLS_SHIM_DIR = os.path.join(LLVM_DIR, 'llvm', 'tools', 'chrometools') - shutil.rmtree(CHROME_TOOLS_SHIM_DIR, ignore_errors=True) - - def AddCMakeToPath(args): """Download CMake and add it to PATH.""" if args.use_system_cmake: @@ -389,22 +385,9 @@ def DownloadRPMalloc(): def DownloadPinnedClang(): - # The update.py in this current revision may have a patched revision while - # building new clang packages. Get update.py off HEAD~ to pull the current - # pinned clang. - if not os.path.exists(PINNED_CLANG_DIR): - os.mkdir(os.path.join(PINNED_CLANG_DIR)) - - script_path = os.path.join(PINNED_CLANG_DIR, 'update.py') - - with open(script_path, 'w') as f: - subprocess.check_call( - ['git', 'show', 'HEAD~:tools/clang/scripts/update.py'], - stdout=f, - cwd=CHROMIUM_DIR) - print("Running pinned update.py") - subprocess.check_call( - [sys.executable, script_path, '--output-dir=' + PINNED_CLANG_DIR]) + PINNED_CLANG_VERSION = 'llvmorg-16-init-572-gdde41c6c-3' + DownloadAndUnpackPackage('clang', PINNED_CLANG_DIR, GetDefaultHostOs(), + PINNED_CLANG_VERSION) # TODO(crbug.com/929645): Remove once we don't need gcc's libstdc++. @@ -414,8 +397,8 @@ def MaybeDownloadHostGcc(args): if args.gcc_toolchain: return gcc_dir = os.path.join(LLVM_BUILD_TOOLS_DIR, 'gcc-10.2.0-bionic') - if os.path.isdir(gcc_dir): # TODO(thakis): Remove this branch after a few weeks. - RmTree(gcc_dir) + if os.path.isdir(gcc_dir): + RmTree(gcc_dir) # TODO(thakis): Remove this branch after a few weeks. if not os.path.exists(gcc_dir): DownloadAndUnpack(CDS_URL + '/tools/gcc-10.2.0-bionic.tgz', gcc_dir) args.gcc_toolchain = gcc_dir @@ -476,6 +459,28 @@ def CopyLibstdcpp(args, build_dir): CopyFile(libstdcpp, os.path.join(build_dir, 'lib')) +def compiler_rt_cmake_flags(*, sanitizers, profile): + # Don't set -DCOMPILER_RT_BUILD_BUILTINS=ON/OFF as it interferes with the + # runtimes logic of building builtins. + args = [ + # Build crtbegin/crtend. It's just two tiny TUs, so just enable this + # everywhere, even though we only need it on Linux. + 'COMPILER_RT_BUILD_CRT=ON', + 'COMPILER_RT_BUILD_LIBFUZZER=OFF', + 'COMPILER_RT_BUILD_MEMPROF=OFF', + 'COMPILER_RT_BUILD_ORC=OFF', + 'COMPILER_RT_BUILD_PROFILE=' + ('ON' if profile else 'OFF'), + 'COMPILER_RT_BUILD_SANITIZERS=' + ('ON' if sanitizers else 'OFF'), + 'COMPILER_RT_BUILD_XRAY=OFF', + # See crbug.com/1205046: don't build scudo (and others we don't need). + 'COMPILER_RT_SANITIZERS_TO_BUILD=asan;dfsan;msan;hwasan;tsan;cfi', + # We explicitly list all targets we want to build, do not autodetect + # targets. + 'COMPILER_RT_DEFAULT_TARGET_ONLY=ON', + ] + return args + + def gn_arg(v): if v == 'True': return True @@ -590,9 +595,6 @@ def main(): # move this down to where we fetch other build tools. AddGnuWinToPath() - if sys.platform == 'darwin': - isysroot = subprocess.check_output(['xcrun', '--show-sdk-path'], - universal_newlines=True).rstrip() if args.build_dir: LLVM_BUILD_DIR = args.build_dir @@ -614,7 +616,6 @@ def main(): WriteStampFile('', FORCE_HEAD_REVISION_FILE) AddCMakeToPath(args) - DeleteChromeToolsShim() if args.skip_build: @@ -633,18 +634,15 @@ def main(): targets = 'AArch64;ARM;Mips;PowerPC;RISCV;SystemZ;WebAssembly;X86' - projects = 'clang;compiler-rt;lld;clang-tools-extra' - - if sys.platform == 'darwin': - # clang needs libc++, else -stdlib=libc++ won't find includes - # (this is needed for bootstrap builds and for building the fuchsia runtime) - projects += ';libcxx' + projects = 'clang;lld;clang-tools-extra' + runtimes = 'compiler-rt' base_cmake_args = [ '-GNinja', '-DCMAKE_BUILD_TYPE=Release', '-DLLVM_ENABLE_ASSERTIONS=%s' % ('OFF' if args.disable_asserts else 'ON'), '-DLLVM_ENABLE_PROJECTS=' + projects, + '-DLLVM_ENABLE_RUNTIMES=' + runtimes, '-DLLVM_TARGETS_TO_BUILD=' + targets, # PIC needed for Rust build (links LLVM into shared object) '-DLLVM_ENABLE_PIC=ON', @@ -657,12 +655,8 @@ def main(): '-DBUG_REPORT_URL=' + BUG_REPORT_URL, # Don't run Go bindings tests; PGO makes them confused. '-DLLVM_INCLUDE_GO_TESTS=OFF', - # TODO(crbug.com/1113475): Update binutils. - '-DENABLE_X86_RELAX_RELOCATIONS=NO', # See crbug.com/1126219: Use native symbolizer instead of DIA '-DLLVM_ENABLE_DIA_SDK=OFF', - # See crbug.com/1205046: don't build scudo (and others we don't need). - '-DCOMPILER_RT_SANITIZERS_TO_BUILD=asan;dfsan;msan;hwasan;tsan;cfi', # The default value differs per platform, force it off everywhere. '-DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=OFF', # Don't use curl. @@ -670,6 +664,20 @@ def main(): # Build libclang.a as well as libclang.so '-DLIBCLANG_BUILD_STATIC=ON', ] + + if sys.platform == 'darwin': + isysroot = subprocess.check_output(['xcrun', '--show-sdk-path'], + universal_newlines=True).rstrip() + + # See https://crbug.com/1302636#c49 - #c56 -- intercepting crypt_r() does not + # work with the sysroot for not fully understood reasons. Disable it. + sanitizers_override = [ + '-DSANITIZER_OVERRIDE_INTERCEPTORS', + '-I' + os.path.join(THIS_DIR, 'sanitizers'), + ] + cflags += sanitizers_override + cxxflags += sanitizers_override + if args.host_cc or args.host_cxx: assert args.host_cc and args.host_cxx, \ "--host-cc and --host-cxx need to be used together" @@ -690,38 +698,65 @@ def main(): cc = os.path.join(PINNED_CLANG_DIR, 'bin', 'clang') cxx = os.path.join(PINNED_CLANG_DIR, 'bin', 'clang++') - if sys.platform != 'darwin': - # The host clang has lld, but self-hosting with lld is still slightly - # broken on mac. - # TODO: check if this works now. - base_cmake_args.append('-DLLVM_ENABLE_LLD=ON') - if sys.platform.startswith('linux'): MaybeDownloadHostGcc(args) - # Use the libraries in the specified gcc installation for building. - cflags.append('--gcc-toolchain=' + args.gcc_toolchain) - cxxflags.append('--gcc-toolchain=' + args.gcc_toolchain) - base_cmake_args += [ - '-DLLVM_STATIC_LINK_CXX_STDLIB=ON', - # Force compiler-rt tests to use our gcc toolchain - # because the one on the host may be too old. - # Even with -static-libstdc++ the compiler-rt tests add -lstdc++ - # which adds a DT_NEEDED to libstdc++.so so we need to add RPATHs - # to the gcc toolchain. - '-DCOMPILER_RT_TEST_COMPILER_CFLAGS=--gcc-toolchain=' + - args.gcc_toolchain + ' -Wl,-rpath,' + - os.path.join(args.gcc_toolchain, 'lib64') + ' -Wl,-rpath,' + - os.path.join(args.gcc_toolchain, 'lib32') - ] - - if sys.platform == 'darwin': - # For libc++, we only want the headers. - base_cmake_args.extend([ - '-DLIBCXX_ENABLE_SHARED=OFF', - '-DLIBCXX_ENABLE_STATIC=OFF', - '-DLIBCXX_INCLUDE_TESTS=OFF', - '-DLIBCXX_ENABLE_EXPERIMENTAL_LIBRARY=OFF', - ]) + base_cmake_args += [ '-DLLVM_STATIC_LINK_CXX_STDLIB=ON' ] + + if sys.platform != 'darwin': + # The host clang has lld, but self-hosting with lld is still slightly + # broken on mac. + # TODO: check if this works now. + base_cmake_args.append('-DLLVM_ENABLE_LLD=ON') + + if sys.platform.startswith('linux'): + # Download sysroots. This uses basically Chromium's sysroots, but with + # minor changes: + # - glibc version bumped to 2.18 to make __cxa_thread_atexit_impl + # work (clang can require 2.18; chromium currently doesn't) + # - libcrypt.so.1 reversioned so that crypt() is picked up from glibc + # The sysroot was built at + # https://chromium-review.googlesource.com/c/chromium/src/+/3684954/1 + # and the hashes here are from sysroots.json in that CL. + toolchain_bucket = 'https://commondatastorage.googleapis.com/chrome-linux-sysroot/toolchain/' + + # amd64 + # hash from https://chromium-review.googlesource.com/c/chromium/src/+/3684954/1/build/linux/sysroot_scripts/sysroots.json#3 + toolchain_hash = '2028cdaf24259d23adcff95393b8cc4f0eef714b' + toolchain_name = 'debian_bullseye_amd64_sysroot' + U = toolchain_bucket + toolchain_hash + '/' + toolchain_name + '.tar.xz' + sysroot_amd64 = os.path.join(LLVM_BUILD_TOOLS_DIR, toolchain_name) + DownloadAndUnpack(U, sysroot_amd64) + + # i386 + # hash from https://chromium-review.googlesource.com/c/chromium/src/+/3684954/1/build/linux/sysroot_scripts/sysroots.json#23 + toolchain_hash = 'a033618b5e092c86e96d62d3c43f7363df6cebe7' + toolchain_name = 'debian_bullseye_i386_sysroot' + U = toolchain_bucket + toolchain_hash + '/' + toolchain_name + '.tar.xz' + sysroot_i386 = os.path.join(LLVM_BUILD_TOOLS_DIR, toolchain_name) + DownloadAndUnpack(U, sysroot_i386) + + # arm + # hash from https://chromium-review.googlesource.com/c/chromium/src/+/3684954/1/build/linux/sysroot_scripts/sysroots.json#8 + toolchain_hash = '0b9a3c54d2d5f6b1a428369aaa8d7ba7b227f701' + toolchain_name = 'debian_bullseye_arm_sysroot' + U = toolchain_bucket + toolchain_hash + '/' + toolchain_name + '.tar.xz' + sysroot_arm = os.path.join(LLVM_BUILD_TOOLS_DIR, toolchain_name) + DownloadAndUnpack(U, sysroot_arm) + + # arm64 + # hash from https://chromium-review.googlesource.com/c/chromium/src/+/3684954/1/build/linux/sysroot_scripts/sysroots.json#12 + toolchain_hash = '0e28d9832614729bb5b731161ff96cb4d516f345' + toolchain_name = 'debian_bullseye_arm64_sysroot' + U = toolchain_bucket + toolchain_hash + '/' + toolchain_name + '.tar.xz' + sysroot_arm64 = os.path.join(LLVM_BUILD_TOOLS_DIR, toolchain_name) + DownloadAndUnpack(U, sysroot_arm64) + + # Add the sysroot to base_cmake_args. + if platform.machine() == 'aarch64': + base_cmake_args.append('-DCMAKE_SYSROOT=' + sysroot_arm64) + else: + # amd64 is the default toolchain. + base_cmake_args.append('-DCMAKE_SYSROOT=' + sysroot_amd64) if sys.platform == 'win32': base_cmake_args.append('-DLLVM_USE_CRT_RELEASE=MT') @@ -752,14 +787,16 @@ def main(): os.chdir(LLVM_BOOTSTRAP_DIR) projects = 'clang' - if args.pgo: - # Need libclang_rt.profile - projects += ';compiler-rt' + runtimes = '' + if args.pgo or sys.platform == 'darwin': + # Need libclang_rt.profile for PGO. + # On macOS, the bootstrap toolchain needs to have compiler-rt because + # dsymutil's link needs libclang_rt.osx.a. Only the x86_64 osx + # libraries are needed though, and only libclang_rt (i.e. + # COMPILER_RT_BUILD_BUILTINS). + runtimes += ';compiler-rt' if sys.platform != 'darwin': projects += ';lld' - if sys.platform == 'darwin': - # Need libc++ and compiler-rt for the bootstrap compiler on mac. - projects += ';libcxx;compiler-rt' bootstrap_targets = 'X86' if sys.platform == 'darwin': @@ -768,6 +805,7 @@ def main(): bootstrap_args = base_cmake_args + [ '-DLLVM_TARGETS_TO_BUILD=' + bootstrap_targets, '-DLLVM_ENABLE_PROJECTS=' + projects, + '-DLLVM_ENABLE_RUNTIMES=' + runtimes, '-DCMAKE_INSTALL_PREFIX=' + LLVM_BOOTSTRAP_INSTALL_DIR, '-DCMAKE_C_FLAGS=' + ' '.join(cflags), '-DCMAKE_CXX_FLAGS=' + ' '.join(cxxflags), @@ -777,19 +815,13 @@ def main(): # Ignore args.disable_asserts for the bootstrap compiler. '-DLLVM_ENABLE_ASSERTIONS=ON', ] + # PGO needs libclang_rt.profile but none of the other compiler-rt stuff. + bootstrap_args.extend([ + '-D' + f + for f in compiler_rt_cmake_flags(sanitizers=False, profile=args.pgo) + ]) if sys.platform == 'darwin': - # On macOS, the bootstrap toolchain needs to have compiler-rt because - # dsymutil's link needs libclang_rt.osx.a. Only the x86_64 osx - # libraries are needed though, and only libclang_rt (i.e. - # COMPILER_RT_BUILD_BUILTINS). bootstrap_args.extend([ - '-DCOMPILER_RT_BUILD_BUILTINS=ON', - '-DCOMPILER_RT_BUILD_CRT=OFF', - '-DCOMPILER_RT_BUILD_LIBFUZZER=OFF', - '-DCOMPILER_RT_BUILD_MEMPROF=OFF', - '-DCOMPILER_RT_BUILD_ORC=OFF', - '-DCOMPILER_RT_BUILD_SANITIZERS=OFF', - '-DCOMPILER_RT_BUILD_XRAY=OFF', '-DCOMPILER_RT_ENABLE_IOS=OFF', '-DCOMPILER_RT_ENABLE_WATCHOS=OFF', '-DCOMPILER_RT_ENABLE_TVOS=OFF', @@ -798,18 +830,6 @@ def main(): bootstrap_args.extend(['-DDARWIN_osx_ARCHS=arm64']) else: bootstrap_args.extend(['-DDARWIN_osx_ARCHS=x86_64']) - elif args.pgo: - # PGO needs libclang_rt.profile but none of the other compiler-rt stuff. - bootstrap_args.extend([ - '-DCOMPILER_RT_BUILD_BUILTINS=OFF', - '-DCOMPILER_RT_BUILD_CRT=OFF', - '-DCOMPILER_RT_BUILD_LIBFUZZER=OFF', - '-DCOMPILER_RT_BUILD_MEMPROF=OFF', - '-DCOMPILER_RT_BUILD_ORC=OFF', - '-DCOMPILER_RT_BUILD_PROFILE=ON', - '-DCOMPILER_RT_BUILD_SANITIZERS=OFF', - '-DCOMPILER_RT_BUILD_XRAY=OFF', - ]) if cc is not None: bootstrap_args.append('-DCMAKE_C_COMPILER=' + cc) if cxx is not None: bootstrap_args.append('-DCMAKE_CXX_COMPILER=' + cxx) @@ -844,8 +864,6 @@ def main(): os.chdir(LLVM_INSTRUMENTED_DIR) projects = 'clang' - if sys.platform == 'darwin': - projects += ';libcxx;compiler-rt' instrument_args = base_cmake_args + [ '-DLLVM_ENABLE_PROJECTS=' + projects, @@ -896,7 +914,7 @@ def main(): '-target', 'x86_64-unknown-unknown', '-O2', '-g', '-std=c++14', '-fno-exceptions', '-fno-rtti', '-w', '-c', training_source] if sys.platform == 'darwin': - train_cmd.extend(['-stdlib=libc++', '-isysroot', isysroot]) + train_cmd.extend(['-isysroot', isysroot]) RunCommand(train_cmd, msvc_arch='x64') # Merge profiles. @@ -906,49 +924,7 @@ def main(): '*.profraw')), msvc_arch='x64') print('Profile generated.') - compiler_rt_args = [ - # Build crtbegin/crtend. It's just two tiny TUs, so just enable this - # everywhere, even though we only need it on Linux. - '-DCOMPILER_RT_BUILD_CRT=ON', - '-DCOMPILER_RT_BUILD_LIBFUZZER=OFF', - '-DCOMPILER_RT_BUILD_MEMPROF=OFF', - '-DCOMPILER_RT_BUILD_ORC=OFF', - '-DCOMPILER_RT_BUILD_PROFILE=ON', - '-DCOMPILER_RT_BUILD_SANITIZERS=ON', - '-DCOMPILER_RT_BUILD_XRAY=OFF', - ] - if sys.platform == 'darwin': - compiler_rt_args.extend([ - '-DCOMPILER_RT_ENABLE_IOS=ON', - '-DCOMPILER_RT_ENABLE_WATCHOS=OFF', - '-DCOMPILER_RT_ENABLE_TVOS=OFF', - # armv7 is A5 and earlier, armv7s is A6+ (2012 and later, before 64-bit - # iPhones). armv7k is Apple Watch, which we don't need. - '-DDARWIN_ios_ARCHS=armv7;armv7s;arm64', - '-DDARWIN_iossim_ARCHS=i386;x86_64;arm64', - # We don't need 32-bit intel support for macOS, we only ship 64-bit. - '-DDARWIN_osx_ARCHS=arm64;x86_64', - ]) - - if sys.platform == 'win32': - # https://crbug.com/1293778 - compiler_rt_args.append('-DCOMPILER_RT_BUILD_BUILTINS=OFF') - else: - compiler_rt_args.append('-DCOMPILER_RT_BUILD_BUILTINS=ON') - - # LLVM uses C++11 starting in llvm 3.5. On Linux, this means libstdc++4.7+ is - # needed, on OS X it requires libc++. clang only automatically links to libc++ - # when targeting OS X 10.9+, so add stdlib=libc++ explicitly so clang can run - # on OS X versions as old as 10.7. - deployment_target = '' - - if sys.platform == 'darwin' and args.bootstrap: - # When building on 10.9, /usr/include usually doesn't exist, and while - # Xcode's clang automatically sets a sysroot, self-built clangs don't. - cflags = ['-isysroot', isysroot] - cxxflags = ['-stdlib=libc++'] + cflags - ldflags += ['-stdlib=libc++'] - deployment_target = '10.7' + deployment_target = '10.12' # If building at head, define a macro that plugins can use for #ifdefing # out code that builds at head, but not at CLANG_REVISION or vice versa. @@ -976,7 +952,7 @@ def main(): if cc is not None: base_cmake_args.append('-DCMAKE_C_COMPILER=' + cc) if cxx is not None: base_cmake_args.append('-DCMAKE_CXX_COMPILER=' + cxx) if lld is not None: base_cmake_args.append('-DCMAKE_LINKER=' + lld) - cmake_args = base_cmake_args + compiler_rt_args + [ + cmake_args = base_cmake_args + [ '-DCMAKE_C_FLAGS=' + ' '.join(cflags), '-DCMAKE_CXX_FLAGS=' + ' '.join(cxxflags), '-DCMAKE_EXE_LINKER_FLAGS=' + ' '.join(ldflags), @@ -994,13 +970,11 @@ def main(): if sys.platform == 'win32': cmake_args.append('-DLLVM_ENABLE_ZLIB=FORCE_ON') - if sys.platform == 'darwin': - cmake_args += ['-DCOMPILER_RT_ENABLE_IOS=ON', - '-DSANITIZER_MIN_OSX_VERSION=10.7'] - if args.build_mac_arm: - assert platform.machine() != 'arm64', 'build_mac_arm for cross build only' - cmake_args += ['-DCMAKE_OSX_ARCHITECTURES=arm64', - '-DCMAKE_SYSTEM_NAME=Darwin'] + if args.build_mac_arm: + assert platform.machine() != 'arm64', 'build_mac_arm for cross build only' + cmake_args += [ + '-DCMAKE_OSX_ARCHITECTURES=arm64', '-DCMAKE_SYSTEM_NAME=Darwin' + ] # The default LLVM_DEFAULT_TARGET_TRIPLE depends on the host machine. # Set it explicitly to make the build of clang more hermetic, and also to @@ -1023,89 +997,67 @@ def main(): elif sys.platform == 'win32': cmake_args.append('-DLLVM_DEFAULT_TARGET_TRIPLE=x86_64-pc-windows-msvc') - if os.path.exists(LLVM_BUILD_DIR): - RmTree(LLVM_BUILD_DIR) - EnsureDirExists(LLVM_BUILD_DIR) - os.chdir(LLVM_BUILD_DIR) - RunCommand(['cmake'] + cmake_args + [os.path.join(LLVM_DIR, 'llvm')], - msvc_arch='x64', env=deployment_env) - CopyLibstdcpp(args, LLVM_BUILD_DIR) - RunCommand(['ninja'], msvc_arch='x64') - - if chrome_tools: - # If any Chromium tools were built, install those now. - RunCommand(['ninja', 'cr-install'], msvc_arch='x64') - - if not args.build_mac_arm: - VerifyVersionOfBuiltClangMatchesVERSION() - VerifyZlibSupport() - - if sys.platform == 'win32': - rt_platform = 'windows' + # List of (triple, list of CMake vars without '-D'). + runtimes_triples_args = [] + + if sys.platform.startswith('linux'): + runtimes_triples_args.append( + ('i386-unknown-linux-gnu', + compiler_rt_cmake_flags(sanitizers=True, profile=True) + [ + 'CMAKE_SYSROOT=%s' % sysroot_i386, + ])) + runtimes_triples_args.append( + ('x86_64-unknown-linux-gnu', + compiler_rt_cmake_flags(sanitizers=True, profile=True) + [ + 'CMAKE_SYSROOT=%s' % sysroot_amd64, + ])) + runtimes_triples_args.append( + # Using "armv7a-unknown-linux-gnueabhihf" confuses the compiler-rt + # builtins build, since compiler-rt/cmake/builtin-config-ix.cmake + # doesn't include "armv7a" in its `ARM32` list. + # TODO(thakis): It seems to work for everything else though, see try + # results on + # https://chromium-review.googlesource.com/c/chromium/src/+/3702739/4 + # Maybe it should work for builtins too? + ('armv7-unknown-linux-gnueabihf', + compiler_rt_cmake_flags(sanitizers=True, profile=True) + [ + 'CMAKE_SYSROOT=%s' % sysroot_arm, + ])) + runtimes_triples_args.append( + ('aarch64-unknown-linux-gnu', + compiler_rt_cmake_flags(sanitizers=True, profile=True) + [ + 'CMAKE_SYSROOT=%s' % sysroot_arm64, + ])) + elif sys.platform == 'win32': + runtimes_triples_args.append( + ('i386-pc-windows-msvc', + compiler_rt_cmake_flags(sanitizers=False, profile=True) + [ + 'LLVM_ENABLE_PER_TARGET_RUNTIME_DIR=OFF', + ])) + runtimes_triples_args.append( + ('x86_64-pc-windows-msvc', + compiler_rt_cmake_flags(sanitizers=True, profile=True) + [ + 'LLVM_ENABLE_PER_TARGET_RUNTIME_DIR=OFF', + ])) elif sys.platform == 'darwin': - rt_platform = 'darwin' - else: - assert sys.platform.startswith('linux') - rt_platform = 'linux' - rt_lib_dst_dir = os.path.join(LLVM_BUILD_DIR, 'lib', 'clang', RELEASE_VERSION, - 'lib', rt_platform) - # Make sure the directory exists; this will not be implicilty created if - # built with per-target runtime directories. - if not os.path.exists(rt_lib_dst_dir): - os.makedirs(rt_lib_dst_dir) - - # Do an out-of-tree build of compiler-rt for 32-bit Win clang_rt.profile.lib. - if sys.platform == 'win32': - compiler_rt_build_dir = os.path.join(LLVM_BUILD_DIR, 'compiler-rt') - if os.path.isdir(compiler_rt_build_dir): - RmTree(compiler_rt_build_dir) - os.makedirs(compiler_rt_build_dir) - os.chdir(compiler_rt_build_dir) - if 'clang-cl' in cc: - # clang-cl produces 64-bit binaries by default. - cflags += ['-m32'] - cxxflags += ['-m32'] - - compiler_rt_args = base_cmake_args + [ - '-DCMAKE_C_FLAGS=' + ' '.join(cflags), - '-DCMAKE_CXX_FLAGS=' + ' '.join(cxxflags), - '-DCMAKE_EXE_LINKER_FLAGS=' + ' '.join(ldflags), - '-DCMAKE_SHARED_LINKER_FLAGS=' + ' '.join(ldflags), - '-DCMAKE_MODULE_LINKER_FLAGS=' + ' '.join(ldflags), - '-DCOMPILER_RT_BUILD_BUILTINS=OFF', - '-DCOMPILER_RT_BUILD_CRT=OFF', - '-DCOMPILER_RT_BUILD_LIBFUZZER=OFF', - '-DCOMPILER_RT_BUILD_MEMPROF=OFF', - '-DCOMPILER_RT_BUILD_ORC=OFF', - '-DCOMPILER_RT_BUILD_PROFILE=ON', - '-DCOMPILER_RT_BUILD_SANITIZERS=OFF', - '-DCOMPILER_RT_BUILD_XRAY=OFF', - - # The libxml2 we built above is 64-bit. Since it's only needed by - # lld-link and not compiler-rt, just turn it off down here. - '-DLLVM_ENABLE_LIBXML2=OFF', - ] - RunCommand(['cmake'] + compiler_rt_args + - [os.path.join(LLVM_DIR, 'llvm')], - msvc_arch='x86', env=deployment_env) - RunCommand(['ninja', 'compiler-rt'], msvc_arch='x86') - - # Copy select output to the main tree. - rt_lib_src_dir = os.path.join(compiler_rt_build_dir, 'lib', 'clang', - RELEASE_VERSION, 'lib', rt_platform) - # Static and dynamic libraries: - CopyDirectoryContents(rt_lib_src_dir, rt_lib_dst_dir) + compiler_rt_args = [ + 'SANITIZER_MIN_OSX_VERSION=' + deployment_target, + 'COMPILER_RT_ENABLE_MACCATALYST=ON', + 'COMPILER_RT_ENABLE_IOS=ON', + 'COMPILER_RT_ENABLE_WATCHOS=OFF', + 'COMPILER_RT_ENABLE_TVOS=OFF', + 'DARWIN_ios_ARCHS=arm64', + 'DARWIN_iossim_ARCHS=arm64;x86_64', + 'DARWIN_osx_ARCHS=arm64;x86_64', + ] + compiler_rt_cmake_flags(sanitizers=True, profile=True) + # compiler-rt is built for all platforms/arches with a single + # configuration, we should only specify one target triple. 'default' is + # specially handled. + runtimes_triples_args.append(('default', compiler_rt_args)) if args.with_android: - # TODO(thakis): Now that the NDK uses clang, try to build all archs in - # one LLVM build instead of building 3 times. toolchain_dir = ANDROID_NDK_DIR + '/toolchains/llvm/prebuilt/linux-x86_64' for target_arch in ['aarch64', 'arm', 'i686', 'x86_64']: - # Build compiler-rt runtimes needed for Android in a separate build tree. - build_dir = os.path.join(LLVM_BUILD_DIR, 'android-' + target_arch) - if not os.path.exists(build_dir): - os.mkdir(os.path.join(build_dir)) - os.chdir(build_dir) target_triple = target_arch if target_arch == 'arm': target_triple = 'armv7' @@ -1114,16 +1066,8 @@ def main(): api_level = '21' target_triple += '-linux-android' + api_level cflags = [ - '--target=' + target_triple, '--sysroot=%s/sysroot' % toolchain_dir, - # pylint: disable=line-too-long - # android_ndk/toolchains/llvm/prebuilt/linux-x86_64/aarch64-linux-android/bin/ld - # depends on a newer version of libxml2.so than what's available on - # the bots. To make things work, use our just-built lld as linker. - # pylint: enable=line-too-long - '-fuse-ld=lld', - # We don't have an unwinder ready, and don't need it either. '--unwindlib=none', ] @@ -1132,73 +1076,26 @@ def main(): # Use PAC/BTI instructions for AArch64 cflags += [ '-mbranch-protection=standard' ] - android_args = base_cmake_args + [ - '-DCMAKE_C_COMPILER=' + os.path.join(LLVM_BUILD_DIR, 'bin/clang'), - '-DCMAKE_CXX_COMPILER=' + os.path.join(LLVM_BUILD_DIR, 'bin/clang++'), - '-DLLVM_CONFIG_PATH=' + os.path.join(LLVM_BUILD_DIR, 'bin/llvm-config'), - '-DCMAKE_C_FLAGS=' + ' '.join(cflags), - '-DCMAKE_CXX_FLAGS=' + ' '.join(cflags), - '-DCMAKE_ASM_FLAGS=' + ' '.join(cflags), - '-DCOMPILER_RT_BUILD_BUILTINS=ON', - '-DCOMPILER_RT_BUILD_CRT=OFF', - '-DCOMPILER_RT_BUILD_LIBFUZZER=OFF', - '-DCOMPILER_RT_BUILD_MEMPROF=OFF', - '-DCOMPILER_RT_BUILD_ORC=OFF', - '-DCOMPILER_RT_BUILD_PROFILE=OFF', - '-DCOMPILER_RT_BUILD_SANITIZERS=OFF', - '-DCOMPILER_RT_BUILD_XRAY=OFF', - '-DSANITIZER_CXX_ABI=libcxxabi', - '-DCMAKE_SHARED_LINKER_FLAGS=-Wl,-u__cxa_demangle', - '-DANDROID=1' - - # These are necessary because otherwise CMake tries to build an - # executable to test to see if the compiler is working, but in doing so, - # it links against the builtins.a that we're about to build. - '-DCMAKE_CXX_COMPILER_WORKS=ON', - '-DCMAKE_C_COMPILER_WORKS=ON', - '-DCMAKE_ASM_COMPILER_WORKS=ON', + android_args = compiler_rt_cmake_flags(sanitizers=True, profile=True) + [ + 'LLVM_ENABLE_RUNTIMES=compiler-rt', + # On Android, we want DWARF info for the builtins for unwinding. See + # crbug.com/1311807. + 'CMAKE_BUILD_TYPE=RelWithDebInfo', + 'CMAKE_C_FLAGS=' + ' '.join(cflags), + 'CMAKE_CXX_FLAGS=' + ' '.join(cflags), + 'CMAKE_ASM_FLAGS=' + ' '.join(cflags), + 'COMPILER_RT_USE_BUILTINS_LIBRARY=ON', + 'SANITIZER_CXX_ABI=libcxxabi', + 'CMAKE_SHARED_LINKER_FLAGS=-Wl,-u__cxa_demangle', + 'ANDROID=1', + 'LLVM_ENABLE_PER_TARGET_RUNTIME_DIR=OFF', + 'LLVM_INCLUDE_TESTS=OFF', + # This prevents static_asserts from firing in 32-bit builds. + # TODO: remove once we only support API >=24. + 'ANDROID_NATIVE_API_LEVEL=' + api_level, ] - # First build the builtins and copy to the main build tree. - RunCommand( - ['cmake'] + android_args + - # On Android, we want DWARF info for the builtins for - # unwinding. See crbug.com/1311807. - ['-DCMAKE_BUILD_TYPE=RelWithDebInfo'] + - [os.path.join(COMPILER_RT_DIR, 'lib', 'builtins')]) - builtins_a = 'lib/linux/libclang_rt.builtins-%s-android.a' % target_arch - RunCommand(['ninja', builtins_a]) - shutil.copy(builtins_a, rt_lib_dst_dir) - - # With the builtins in place, we can build the other runtimes. - build_dir_2 = build_dir + '-phase2' - if not os.path.exists(build_dir_2): - os.mkdir(os.path.join(build_dir_2)) - os.chdir(build_dir_2) - - android_args.extend([ - '-DCOMPILER_RT_BUILD_BUILTINS=OFF', - '-DCOMPILER_RT_USE_BUILTINS_LIBRARY=ON', - '-DCOMPILER_RT_BUILD_PROFILE=ON', - '-DCOMPILER_RT_BUILD_SANITIZERS=ON', - ]) - RunCommand(['cmake'] + android_args + [COMPILER_RT_DIR]) - - libs_want = [ - 'lib/linux/libclang_rt.asan-{0}-android.so', - 'lib/linux/libclang_rt.asan_static-{0}-android.a', - 'lib/linux/libclang_rt.ubsan_standalone-{0}-android.so', - 'lib/linux/libclang_rt.profile-{0}-android.a', - ] - # Only build HWASan for AArch64. - if target_arch == 'aarch64': - libs_want += ['lib/linux/libclang_rt.hwasan-{0}-android.so'] - libs_want = [lib.format(target_arch) for lib in libs_want] - RunCommand(['ninja'] + libs_want) - - # And copy them into the main build tree. - for p in libs_want: - shutil.copy(p, rt_lib_dst_dir) + runtimes_triples_args.append((target_triple, android_args)) if args.with_fuchsia: # Fuchsia links against libclang_rt.builtins-<arch>.a instead of libgcc.a. @@ -1206,112 +1103,68 @@ def main(): fuchsia_arch_name = {'aarch64': 'arm64', 'x86_64': 'x64'}[target_arch] toolchain_dir = os.path.join( FUCHSIA_SDK_DIR, 'arch', fuchsia_arch_name, 'sysroot') - # Build clang_rt runtime for Fuchsia in a separate build tree. - build_dir = os.path.join(LLVM_BUILD_DIR, 'fuchsia-' + target_arch) - if not os.path.exists(build_dir): - os.mkdir(os.path.join(build_dir)) - os.chdir(build_dir) - target_spec = target_arch + '-unknown-fuchsia' - if args.build_mac_arm: - # Just-built clang can't run (it's an arm binary on an intel host), so - # use the bootstrap compiler instead. - host_path = LLVM_BOOTSTRAP_INSTALL_DIR - else: - host_path = LLVM_BUILD_DIR - # TODO(thakis): Might have to pass -B here once sysroot contains - # binaries (e.g. gas for arm64?) - fuchsia_args = base_cmake_args + [ - '-DCMAKE_C_COMPILER=' + os.path.join(host_path, 'bin/clang'), - '-DCMAKE_CXX_COMPILER=' + os.path.join(host_path, 'bin/clang++'), - '-DCMAKE_LINKER=' + os.path.join(host_path, 'bin/clang'), - '-DCMAKE_AR=' + os.path.join(host_path, 'bin/llvm-ar'), - '-DLLVM_CONFIG_PATH=' + os.path.join(host_path, 'bin/llvm-config'), - '-DCMAKE_SYSTEM_NAME=Fuchsia', - '-DCMAKE_CXX_COMPILER_TARGET=' + target_spec, - '-DCMAKE_C_COMPILER_TARGET=' + target_spec, - '-DCMAKE_ASM_COMPILER_TARGET=' + target_spec, - '-DCOMPILER_RT_BUILD_BUILTINS=ON', - '-DCOMPILER_RT_BUILD_CRT=OFF', - '-DCOMPILER_RT_BUILD_LIBFUZZER=OFF', - '-DCOMPILER_RT_BUILD_MEMPROF=OFF', - '-DCOMPILER_RT_BUILD_ORC=OFF', - '-DCOMPILER_RT_BUILD_PROFILE=OFF', - '-DCOMPILER_RT_BUILD_SANITIZERS=OFF', - '-DCOMPILER_RT_BUILD_XRAY=OFF', - '-DCOMPILER_RT_DEFAULT_TARGET_ONLY=ON', - '-DCMAKE_SYSROOT=%s' % toolchain_dir, - # TODO(thakis|scottmg): Use PER_TARGET_RUNTIME_DIR for all platforms. - # https://crbug.com/882485. - '-DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=ON', - - # These are necessary because otherwise CMake tries to build an - # executable to test to see if the compiler is working, but in doing so, - # it links against the builtins.a that we're about to build. - '-DCMAKE_CXX_COMPILER_WORKS=ON', - '-DCMAKE_C_COMPILER_WORKS=ON', - '-DCMAKE_ASM_COMPILER_WORKS=ON', - ] - RunCommand(['cmake'] + - fuchsia_args + - [os.path.join(COMPILER_RT_DIR, 'lib', 'builtins')]) - builtins_a = 'libclang_rt.builtins.a' - RunCommand(['ninja', builtins_a]) - - # And copy it into the main build tree. - fuchsia_lib_dst_dir = os.path.join(LLVM_BUILD_DIR, 'lib', 'clang', - RELEASE_VERSION, 'lib', target_spec) - if not os.path.exists(fuchsia_lib_dst_dir): - os.makedirs(fuchsia_lib_dst_dir) - CopyFile(os.path.join(build_dir, 'lib', target_spec, builtins_a), - fuchsia_lib_dst_dir) - + target_triple = target_arch + '-unknown-fuchsia' # Build the Fuchsia profile and asan runtimes. This is done after the rt # builtins have been created because the CMake build runs link checks that # require that the builtins already exist to succeed. # TODO(thakis): Figure out why this doesn't build with the stage0 # compiler in arm cross builds. - if target_arch == 'x86_64' and not args.build_mac_arm: - fuchsia_args.extend([ - '-DCOMPILER_RT_BUILD_BUILTINS=OFF', - '-DCOMPILER_RT_BUILD_PROFILE=ON', - ]) - # Build the asan runtime only on non-Mac platforms. Macs are excluded - # because the asan install changes library RPATHs which CMake only - # supports on ELF platforms and MacOS uses Mach-O instead of ELF. - if sys.platform != 'darwin': - fuchsia_args.extend([ - '-DCOMPILER_RT_BUILD_SANITIZERS=ON', - '-DSANITIZER_NO_UNDEFINED_SYMBOLS=OFF', - ]) - build_phase2_dir = os.path.join(LLVM_BUILD_DIR, - 'fuchsia-phase2-' + target_arch) - if not os.path.exists(build_phase2_dir): - os.mkdir(os.path.join(build_phase2_dir)) - os.chdir(build_phase2_dir) - RunCommand(['cmake'] + - fuchsia_args + - [COMPILER_RT_DIR]) - profile_a = 'libclang_rt.profile.a' - asan_preinit_a = 'libclang_rt.asan-preinit.a' - asan_static_a = 'libclang_rt.asan_static.a' - asan_so = 'libclang_rt.asan.so' - ninja_command = ['ninja', profile_a] - if sys.platform != 'darwin': - ninja_command.append(asan_so) - ninja_command.append(asan_preinit_a) - ninja_command.append(asan_static_a) - RunCommand(ninja_command) - CopyFile(os.path.join(build_phase2_dir, 'lib', target_spec, profile_a), - fuchsia_lib_dst_dir) - if sys.platform != 'darwin': - CopyFile(os.path.join(build_phase2_dir, 'lib', target_spec, asan_so), - fuchsia_lib_dst_dir) - CopyFile( - os.path.join(build_phase2_dir, 'lib', target_spec, - asan_preinit_a), fuchsia_lib_dst_dir) - CopyFile( - os.path.join(build_phase2_dir, 'lib', target_spec, asan_static_a), - fuchsia_lib_dst_dir) + build_profile = target_arch == 'x86_64' and not args.build_mac_arm + # Build the asan runtime only on non-Mac platforms. Macs are excluded + # because the asan install changes library RPATHs which CMake only + # supports on ELF platforms and MacOS uses Mach-O instead of ELF. + build_sanitizers = build_profile and sys.platform != 'darwin' + # TODO(thakis): Might have to pass -B here once sysroot contains + # binaries (e.g. gas for arm64?) + fuchsia_args = compiler_rt_cmake_flags( + sanitizers=build_sanitizers, profile=build_profile + ) + [ + 'LLVM_ENABLE_RUNTIMES=compiler-rt', + 'CMAKE_SYSTEM_NAME=Fuchsia', + 'CMAKE_SYSROOT=%s' % toolchain_dir, + # TODO(thakis|scottmg): Use PER_TARGET_RUNTIME_DIR for all platforms. + # https://crbug.com/882485. + 'LLVM_ENABLE_PER_TARGET_RUNTIME_DIR=ON', + ] + if build_sanitizers: + fuchsia_args.append('SANITIZER_NO_UNDEFINED_SYMBOLS=OFF') + + runtimes_triples_args.append((target_triple, fuchsia_args)) + + # Convert FOO=BAR CMake flags per triple into + # -DBUILTINS_$triple_FOO=BAR/-DRUNTIMES_$triple_FOO=BAR and build up + # -DLLVM_BUILTIN_TARGETS/-DLLVM_RUNTIME_TARGETS. + all_triples = '' + for (triple, a) in runtimes_triples_args: + all_triples += ';' + triple + for arg in a: + assert not arg.startswith('-') + # 'default' is specially handled to pass through relevant CMake flags. + if triple == 'default': + cmake_args.append('-D' + arg) + else: + cmake_args.append('-DBUILTINS_' + triple + '_' + arg) + cmake_args.append('-DRUNTIMES_' + triple + '_' + arg) + cmake_args.append('-DLLVM_BUILTIN_TARGETS=' + all_triples) + cmake_args.append('-DLLVM_RUNTIME_TARGETS=' + all_triples) + + if os.path.exists(LLVM_BUILD_DIR): + RmTree(LLVM_BUILD_DIR) + EnsureDirExists(LLVM_BUILD_DIR) + os.chdir(LLVM_BUILD_DIR) + RunCommand(['cmake'] + cmake_args + [os.path.join(LLVM_DIR, 'llvm')], + msvc_arch='x64', + env=deployment_env) + CopyLibstdcpp(args, LLVM_BUILD_DIR) + RunCommand(['ninja'], msvc_arch='x64') + + if chrome_tools: + # If any Chromium tools were built, install those now. + RunCommand(['ninja', 'cr-install'], msvc_arch='x64') + + if not args.build_mac_arm: + VerifyVersionOfBuiltClangMatchesVERSION() + VerifyZlibSupport() # Run tests. if (not args.build_mac_arm and @@ -1319,11 +1172,16 @@ def main(): RunCommand(['ninja', '-C', LLVM_BUILD_DIR, 'cr-check-all'], msvc_arch='x64') if not args.build_mac_arm and args.run_tests: - test_targets = [ 'check-all' ] - if sys.platform == 'darwin': - # TODO(thakis): Run check-all on Darwin too, https://crbug.com/959361 - test_targets = [ 'check-llvm', 'check-clang', 'check-lld' ] - RunCommand(['ninja', '-C', LLVM_BUILD_DIR] + test_targets, msvc_arch='x64') + env = None + if sys.platform.startswith('linux'): + env = os.environ.copy() + # See SANITIZER_OVERRIDE_INTERCEPTORS above: We disable crypt_r() + # interception, so its tests can't pass. + env['LIT_FILTER_OUT'] = ('^SanitizerCommon-(a|l|m|ub|t)san-x86_64-Linux' + + ' :: Linux/crypt_r.cpp$') + RunCommand(['ninja', '-C', LLVM_BUILD_DIR, 'check-all'], + env=env, + msvc_arch='x64') WriteStampFile(PACKAGE_VERSION, STAMP_FILE) WriteStampFile(PACKAGE_VERSION, FORCE_HEAD_REVISION_FILE) diff --git a/chromium/tools/clang/scripts/goma_ld.py b/chromium/tools/clang/scripts/goma_ld.py index 21a7dd2286c..123da699881 100755 --- a/chromium/tools/clang/scripts/goma_ld.py +++ b/chromium/tools/clang/scripts/goma_ld.py @@ -1,4 +1,4 @@ -#! /usr/bin/env python +#! /usr/bin/env python3 # Copyright (c) 2020 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. @@ -9,17 +9,12 @@ # E.g. original: clang++ -o foo foo.o # Becomes: goma-ld clang++ -o foo foo.o -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function -from __future__ import unicode_literals - -import goma_link - import os import re import sys +import goma_link + class GomaLinkUnix(goma_link.GomaLinkBase): # Target-platform-specific constants. diff --git a/chromium/tools/clang/scripts/goma_link.py b/chromium/tools/clang/scripts/goma_link.py index a101dc93bfd..5d7339fbf91 100755 --- a/chromium/tools/clang/scripts/goma_link.py +++ b/chromium/tools/clang/scripts/goma_link.py @@ -1,4 +1,4 @@ -#! /usr/bin/env python +#! /usr/bin/env python3 # Copyright (c) 2020 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. @@ -9,11 +9,6 @@ # E.g. original: lld-link -out:foo foo.obj # Becomes: goma_link.py lld-link -out:foo foo.obj -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function -from __future__ import unicode_literals - import argparse import errno import io @@ -26,14 +21,6 @@ from collections import namedtuple from pipes import quote as shquote from tempfile import NamedTemporaryFile -# Python 2 has int and long, and we want to use long. Python 3 only has int, -# which is like long in Python 2. So we check if long is defined, and, if not, -# define it to be the same as int. -try: - long -except NameError: - long = int - # Type returned by analyze_args. AnalyzeArgsResult = namedtuple('AnalyzeArgsResult', [ 'output', 'linker', 'compiler', 'splitfile', 'index_inputs', 'index_params', @@ -124,13 +111,13 @@ def names_in_archive(path): f.seek(32, io.SEEK_CUR) m = re.match(b'/([0-9]+)', file_id) if long_names and m: - name_pos = long(m.group(1)) + name_pos = int(m.group(1)) name_end = long_names.find(b'/\n', name_pos) name = long_names[name_pos:name_end] else: name = file_id try: - size = long(f.read(10)) + size = int(f.read(10)) except: sys.stderr.write('While parsing %r, pos %r\n' % (path, f.tell())) raise diff --git a/chromium/tools/clang/scripts/package.py b/chromium/tools/clang/scripts/package.py index 32a79a5e3e5..bd8782125c3 100755 --- a/chromium/tools/clang/scripts/package.py +++ b/chromium/tools/clang/scripts/package.py @@ -4,13 +4,12 @@ # found in the LICENSE file. """This script will check out llvm and clang, and then package the results up -to a tgz file.""" - -from __future__ import print_function +to a number of tarballs.""" import argparse import fnmatch import itertools +import lzma import multiprocessing.dummy import os import platform @@ -101,16 +100,24 @@ def PackageInArchive(directory_path, archive_path): if not os.path.islink(file_path): subprocess.call(['strip', file_path]) - with tarfile.open(archive_path, 'w:gz') as tar: - for f in os.listdir(directory_path): - tar.add(os.path.join(directory_path, f), - arcname=f, filter=PrintTarProgress) + with tarfile.open(archive_path + '.tar.xz', + 'w:xz', + preset=9 | lzma.PRESET_EXTREME) as tar_xz: + with tarfile.open(archive_path + '.tgz', 'w:gz') as tar_gz: + for f in sorted(os.listdir(directory_path)): + tar_xz.add(os.path.join(directory_path, f), + arcname=f, + filter=PrintTarProgress) + # TODO(crbug.com/1261812) Stop making gzip'ed archives once the + # goma/reclient push processes are updated to consume the .xz files + # instead. + tar_gz.add(os.path.join(directory_path, f), arcname=f) def MaybeUpload(do_upload, filename, gcs_platform, extra_gsutil_args=[]): gsutil_args = ['cp'] + extra_gsutil_args + [ - '-a', 'public-read', filename, - 'gs://chromium-browser-clang-staging/%s/%s' % (gcs_platform, filename) + '-n', '-a', 'public-read', filename, + 'gs://chromium-browser-clang-staging/%s/' % (gcs_platform) ] if do_upload: print('Uploading %s to Google Cloud Storage...' % filename) @@ -256,20 +263,23 @@ def main(): ]) else: want.extend([ - 'bin/clang', + 'bin/clang', + + # Add LLD. + 'bin/lld', - # Add LLD. - 'bin/lld', + # Add llvm-ar for LTO. + 'bin/llvm-ar', - # Add llvm-ar for LTO. - 'bin/llvm-ar', + # llvm-ml for Windows cross builds. + 'bin/llvm-ml', - # Include libclang_rt.builtins.a for Fuchsia targets. - 'lib/clang/$V/lib/aarch64-unknown-fuchsia/libclang_rt.builtins.a', - 'lib/clang/$V/lib/x86_64-unknown-fuchsia/libclang_rt.builtins.a', + # Include libclang_rt.builtins.a for Fuchsia targets. + 'lib/clang/$V/lib/aarch64-unknown-fuchsia/libclang_rt.builtins.a', + 'lib/clang/$V/lib/x86_64-unknown-fuchsia/libclang_rt.builtins.a', - # Add llvm-readobj (symlinked from llvm-readelf) for extracting SONAMEs. - 'bin/llvm-readobj', + # Add llvm-readobj (symlinked from llvm-readelf) for extracting SONAMEs. + 'bin/llvm-readobj', ]) if not args.build_mac_arm: # TODO(thakis): Figure out why this doesn't build in --build-mac-arm @@ -343,9 +353,15 @@ def main(): 'lib/clang/$V/lib/linux/libclang_rt.builtins-x86_64-android.a', # Builtins for Lacros (and potentially Linux, but not used there atm). + 'lib/clang/$V/lib/aarch64-unknown-linux-gnu/libclang_rt.builtins.a', + 'lib/clang/$V/lib/armv7-unknown-linux-gnueabihf/libclang_rt.builtins.a', 'lib/clang/$V/lib/x86_64-unknown-linux-gnu/libclang_rt.builtins.a', # crtstart/crtend for Linux and Lacros. + 'lib/clang/$V/lib/aarch64-unknown-linux-gnu/clang_rt.crtbegin.o', + 'lib/clang/$V/lib/aarch64-unknown-linux-gnu/clang_rt.crtend.o', + 'lib/clang/$V/lib/armv7-unknown-linux-gnueabihf/clang_rt.crtbegin.o', + 'lib/clang/$V/lib/armv7-unknown-linux-gnueabihf/clang_rt.crtend.o', 'lib/clang/$V/lib/x86_64-unknown-linux-gnu/clang_rt.crtbegin.o', 'lib/clang/$V/lib/x86_64-unknown-linux-gnu/clang_rt.crtend.o', @@ -361,9 +377,11 @@ def main(): 'lib/clang/$V/lib/x86_64-unknown-linux-gnu/libclang_rt.msan_cxx.a.syms', # Profile runtime (used by profiler and code coverage). + 'lib/clang/$V/lib/aarch64-unknown-linux-gnu/libclang_rt.profile.a', + 'lib/clang/$V/lib/armv7-unknown-linux-gnueabihf/libclang_rt.profile.a', 'lib/clang/$V/lib/i386-unknown-linux-gnu/libclang_rt.profile.a', - 'lib/clang/$V/lib/linux/libclang_rt.profile-i686-android.a', 'lib/clang/$V/lib/x86_64-unknown-linux-gnu/libclang_rt.profile.a', + 'lib/clang/$V/lib/linux/libclang_rt.profile-i686-android.a', 'lib/clang/$V/lib/linux/libclang_rt.profile-aarch64-android.a', 'lib/clang/$V/lib/linux/libclang_rt.profile-arm-android.a', @@ -516,19 +534,16 @@ def main(): # Make `--target=*-cros-linux-gnu` work with # LLVM_ENABLE_PER_TARGET_RUNTIME_DIR=ON. - os.symlink( - 'x86_64-unknown-linux-gnu', - os.path.join(pdir, 'lib', 'clang', RELEASE_VERSION, 'lib', - 'x86_64-cros-linux-gnu')) - - # Copy libc++ headers. - if sys.platform == 'darwin': - shutil.copytree(os.path.join(LLVM_BOOTSTRAP_INSTALL_DIR, 'include', 'c++'), - os.path.join(pdir, 'include', 'c++')) + for arch, abi in [('armv7', 'gnueabihf'), ('aarch64', 'gnu'), + ('x86_64', 'gnu')]: + old = '%s-unknown-linux-%s' % (arch, abi) + new = old.replace('unknown', 'cros').replace('armv7', 'armv7a') + os.symlink( + old, os.path.join(pdir, 'lib', 'clang', RELEASE_VERSION, 'lib', new)) # Create main archive. - PackageInArchive(pdir, pdir + '.tgz') - MaybeUpload(args.upload, pdir + '.tgz', gcs_platform) + PackageInArchive(pdir, pdir) + MaybeUpload(args.upload, pdir + '.t*z', gcs_platform) # Upload build log next to it. os.rename('buildlog.txt', pdir + '-buildlog.txt') @@ -545,8 +560,8 @@ def main(): for filename in ['llvm-cov', 'llvm-profdata']: shutil.copy(os.path.join(LLVM_RELEASE_DIR, 'bin', filename + exe_ext), os.path.join(code_coverage_dir, 'bin')) - PackageInArchive(code_coverage_dir, code_coverage_dir + '.tgz') - MaybeUpload(args.upload, code_coverage_dir + '.tgz', gcs_platform) + PackageInArchive(code_coverage_dir, code_coverage_dir) + MaybeUpload(args.upload, code_coverage_dir + '.t*z', gcs_platform) # Zip up llvm-objdump and related tools for sanitizer coverage and Supersize. objdumpdir = 'llvmobjdump-' + stamp @@ -565,8 +580,8 @@ def main(): f.write('\n') if sys.platform != 'win32': os.symlink('llvm-objdump', os.path.join(objdumpdir, 'bin', 'llvm-otool')) - PackageInArchive(objdumpdir, objdumpdir + '.tgz') - MaybeUpload(args.upload, objdumpdir + '.tgz', gcs_platform) + PackageInArchive(objdumpdir, objdumpdir) + MaybeUpload(args.upload, objdumpdir + '.t*z', gcs_platform) # Zip up clang-tidy for users who opt into it, and Tricium. clang_tidy_dir = 'clang-tidy-' + stamp @@ -574,8 +589,8 @@ def main(): os.makedirs(os.path.join(clang_tidy_dir, 'bin')) shutil.copy(os.path.join(LLVM_RELEASE_DIR, 'bin', 'clang-tidy' + exe_ext), os.path.join(clang_tidy_dir, 'bin')) - PackageInArchive(clang_tidy_dir, clang_tidy_dir + '.tgz') - MaybeUpload(args.upload, clang_tidy_dir + '.tgz', gcs_platform) + PackageInArchive(clang_tidy_dir, clang_tidy_dir) + MaybeUpload(args.upload, clang_tidy_dir + '.t*z', gcs_platform) # Zip up clang-format so we can update it (separately from the clang roll). clang_format_dir = 'clang-format-' + stamp @@ -583,8 +598,8 @@ def main(): os.makedirs(os.path.join(clang_format_dir, 'bin')) shutil.copy(os.path.join(LLVM_RELEASE_DIR, 'bin', 'clang-format' + exe_ext), os.path.join(clang_format_dir, 'bin')) - PackageInArchive(clang_format_dir, clang_format_dir + '.tgz') - MaybeUpload(args.upload, clang_format_dir + '.tgz', gcs_platform) + PackageInArchive(clang_format_dir, clang_format_dir) + MaybeUpload(args.upload, clang_format_dir + '.t*z', gcs_platform) # Zip up clang-libs for users who opt into it. We want Clang and LLVM headers # and libs, as well as a couple binaries. The LLVM parts are needed by the @@ -635,8 +650,8 @@ def main(): if fnmatch.fnmatch(lib_path, lib_want): shutil.copy(os.path.join(LLVM_BOOTSTRAP_DIR, 'lib', lib_path), os.path.join(clang_libs_dir, 'lib')) - PackageInArchive(clang_libs_dir, clang_libs_dir + '.tgz') - MaybeUpload(args.upload, clang_libs_dir + '.tgz', gcs_platform) + PackageInArchive(clang_libs_dir, clang_libs_dir) + MaybeUpload(args.upload, clang_libs_dir + '.t*z', gcs_platform) if sys.platform == 'darwin': # dsymutil isn't part of the main zip, and it gets periodically @@ -647,8 +662,8 @@ def main(): os.makedirs(os.path.join(dsymdir, 'bin')) shutil.copy(os.path.join(LLVM_RELEASE_DIR, 'bin', 'dsymutil'), os.path.join(dsymdir, 'bin')) - PackageInArchive(dsymdir, dsymdir + '.tgz') - MaybeUpload(args.upload, dsymdir + '.tgz', gcs_platform) + PackageInArchive(dsymdir, dsymdir) + MaybeUpload(args.upload, dsymdir + '.t*z', gcs_platform) # Zip up the translation_unit tool. translation_unit_dir = 'translation_unit-' + stamp @@ -657,8 +672,8 @@ def main(): shutil.copy(os.path.join(LLVM_RELEASE_DIR, 'bin', 'translation_unit' + exe_ext), os.path.join(translation_unit_dir, 'bin')) - PackageInArchive(translation_unit_dir, translation_unit_dir + '.tgz') - MaybeUpload(args.upload, translation_unit_dir + '.tgz', gcs_platform) + PackageInArchive(translation_unit_dir, translation_unit_dir) + MaybeUpload(args.upload, translation_unit_dir + '.t*z', gcs_platform) # Zip up the libclang binaries. libclang_dir = 'libclang-' + stamp @@ -672,8 +687,8 @@ def main(): shutil.copy(os.path.join(LLVM_DIR, 'clang', 'bindings', 'python', 'clang', filename), os.path.join(libclang_dir, 'bindings', 'python', 'clang')) - PackageInArchive(libclang_dir, libclang_dir + '.tgz') - MaybeUpload(args.upload, libclang_dir + '.tgz', gcs_platform) + PackageInArchive(libclang_dir, libclang_dir) + MaybeUpload(args.upload, libclang_dir + '.t*z', gcs_platform) if sys.platform == 'win32' and args.upload: binaries = [f for f in want if f.endswith('.exe') or f.endswith('.dll')] diff --git a/chromium/tools/clang/scripts/process_crashreports.py b/chromium/tools/clang/scripts/process_crashreports.py index d6d7cd9104f..020530460a1 100755 --- a/chromium/tools/clang/scripts/process_crashreports.py +++ b/chromium/tools/clang/scripts/process_crashreports.py @@ -66,6 +66,10 @@ def ProcessCrashreport(base, source): subprocess.check_call([sys.executable, GSUTIL, '-q', 'cp', tmp_name, dest]) print('done') print(' %s' % dest) + except subprocess.CalledProcessError as e: + print('upload failed; if it was due to missing permissions, try running') + print('download_from_google_storage --config') + print('and then try again') finally: if tmp_name: os.remove(tmp_name) diff --git a/chromium/tools/clang/scripts/sanitizers/sanitizer_intercept_overriders.h b/chromium/tools/clang/scripts/sanitizers/sanitizer_intercept_overriders.h new file mode 100644 index 00000000000..bfd0f6b5b98 --- /dev/null +++ b/chromium/tools/clang/scripts/sanitizers/sanitizer_intercept_overriders.h @@ -0,0 +1,5 @@ +// Workaround for https://crbug.com/1302636#c49, #c55 +#ifdef SANITIZER_INTERCEPT_CRYPT_R +#undef SANITIZER_INTERCEPT_CRYPT_R +#define SANITIZER_INTERCEPT_CRYPT_R 0 +#endif
\ No newline at end of file diff --git a/chromium/tools/clang/scripts/update.py b/chromium/tools/clang/scripts/update.py index a6af0980390..c8703580d32 100755 --- a/chromium/tools/clang/scripts/update.py +++ b/chromium/tools/clang/scripts/update.py @@ -35,11 +35,11 @@ import zlib # https://chromium.googlesource.com/chromium/src/+/main/docs/updating_clang.md # Reverting problematic clang rolls is safe, though. # This is the output of `git describe` and is usable as a commit-ish. -CLANG_REVISION = 'llvmorg-15-init-11722-g3f3a235a' -CLANG_SUB_REVISION = 2 +CLANG_REVISION = 'llvmorg-16-init-907-g8b740747' +CLANG_SUB_REVISION = 1 PACKAGE_VERSION = '%s-%s' % (CLANG_REVISION, CLANG_SUB_REVISION) -RELEASE_VERSION = '15.0.0' +RELEASE_VERSION = '16.0.0' CDS_URL = os.environ.get('CDS_CLANG_BUCKET_OVERRIDE', 'https://commondatastorage.googleapis.com/chromium-browser-clang') @@ -140,6 +140,8 @@ def DownloadUrl(url, output_file): e, urllib.error.HTTPError) and e.code == 404: raise e num_retries -= 1 + output_file.seek(0) + output_file.truncate() print('Retrying in %d s ...' % retry_wait_s) sys.stdout.flush() time.sleep(retry_wait_s) @@ -181,8 +183,11 @@ def GetPlatformUrlPrefix(host_os): return CDS_URL + '/' + _HOST_OS_URL_MAP[host_os] + '/' -def DownloadAndUnpackPackage(package_file, output_dir, host_os): - cds_file = "%s-%s.tgz" % (package_file, PACKAGE_VERSION) +def DownloadAndUnpackPackage(package_file, + output_dir, + host_os, + version=PACKAGE_VERSION): + cds_file = "%s-%s.tar.xz" % (package_file, version) cds_full_url = GetPlatformUrlPrefix(host_os) + cds_file try: DownloadAndUnpack(cds_full_url, output_dir) @@ -194,7 +199,7 @@ def DownloadAndUnpackPackage(package_file, output_dir, host_os): def DownloadAndUnpackClangMacRuntime(output_dir): - cds_file = "clang-%s.tgz" % PACKAGE_VERSION + cds_file = "clang-%s.tar.xz" % PACKAGE_VERSION # We run this only for the runtime libraries, and 'mac' and 'mac-arm64' both # have the same (universal) runtime libraries. It doesn't matter which one # we download here. @@ -213,7 +218,7 @@ def DownloadAndUnpackClangMacRuntime(output_dir): # TODO(hans): Create a clang-win-runtime package instead. def DownloadAndUnpackClangWinRuntime(output_dir): - cds_file = "clang-%s.tgz" % PACKAGE_VERSION + cds_file = "clang-%s.tar.xz" % PACKAGE_VERSION cds_full_url = GetPlatformUrlPrefix('win') + cds_file path_prefixes = [ 'lib/clang/' + RELEASE_VERSION + '/lib/windows', 'bin/llvm-symbolizer.exe' diff --git a/chromium/tools/clang/scripts/upload_revision.py b/chromium/tools/clang/scripts/upload_revision.py index 7386e5ac5ec..911ee36d0ba 100755 --- a/chromium/tools/clang/scripts/upload_revision.py +++ b/chromium/tools/clang/scripts/upload_revision.py @@ -39,6 +39,7 @@ Cq-Include-Trybots: chromium/try:linux_chromium_cfi_rel_ng Cq-Include-Trybots: chromium/try:linux_chromium_chromeos_msan_rel_ng Cq-Include-Trybots: chromium/try:linux_chromium_msan_rel_ng Cq-Include-Trybots: chromium/try:mac11-arm64-rel,mac_chromium_asan_rel_ng +Cq-Include-Trybots: chromium/try:ios-catalyst Cq-Include-Trybots: chromium/try:win-asan,win7-rel Cq-Include-Trybots: chromium/try:android-official,fuchsia-official Cq-Include-Trybots: chromium/try:mac-official,linux-official |