Skip to content

compiler-wrapper: set -frandom-seed="$*" for gcc - #4718

Closed
haampie wants to merge 1 commit into
developfrom
hs/compiler-wrapper/reproducible
Closed

compiler-wrapper: set -frandom-seed="$*" for gcc#4718
haampie wants to merge 1 commit into
developfrom
hs/compiler-wrapper/reproducible

Conversation

@haampie

@haampie haampie commented May 7, 2026

Copy link
Copy Markdown
Member

To make builds deterministic with GCC, use -frandom-seed with the
value set to all command line arguments. GCC uses the CRC checksum of
this string to initialize its random number generator.

LLVM is deterministic by default.

One concern could be "Argument list too long", but I think this one extra
flag is typically smaller than all the -I, -L, -Wl, flags we inject.

@spackbot-triage spackbot-triage Bot added the update-package Modifications to packages in the repository label May 7, 2026
@haampie
haampie force-pushed the hs/compiler-wrapper/reproducible branch 2 times, most recently from d22de77 to 6e3bbe0 Compare May 13, 2026 08:38
@haampie haampie changed the title compiler-wrapper: set -frandom-seed compiler-wrapper: set -frandom-seed for gcc May 13, 2026
@haampie
haampie marked this pull request as ready for review May 13, 2026 08:40
@haampie
haampie marked this pull request as draft May 13, 2026 09:35
To make builds deterministic with GCC, use `-frandom-seed` with the
value set to all command line arguments.

Signed-off-by: Harmen Stoppels <me@harmenstoppels.nl>
@haampie
haampie force-pushed the hs/compiler-wrapper/reproducible branch from 6e3bbe0 to ea7c243 Compare May 13, 2026 09:53
@haampie haampie changed the title compiler-wrapper: set -frandom-seed for gcc compiler-wrapper: set -frandom-seed=$* for gcc May 13, 2026
@haampie haampie changed the title compiler-wrapper: set -frandom-seed=$* for gcc compiler-wrapper: set -frandom-seed="$*" for gcc May 13, 2026
@haampie
haampie marked this pull request as ready for review May 13, 2026 10:04
@haampie

haampie commented May 13, 2026

Copy link
Copy Markdown
Member Author

Regarding binutils, we can assume it's configured with --enable-deterministic-archives (Spack default, and a default in various distros)

The only non-determinism can come from ar -U, which should then be fixed with ARFLAGS=..., a @run_after hook, or a patch.

@haampie
haampie marked this pull request as draft May 13, 2026 14:38
@haampie

haampie commented May 13, 2026

Copy link
Copy Markdown
Member Author

Converted to draft cause I've submitted this to spack/compiler-wrapper, and we need #4829 first.

@haampie

haampie commented May 13, 2026

Copy link
Copy Markdown
Member Author

Combined with #4829 to avoid double full rebuild.

@haampie haampie closed this May 13, 2026
@haampie
haampie deleted the hs/compiler-wrapper/reproducible branch May 13, 2026 15:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

update-package Modifications to packages in the repository

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant