C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Random numbers in identical builds

From: Thiago Macieira <thiago_at_[hidden]>
Date: Sat, 08 Mar 2025 07:17:27 -0800
On Saturday, 8 March 2025 06:53:53 Pacific Standard Time Frederick Virchanza
Gotham via Std-Proposals wrote:
> It takes the name of the file, the line number and the character number, so
> a string something like "myfile.cpp 5 25", and it feeds it into MD5 to
> produce a hash digest.
> It takes the hash digest and XOR's with the UUID we gave it at the command
> line.

There's no need to do any of that.

First of all, if you don't fix the seed, then whatever it does is irrelevant:
the numbers will come out different anyway.

But if you do fix the seed, you should let the compilers decide what is
important for reproducible builds. And I'd think all they need is a random
number generator and a sequence number. If you modify the source but don't
change the quantity of uses of the macro, then it will generate the same
numbers. That is more than sufficient because, if you're striving for
reproducibility, you're probably not modifying the sources *intentionally* but
may be due to trivial changes like line endings and white space.

-- 
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
  Principal Engineer - Intel DCAI Platform & System Engineering

Received on 2025-03-08 15:17:33