@@ -196,6 +196,7 @@ execute() {
196196 output_log=" $SPACK_DEBUG_LOG_DIR /spack-cc-$SPACK_DEBUG_LOG_ID .out.log"
197197 echo " [$mode ] $command $input_command " >> " $input_log "
198198 IFS=" $lsep "
199+ # shellcheck disable=SC2086
199200 echo " [$mode ] " $full_command_list >> " $output_log "
200201 unset IFS
201202 fi
@@ -365,20 +366,17 @@ if [ -z "$mode" ] || [ "$mode" = ld ]; then
365366 done
366367fi
367368
368- # 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:-}"
369371if [ -z " $mode " ]; then
370372 mode=ccld
371373 for arg in " $@ " ; do
372- if [ " $arg " = " -E" ]; then
373- mode=cpp
374- break
375- elif [ " $arg " = " -S" ]; then
376- mode=as
377- break
378- elif [ " $arg " = " -c" ]; then
379- mode=cc
380- break
381- 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
382380 done
383381fi
384382
@@ -437,9 +435,10 @@ export PATH="$new_dirs"
437435
438436if [ " $mode " = vcheck ]; then
439437 full_command_list=" $command "
440- args=" $@ "
441438 extend full_command_list vcheck_flags
442- extend full_command_list args
439+ for arg in " $@ " ; do
440+ append full_command_list " $arg "
441+ done
443442 execute
444443fi
445444
@@ -580,6 +579,7 @@ categorize_arguments() {
580579 eval " \
581580 stripped=\"\$ {1##$before }\"
582581 "
582+ # shellcheck disable=SC2154 # shellcheck doesn't see eval
583583 if [ " $stripped " = " $1 " ] ; then
584584 continue
585585 fi
@@ -633,6 +633,7 @@ categorize_arguments() {
633633 ;;
634634 -Wl,* )
635635 IFS=,
636+ # shellcheck disable=SC2086 # intentional splitting
636637 if ! parse_Wl ${1# -Wl,} ; then
637638 append return_other_args_list " $1 "
638639 fi
@@ -803,7 +804,8 @@ case "$mode" in
803804esac
804805
805806IFS=" $lsep "
806- categorize_arguments $spack_flags_list
807+ # shellcheck disable=SC2086 # intentional splitting
808+ categorize_arguments $spack_flags_list
807809unset IFS
808810
809811assign_path_lists spack_flags_isystem_include_dirs_list return_isystem_include_dirs_list
@@ -951,6 +953,15 @@ extend args_list libs_list "-l"
951953full_command_list=" $command "
952954extend full_command_list args_list
953955
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+
954965# prepend the ccache binary if we're using ccache
955966if [ -n " $SPACK_CCACHE_BINARY " ]; then
956967 case " $lang_flags " in
0 commit comments