Date: Sat, 8 Mar 2025 14:53:53 +0000
There's another thread running alongside this one about constexpr clocks,
but I'm changing topic to focus on having UUID's at compile time, allowing
for repeatable builds that produce an identical binary.
You start by generating a UUID, so let's say:
11223344556677881122334455667788
You feed this into the compiler something like:
g++ -c myfile.cpp -o myfile.o
-uuid_seed=11223344556677881122334455667788
And so then when the compiler encounters the preprocessor macro 'UUID',
here's what it does:
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.
This will give us unique 128-bit numbers at compile time, and if we hit
Rebuild, we'll get an identical binary. It will also work fine for parallel
builds.
If we ever want to change the random numbers, just change the UUID we give
it at the command line.
but I'm changing topic to focus on having UUID's at compile time, allowing
for repeatable builds that produce an identical binary.
You start by generating a UUID, so let's say:
11223344556677881122334455667788
You feed this into the compiler something like:
g++ -c myfile.cpp -o myfile.o
-uuid_seed=11223344556677881122334455667788
And so then when the compiler encounters the preprocessor macro 'UUID',
here's what it does:
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.
This will give us unique 128-bit numbers at compile time, and if we hit
Rebuild, we'll get an identical binary. It will also work fine for parallel
builds.
If we ever want to change the random numbers, just change the UUID we give
it at the command line.
Received on 2025-03-08 14:53:55