<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/63961>63961</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            MachO UUID dependency on `compute_thread_count` makes reproducing builds harder
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          PieroV
      </td>
    </tr>
</table>

<pre>
    We run builds on normalized containers to provide reproducible builds.
However, after updating from Clang 14.0.4 to Clang 16.0.4, we started not being able to reproduce builds anymore.
The build is still deterministic, if ran on the same machine multiple times, but it leads to different results when run in machines with different hardware. The binaries only differ on the UUID.
I think the problem is that `Writer::writeUuid()` has a dependency on `parallel::strategy.compute_thread_count()`.

We cross compile everything from Debian containers, in a LLVM we build ourselves by following Mozilla's build scripts.

Even an almost empty C file leads to the same result:

```C
int main() {}
```

```bash
clang -isysroot .../MacOSX13.3.sdk -target x86_64-apple-darwin -B .../cctools/bin -isysroot .../MacOSX13.3.sdk -fuse-ld=lld main.c
```

```
sha256sum a.out
3812ad038467550193e511fc201185d3e5ce2cac57142c8e0f8bb844c5493e3c a.out # My machine, 16 threads
2dbca6391b414bc06af85d4a2a019b4616846b0cb7f57c3d39a359f3996b59b3 a.out # Build server, 64 threads
```

Stripping the UUID with Apple's strip (`llvm-strip` does not to support this feature), makes the files the same:

```
x86_64-apple-darwin-strip -ur -no_uuid a.out
sha256sum a.out
2e2ac0a89be330b80751bae739f481c173485b0b6825108b9ed17e2e87c368b9 a.out
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyMVU2P2zYQ_TXyZWBBJCVKOviwH100QBYpkCbpbcGPkcUuRQokta7z6wtKXnfTbtEChm2SM29m-N4MRYzm6BAPRXNbNPc7saTRh8MvBoP_upNenw_fEMLiQC7G6gjegfNhEtZ8Rw3KuySMwxAheZiDfzEaI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