Clang and binary Reproducibility

I am planning on porting some of my Microsoft C++ based projects to the clang
compiler . I know that gcc supports Binary reproducibility . My question is
does clang support binary reproducibility ?

if by ‘binary reproducibility’ you mean two matching invocations of the compiler (same arguments, same input, same headers, etc) should produce exactly the same bytes in the binary - yes, Clang supports this. (on a best-effort basis, at least - whenever we find that it doesn’t, we fix the bugs & I think we have some reasonable test infrastructure for this though it could probably be better)

You might need to pass -frandom-seed for this purpose, e.g. a hash of
the name of the input files + some project cookie.

Joerg

> if by 'binary reproducibility' you mean two matching invocations of the
> compiler (same arguments, same input, same headers, etc) should produce
> exactly the same bytes in the binary - yes, Clang supports this.

You might need to pass -frandom-seed for this purpose, e.g. a hash of
the name of the input files + some project cookie.

Good to keep in mind, in general.

I /believe/ only specific opt-in features use randomness deliberately (as a
security threat mitigation, is one instance that comes to mind). If
anything that doesn't look like an explicit "Randomize my stuff" flag
causes non-reproducible output, that's probably a bug.

- David