Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions cc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -754,6 +754,15 @@ elif [ "$SPACK_ADD_DEBUG_FLAGS" = "custom" ]; then
extend flags_list SPACK_DEBUG_FLAGS
fi

# -ffile-prefix-map=<staging>=. injection for build reproducibility
case "$mode" in
cpp|as|cc|ccld)
if [ -n "${SPACK_DEBUG_PREFIX_MAP:-}" ]; then
append flags_list "-ffile-prefix-map=${SPACK_DEBUG_PREFIX_MAP}=."
fi
;;
esac

spack_flags_list=""

# Fortran flags come before CPPFLAGS
Expand Down
49 changes: 48 additions & 1 deletion test/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ SPACK_COMPILER_EXTRA_RPATHS SPACK_COMPILER_IMPLICIT_RPATHS
SPACK_CC_HAS_FRANDOM_SEED SPACK_CXX_HAS_FRANDOM_SEED
SPACK_FC_HAS_FRANDOM_SEED SPACK_F77_HAS_FRANDOM_SEED
SPACK_CCACHE_BINARY SPACK_TEST_COMMAND SPACK_ADD_DEBUG_FLAGS SPACK_DEBUG_FLAGS
SPACK_DEBUG
SPACK_DEBUG SPACK_DEBUG_PREFIX_MAP
'

wrapper_environment() {
Expand Down Expand Up @@ -1309,6 +1309,52 @@ test_add_debug_flags_validation() {
unset SPACK_ADD_DEBUG_FLAGS
}

# ---------------------------------------------------------------------------
# SPACK_DEBUG_PREFIX_MAP injection
# ---------------------------------------------------------------------------

test_debug_prefix_map() {
wrapper_environment

# When SPACK_DEBUG_PREFIX_MAP is unset, -ffile-prefix-map must NOT appear.
unset SPACK_DEBUG_PREFIX_MAP
_out=$(dump_args cc '')
expect_not_contains debug_prefix_map_absent "$_out" \
'-ffile-prefix-map=/some/stage/path=.'

# When set, -ffile-prefix-map=<value>=. must appear for C.
SPACK_DEBUG_PREFIX_MAP='/some/stage/path'
export SPACK_DEBUG_PREFIX_MAP
_out=$(dump_args cc '')
expect_contains debug_prefix_map_cc "$_out" \
'-ffile-prefix-map=/some/stage/path=.'

# Must appear for C++ wrapper too.
_out=$(dump_args c++ '')
expect_contains debug_prefix_map_cxx "$_out" \
'-ffile-prefix-map=/some/stage/path=.'

# Must appear for Fortran wrapper too.
_out=$(dump_args fc '')
expect_contains debug_prefix_map_fc "$_out" \
'-ffile-prefix-map=/some/stage/path=.'

# Must NOT appear in vcheck mode
_out=$(dump_args cc '--version')
expect_not_contains debug_prefix_map_vcheck "$_out" \
'-ffile-prefix-map=/some/stage/path=.'

# Must NOT appear in ld mode
SPACK_DEBUG_PREFIX_MAP='/some/stage/path'
export SPACK_DEBUG_PREFIX_MAP
_out=$(dump_args ld '')
expect_not_contains debug_prefix_map_ld "$_out" \
'-ffile-prefix-map=/some/stage/path=.'

unset SPACK_DEBUG_PREFIX_MAP

}

# ---------------------------------------------------------------------------
# Runner
# ---------------------------------------------------------------------------
Expand Down Expand Up @@ -1359,6 +1405,7 @@ test_spack_managed_dirs_are_prioritized
test_frandom_seed_not_added_without_env
test_frandom_seed_filters_args
test_add_debug_flags_validation
test_debug_prefix_map
'

all_tests="$wrapper_tests $list_ops_tests"
Expand Down