<html>
    <head>
      <base href="https://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - Retire the non-deterministic ASTFileSignature"
   href="https://llvm.org/bugs/show_bug.cgi?id=27449">27449</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Retire the non-deterministic ASTFileSignature
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>unspecified
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Modules
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>aprantl@apple.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>dgregor@apple.com, llvm-bugs@lists.llvm.org
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Implicitly-built modules currently contain a random 32-bit ASTFileSignature.
This makes clang modules nondeterministic which is generally undesirable.

ASTReader has a comment that explains how we arrived at the status quo nicely:

    // For implicit modules we output a signature that we can use to ensure
    // duplicate module builds don't collide in the cache as their output order
    // is non-deterministic.
    // FIXME: Remove this when output is deterministic.
    if (Context.getLangOpts().ImplicitModules) {
      Signature = getSignature();
      RecordData::value_type Record[] = {Signature};
      Stream.EmitRecord(SIGNATURE, Record);
    }


  static ASTFileSignature getSignature() {
    while (1) {
      if (ASTFileSignature S = llvm::sys::Process::GetRandomNumber())
        return S;
      // Rely on GetRandomNumber to eventually return non-zero...
    }
  }

The existence of test/Modules/stress1.cpp seems to indicate that we were able
to remove all(?) sources of nondeterminism in the mean time, so we should be
able to retire this hack.

A minor complication is that module debug info currently uses the module
signature as the DWO_id to uniquely identify a module, but we should be able to
replace this by an actual hash of the serialized AST (which won't be
deterministic until after the ASTFileSignature is removed).</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>