Bug 1497914 - Add a platform-specific piece into the symbol hash from generated files. r=mccr8
authorKartikaya Gupta <kgupta@mozilla.com>
Thu, 11 Oct 2018 10:01:31 -0400
changeset 499257 76efab1fc917e6efa5cb5c1335b530735be0d44f
parent 499256 6a40850883ffce1683a1c29f81314acaad331b9b
child 499258 bf766a8de9d730af010c6fc80b8619ed92ccb483
push id1864
push userffxbld-merge
push dateMon, 03 Dec 2018 15:51:40 +0000
treeherdermozilla-release@f040763d99ad [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmccr8
bugs1497914
milestone64.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1497914 - Add a platform-specific piece into the symbol hash from generated files. r=mccr8
build/clang-plugin/mozsearch-plugin/MozsearchIndexer.cpp
taskcluster/ci/searchfox/kind.yml
--- a/build/clang-plugin/mozsearch-plugin/MozsearchIndexer.cpp
+++ b/build/clang-plugin/mozsearch-plugin/MozsearchIndexer.cpp
@@ -91,33 +91,36 @@ class IndexConsumer;
 // here.
 struct FileInfo {
   FileInfo(std::string &Rname) : Realname(Rname) {
     if (Rname.compare(0, Objdir.length(), Objdir) == 0) {
       // We're in the objdir, so we are probably a generated header
       // We use the escape character to indicate the objdir nature.
       // Note that output also has the `/' already placed
       Interesting = true;
+      Generated = true;
       Realname.replace(0, Objdir.length(), GENERATED);
       return;
     }
 
     // Empty filenames can get turned into Srcdir when they are resolved as
     // absolute paths, so we should exclude files that are exactly equal to
     // Srcdir or anything outside Srcdir.
     Interesting = (Rname.length() > Srcdir.length()) &&
                   (Rname.compare(0, Srcdir.length(), Srcdir) == 0);
+    Generated = false;
     if (Interesting) {
       // Remove the trailing `/' as well.
       Realname.erase(0, Srcdir.length() + 1);
     }
   }
   std::string Realname;
   std::vector<std::string> Output;
   bool Interesting;
+  bool Generated;
 };
 
 class IndexConsumer;
 
 class PreprocessorHook : public PPCallbacks {
   IndexConsumer *Indexer;
 
 public:
@@ -325,16 +328,24 @@ private:
 
   std::string mangleLocation(SourceLocation Loc,
                              std::string Backup = std::string()) {
     FileInfo *F = getFileInfo(Loc);
     std::string Filename = F->Realname;
     if (Filename.length() == 0 && Backup.length() != 0) {
       return Backup;
     }
+    if (F->Generated) {
+      // Since generated files may be different on different platforms,
+      // we need to include a platform-specific thing in the hash. Otherwise
+      // we can end up with hash collisions where different symbols from
+      // different platforms map to the same thing.
+      char* Platform = getenv("MOZSEARCH_PLATFORM");
+      Filename = std::string(Platform ? Platform : "") + std::string("@") + Filename;
+    }
     return hash(Filename + std::string("@") + locationToString(Loc));
   }
 
   std::string mangleQualifiedName(std::string Name) {
     std::replace(Name.begin(), Name.end(), ' ', '_');
     return Name;
   }
 
--- a/taskcluster/ci/searchfox/kind.yml
+++ b/taskcluster/ci/searchfox/kind.yml
@@ -31,16 +31,17 @@ jobs:
         treeherder:
             platform: linux64/debug
         worker-type: aws-provisioner-v1/gecko-{level}-b-linux
         worker:
             max-run-time: 36000
             env:
                 PERFHERDER_EXTRA_OPTIONS: searchfox
                 RUSTC_BOOTSTRAP: "1"
+                MOZSEARCH_PLATFORM: "linux"
         run:
             using: mozharness
             actions: [build]
             config:
                 - builds/releng_base_firefox.py
                 - builds/releng_sub_linux_configs/64_searchfox_and_debug.py
             script: "mozharness/scripts/fx_desktop_build.py"
             tooltool-downloads: public
@@ -59,16 +60,17 @@ jobs:
             platform: osx-cross/debug
         worker-type: aws-provisioner-v1/gecko-{level}-b-linux
         worker:
             max-run-time: 36000
             env:
                 TOOLTOOL_MANIFEST: "browser/config/tooltool-manifests/macosx64/cross-releng.manifest"
                 PERFHERDER_EXTRA_OPTIONS: searchfox
                 RUSTC_BOOTSTRAP: "1"
+                MOZSEARCH_PLATFORM: "macosx"
         run:
             using: mozharness
             actions: [get-secrets build]
             config:
                 - builds/releng_base_firefox.py
                 - builds/releng_base_mac_64_cross_builds.py
             script: "mozharness/scripts/fx_desktop_build.py"
             custom-build-variant-cfg: cross-debug-searchfox