File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -366,20 +366,17 @@ if [ -z "$mode" ] || [ "$mode" = ld ]; then
366366 done
367367fi
368368
369- # Finish setting up the mode.
369+ # Finish setting up the mode, and check whether -frandom-seed needs to be set.
370+ eval " _set_frandom_seed=\$ {SPACK_${comp} _HAS_FRANDOM_SEED:-}"
370371if [ -z " $mode " ]; then
371372 mode=ccld
372373 for arg in " $@ " ; do
373- if [ " $arg " = " -E" ]; then
374- mode=cpp
375- break
376- elif [ " $arg " = " -S" ]; then
377- mode=as
378- break
379- elif [ " $arg " = " -c" ]; then
380- mode=cc
381- break
382- fi
374+ case $arg in
375+ -E) mode=cpp ;;
376+ -S) mode=as ;;
377+ -c) mode=cc ;;
378+ -frandom-seed=* ) _set_frandom_seed= ;;
379+ esac
383380 done
384381fi
385382
@@ -956,6 +953,15 @@ extend args_list libs_list "-l"
956953full_command_list=" $command "
957954extend full_command_list args_list
958955
956+ if [ -n " $_set_frandom_seed " ]; then
957+ case " $mode " in
958+ cc|ccld)
959+ # Make GCC deterministic by setting the random seed to command line arguments
960+ append full_command_list " -frandom-seed=$input_command "
961+ ;;
962+ esac
963+ fi
964+
959965# prepend the ccache binary if we're using ccache
960966if [ -n " $SPACK_CCACHE_BINARY " ]; then
961967 case " $lang_flags " in
You can’t perform that action at this time.
0 commit comments