Skip to content

Commit e8b50ad

Browse files
committed
add -frandom-seed support (#3)
1 parent 145cf31 commit e8b50ad

1 file changed

Lines changed: 17 additions & 11 deletions

File tree

cc.sh

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -366,20 +366,17 @@ if [ -z "$mode" ] || [ "$mode" = ld ]; then
366366
done
367367
fi
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:-}"
370371
if [ -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
384381
fi
385382

@@ -956,6 +953,15 @@ extend args_list libs_list "-l"
956953
full_command_list="$command"
957954
extend 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
960966
if [ -n "$SPACK_CCACHE_BINARY" ]; then
961967
case "$lang_flags" in

0 commit comments

Comments
 (0)