[tor-commits] [tor-browser-build/master] Bug 40097: Update toolchain for Fenix 82

sysrqb at torproject.org sysrqb at torproject.org
Mon Oct 12 02:58:59 UTC 2020


commit 65e79d4262efb2d80a64e3826ddf4362970f6b0f
Author: Georg Koppen <gk at torproject.org>
Date:   Mon Oct 5 10:18:34 2020 +0000

    Bug 40097: Update toolchain for Fenix 82
    
    As Fenix 82 uses clang 11.0.0-rc3 it is easier if we switch to using
    the llvm-project repository directly. This fixes the mobile part of
    bug 40048.
    
    We need to use our compiled binutils version, too, as the one that comes
    with Debian Buster (2.31.1) is breaking the build. We hit
    https://bugs.llvm.org/show_bug.cgi?id=42994 which is essentially
    an ld bug (https://sourceware.org/bugzilla/show_bug.cgi?id=24458). That
    one is fixed on the 2.31 branch and onwards but never made it into a
    2.31.x release.
---
 projects/fenix-clang/43909.patch | 252 ---------------------------------------
 projects/fenix-clang/build       |  19 +--
 projects/fenix-clang/config      |   7 +-
 projects/llvm-project/build      |   8 ++
 projects/llvm-project/config     |   5 +
 5 files changed, 26 insertions(+), 265 deletions(-)

diff --git a/projects/fenix-clang/43909.patch b/projects/fenix-clang/43909.patch
deleted file mode 100644
index 78d2a75..0000000
--- a/projects/fenix-clang/43909.patch
+++ /dev/null
@@ -1,252 +0,0 @@
-From c95310f2d4fd3c88241c3b5d6dbf6251d34a3256 Mon Sep 17 00:00:00 2001
-From: Nikita Popov <nikita.ppv at gmail.com>
-Date: Sat, 16 Nov 2019 16:22:18 +0100
-Subject: [PATCH] Restructure caching
-
-Variant on D70103. The caching is switched to always use a BB to
-cache entry map, which then contains per-value caches. A separate
-set contains value handles with a deletion callback. This allows us
-to properly invalidate overdefined values.
-
-A possible alternative would be to always cache by value first and
-have per-BB maps/sets in the each cache entry. In that case we could
-use a ValueMap and would avoid the separate value handle set. I went
-with the BB indexing at the top level to make it easier to integrate
-D69914, but possibly that's not the right choice.
-
-Differential Revision: https://reviews.llvm.org/D70376
-
-diff --git a/llvm/lib/Analysis/LazyValueInfo.cpp b/llvm/lib/Analysis/LazyValueInfo.cpp
-index 110c085d3f3..aa6862cb588 100644
---- a/llvm/lib/Analysis/LazyValueInfo.cpp
-+++ b/llvm/lib/Analysis/LazyValueInfo.cpp
-@@ -133,12 +133,9 @@ namespace {
-   /// A callback value handle updates the cache when values are erased.
-   class LazyValueInfoCache;
-   struct LVIValueHandle final : public CallbackVH {
--    // Needs to access getValPtr(), which is protected.
--    friend struct DenseMapInfo<LVIValueHandle>;
--
-     LazyValueInfoCache *Parent;
- 
--    LVIValueHandle(Value *V, LazyValueInfoCache *P)
-+    LVIValueHandle(Value *V, LazyValueInfoCache *P = nullptr)
-       : CallbackVH(V), Parent(P) { }
- 
-     void deleted() override;
-@@ -152,89 +149,63 @@ namespace {
-   /// This is the cache kept by LazyValueInfo which
-   /// maintains information about queries across the clients' queries.
-   class LazyValueInfoCache {
--    /// This is all of the cached block information for exactly one Value*.
--    /// The entries are sorted by the BasicBlock* of the
--    /// entries, allowing us to do a lookup with a binary search.
--    /// Over-defined lattice values are recorded in OverDefinedCache to reduce
--    /// memory overhead.
--    struct ValueCacheEntryTy {
--      ValueCacheEntryTy(Value *V, LazyValueInfoCache *P) : Handle(V, P) {}
--      LVIValueHandle Handle;
--      SmallDenseMap<PoisoningVH<BasicBlock>, ValueLatticeElement, 4> BlockVals;
-+    /// This is all of the cached information for one basic block. It contains
-+    /// the per-value lattice elements, as well as a separate set for
-+    /// overdefined values to reduce memory usage.
-+    struct BlockCacheEntryTy {
-+      SmallDenseMap<AssertingVH<Value>, ValueLatticeElement, 4> LatticeElements;
-+      SmallDenseSet<AssertingVH<Value>, 4> OverDefined;
-     };
- 
--    /// This tracks, on a per-block basis, the set of values that are
--    /// over-defined at the end of that block.
--    typedef DenseMap<PoisoningVH<BasicBlock>, SmallPtrSet<Value *, 4>>
--        OverDefinedCacheTy;
--    /// Keep track of all blocks that we have ever seen, so we
--    /// don't spend time removing unused blocks from our caches.
--    DenseSet<PoisoningVH<BasicBlock> > SeenBlocks;
--
--    /// This is all of the cached information for all values,
--    /// mapped from Value* to key information.
--    DenseMap<Value *, std::unique_ptr<ValueCacheEntryTy>> ValueCache;
--    OverDefinedCacheTy OverDefinedCache;
--
-+    /// Cached information per basic block.
-+    DenseMap<PoisoningVH<BasicBlock>, BlockCacheEntryTy> BlockCache;
-+    /// Set of value handles used to erase values from the cache on deletion.
-+    DenseSet<LVIValueHandle, DenseMapInfo<Value *>> ValueHandles;
- 
-   public:
-     void insertResult(Value *Val, BasicBlock *BB,
-                       const ValueLatticeElement &Result) {
--      SeenBlocks.insert(BB);
--
-+      auto &CacheEntry = BlockCache.try_emplace(BB).first->second;
-       // Insert over-defined values into their own cache to reduce memory
-       // overhead.
-       if (Result.isOverdefined())
--        OverDefinedCache[BB].insert(Val);
--      else {
--        auto It = ValueCache.find_as(Val);
--        if (It == ValueCache.end()) {
--          ValueCache[Val] = make_unique<ValueCacheEntryTy>(Val, this);
--          It = ValueCache.find_as(Val);
--          assert(It != ValueCache.end() && "Val was just added to the map!");
--        }
--        It->second->BlockVals[BB] = Result;
--      }
--    }
--
--    bool isOverdefined(Value *V, BasicBlock *BB) const {
--      auto ODI = OverDefinedCache.find(BB);
--
--      if (ODI == OverDefinedCache.end())
--        return false;
-+        CacheEntry.OverDefined.insert(Val);
-+      else
-+        CacheEntry.LatticeElements.insert({ Val, Result });
- 
--      return ODI->second.count(V);
-+      auto HandleIt = ValueHandles.find_as(Val);
-+      if (HandleIt == ValueHandles.end())
-+        ValueHandles.insert({ Val, this });
-     }
- 
-     bool hasCachedValueInfo(Value *V, BasicBlock *BB) const {
--      if (isOverdefined(V, BB))
--        return true;
--
--      auto I = ValueCache.find_as(V);
--      if (I == ValueCache.end())
-+      auto It = BlockCache.find(BB);
-+      if (It == BlockCache.end())
-         return false;
- 
--      return I->second->BlockVals.count(BB);
-+      return It->second.OverDefined.count(V) ||
-+             It->second.LatticeElements.count(V);
-     }
- 
-     ValueLatticeElement getCachedValueInfo(Value *V, BasicBlock *BB) const {
--      if (isOverdefined(V, BB))
-+      auto It = BlockCache.find(BB);
-+      if (It == BlockCache.end())
-+        return ValueLatticeElement();
-+
-+      if (It->second.OverDefined.count(V))
-         return ValueLatticeElement::getOverdefined();
- 
--      auto I = ValueCache.find_as(V);
--      if (I == ValueCache.end())
-+      auto LatticeIt = It->second.LatticeElements.find(V);
-+      if (LatticeIt == It->second.LatticeElements.end())
-         return ValueLatticeElement();
--      auto BBI = I->second->BlockVals.find(BB);
--      if (BBI == I->second->BlockVals.end())
--        return ValueLatticeElement();
--      return BBI->second;
-+
-+      return LatticeIt->second;
-     }
- 
-     /// clear - Empty the cache.
-     void clear() {
--      SeenBlocks.clear();
--      ValueCache.clear();
--      OverDefinedCache.clear();
-+      BlockCache.clear();
-+      ValueHandles.clear();
-     }
- 
-     /// Inform the cache that a given value has been deleted.
-@@ -248,23 +219,18 @@ namespace {
-     /// OldSucc might have (unless also overdefined in NewSucc).  This just
-     /// flushes elements from the cache and does not add any.
-     void threadEdgeImpl(BasicBlock *OldSucc,BasicBlock *NewSucc);
--
--    friend struct LVIValueHandle;
-   };
- }
- 
- void LazyValueInfoCache::eraseValue(Value *V) {
--  for (auto I = OverDefinedCache.begin(), E = OverDefinedCache.end(); I != E;) {
--    // Copy and increment the iterator immediately so we can erase behind
--    // ourselves.
--    auto Iter = I++;
--    SmallPtrSetImpl<Value *> &ValueSet = Iter->second;
--    ValueSet.erase(V);
--    if (ValueSet.empty())
--      OverDefinedCache.erase(Iter);
-+  for (auto &Pair : BlockCache) {
-+    Pair.second.LatticeElements.erase(V);
-+    Pair.second.OverDefined.erase(V);
-   }
- 
--  ValueCache.erase(V);
-+  auto HandleIt = ValueHandles.find_as(V);
-+  if (HandleIt != ValueHandles.end())
-+    ValueHandles.erase(HandleIt);
- }
- 
- void LVIValueHandle::deleted() {
-@@ -274,18 +240,7 @@ void LVIValueHandle::deleted() {
- }
- 
- void LazyValueInfoCache::eraseBlock(BasicBlock *BB) {
--  // Shortcut if we have never seen this block.
--  DenseSet<PoisoningVH<BasicBlock> >::iterator I = SeenBlocks.find(BB);
--  if (I == SeenBlocks.end())
--    return;
--  SeenBlocks.erase(I);
--
--  auto ODI = OverDefinedCache.find(BB);
--  if (ODI != OverDefinedCache.end())
--    OverDefinedCache.erase(ODI);
--
--  for (auto &I : ValueCache)
--    I.second->BlockVals.erase(BB);
-+  BlockCache.erase(BB);
- }
- 
- void LazyValueInfoCache::threadEdgeImpl(BasicBlock *OldSucc,
-@@ -303,10 +258,11 @@ void LazyValueInfoCache::threadEdgeImpl(BasicBlock *OldSucc,
-   std::vector<BasicBlock*> worklist;
-   worklist.push_back(OldSucc);
- 
--  auto I = OverDefinedCache.find(OldSucc);
--  if (I == OverDefinedCache.end())
-+  auto I = BlockCache.find(OldSucc);
-+  if (I == BlockCache.end() || I->second.OverDefined.empty())
-     return; // Nothing to process here.
--  SmallVector<Value *, 4> ValsToClear(I->second.begin(), I->second.end());
-+  SmallVector<Value *, 4> ValsToClear(I->second.OverDefined.begin(),
-+                                      I->second.OverDefined.end());
- 
-   // Use a worklist to perform a depth-first search of OldSucc's successors.
-   // NOTE: We do not need a visited list since any blocks we have already
-@@ -320,10 +276,10 @@ void LazyValueInfoCache::threadEdgeImpl(BasicBlock *OldSucc,
-     if (ToUpdate == NewSucc) continue;
- 
-     // If a value was marked overdefined in OldSucc, and is here too...
--    auto OI = OverDefinedCache.find(ToUpdate);
--    if (OI == OverDefinedCache.end())
-+    auto OI = BlockCache.find(ToUpdate);
-+    if (OI == BlockCache.end() || OI->second.OverDefined.empty())
-       continue;
--    SmallPtrSetImpl<Value *> &ValueSet = OI->second;
-+    auto &ValueSet = OI->second.OverDefined;
- 
-     bool changed = false;
-     for (Value *V : ValsToClear) {
-@@ -333,11 +289,6 @@ void LazyValueInfoCache::threadEdgeImpl(BasicBlock *OldSucc,
-       // If we removed anything, then we potentially need to update
-       // blocks successors too.
-       changed = true;
--
--      if (ValueSet.empty()) {
--        OverDefinedCache.erase(OI);
--        break;
--      }
-     }
- 
-     if (!changed) continue;
--- 
-2.24.0
-
diff --git a/projects/fenix-clang/build b/projects/fenix-clang/build
index 10700ce..c3c15f1 100644
--- a/projects/fenix-clang/build
+++ b/projects/fenix-clang/build
@@ -10,20 +10,21 @@ export PATH="/var/tmp/dist/cmake/bin:$PATH"
   [% pc('gcc', 'var/setup', { compiler_tarfile => c('input_files_by_name/gcc'),
                               hardened_gcc => 0 }) %]
   ln -s gcc /var/tmp/dist/gcc/bin/cc
-  tar -C /var/tmp/dist -xf [% c('input_files_by_name/binutils') %]
-  export PATH="/var/tmp/dist/binutils/bin:$PATH"
 [% END -%]
+tar -C /var/tmp/dist -xf [% c('input_files_by_name/binutils') %]
+export PATH="/var/tmp/dist/binutils/bin:$PATH"
+
 mkdir -p /var/tmp/build
 cd /var/tmp/build
-tar -xf $rootdir/[% c('input_files_by_name/clang-source') %]
-cd clang-source
-export LLVM_HOME=$(pwd)
+tar -xf $rootdir/[% c('input_files_by_name/llvm-project') %]
+cd llvm-project
 mkdir build
 cd build
-cmake .. -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX=$distdir \
-                             -DCMAKE_BUILD_TYPE:STRING=Release \
-     [% IF c("var/rlbox") -%]-DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD=WebAssembly \[% END -%]
-                             $LLVM_HOME
+cmake ../llvm -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX=$distdir \
+                          -DCMAKE_BUILD_TYPE=Release \
+                          -DLLVM_TARGETS_TO_BUILD="X86;ARM;AArch64" \
+  [% IF c("var/rlbox") -%]-DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD=WebAssembly \[% END -%]
+                          -DLLVM_ENABLE_PROJECTS="clang;clang-tools-extra;compiler-rt;libcxx;libcxxabi;lld"
 make -j[% c("buildconf/num_procs") %]
 make install
 cd /var/tmp/dist
diff --git a/projects/fenix-clang/config b/projects/fenix-clang/config
index 46d308a..4bc55f3 100644
--- a/projects/fenix-clang/config
+++ b/projects/fenix-clang/config
@@ -1,5 +1,5 @@
 # vim: filetype=yaml sw=2
-version: 9.0.1
+version: '[% pc("llvm-project", "version") %]'
 filename: '[% project %]-[% c("version") %]-[% c("var/build_id") %].tar.gz'
 
 var:
@@ -13,8 +13,7 @@ input_files:
     enable: '[% c("var/linux") %]'
   - name: binutils
     project: binutils
-    enable: '[% c("var/linux") %]'
   - project: cmake
     name: cmake
-  - project: clang-source
-    name: clang-source
+  - project: llvm-project
+    name: llvm-project
diff --git a/projects/llvm-project/build b/projects/llvm-project/build
new file mode 100644
index 0000000..ac0f21b
--- /dev/null
+++ b/projects/llvm-project/build
@@ -0,0 +1,8 @@
+#!/bin/bash
+[% c("var/set_default_env") -%]
+tar xf [% project %]-[% c("version") %].tar.gz
+mv [% project %]-[% c("version") %] [% project %]
+[% c('tar', {
+        tar_src => [ project ],
+        tar_args => '-czf ' _ dest_dir _ '/' _ c('filename'),
+    }) %]
diff --git a/projects/llvm-project/config b/projects/llvm-project/config
new file mode 100644
index 0000000..1574177
--- /dev/null
+++ b/projects/llvm-project/config
@@ -0,0 +1,5 @@
+# vim: filetype=yaml sw=2
+version: 11.0.0-rc3
+git_hash: 8aca41f39c207b6f9efe2e448986d109892072ad
+git_url: https://github.com/llvm/llvm-project
+filename: '[% project %]-[% c("version") %]-[% c("var/build_id") %].tar.gz'





More information about the tor-commits mailing list