@@ -187,7 +187,7 @@ SPACK_COMPILER_EXTRA_RPATHS SPACK_COMPILER_IMPLICIT_RPATHS
187187SPACK_CC_HAS_FRANDOM_SEED SPACK_CXX_HAS_FRANDOM_SEED
188188SPACK_FC_HAS_FRANDOM_SEED SPACK_F77_HAS_FRANDOM_SEED
189189SPACK_CCACHE_BINARY SPACK_TEST_COMMAND SPACK_ADD_DEBUG_FLAGS SPACK_DEBUG_FLAGS
190- SPACK_DEBUG
190+ SPACK_DEBUG SPACK_DEBUG_PREFIX_MAP
191191'
192192
193193wrapper_environment () {
@@ -1309,6 +1309,44 @@ test_add_debug_flags_validation() {
13091309 unset SPACK_ADD_DEBUG_FLAGS
13101310}
13111311
1312+ # ---------------------------------------------------------------------------
1313+ # SPACK_DEBUG_PREFIX_MAP injection
1314+ # ---------------------------------------------------------------------------
1315+
1316+ test_debug_prefix_map () {
1317+ wrapper_environment
1318+
1319+ # When SPACK_DEBUG_PREFIX_MAP is unset, -ffile-prefix-map must NOT appear.
1320+ unset SPACK_DEBUG_PREFIX_MAP
1321+ _out=$( dump_args cc ' ' )
1322+ expect_not_contains debug_prefix_map_absent " $_out " \
1323+ ' -ffile-prefix-map=/some/stage/path=.'
1324+
1325+ # When set, -ffile-prefix-map=<value>=. must appear for C.
1326+ SPACK_DEBUG_PREFIX_MAP=' /some/stage/path'
1327+ export SPACK_DEBUG_PREFIX_MAP
1328+ _out=$( dump_args cc ' ' )
1329+ expect_contains debug_prefix_map_cc " $_out " \
1330+ ' -ffile-prefix-map=/some/stage/path=.'
1331+
1332+ # Must appear for C++ wrapper too.
1333+ _out=$( dump_args c++ ' ' )
1334+ expect_contains debug_prefix_map_cxx " $_out " \
1335+ ' -ffile-prefix-map=/some/stage/path=.'
1336+
1337+ # Must appear for Fortran wrapper too.
1338+ _out=$( dump_args fc ' ' )
1339+ expect_contains debug_prefix_map_fc " $_out " \
1340+ ' -ffile-prefix-map=/some/stage/path=.'
1341+
1342+ # Must NOT appear in vcheck mode
1343+ _out=$( dump_args cc ' --version' )
1344+ expect_not_contains debug_prefix_map_vcheck " $_out " \
1345+ ' -ffile-prefix-map=/some/stage/path=.'
1346+
1347+ unset SPACK_DEBUG_PREFIX_MAP
1348+ }
1349+
13121350# ---------------------------------------------------------------------------
13131351# Runner
13141352# ---------------------------------------------------------------------------
@@ -1359,6 +1397,7 @@ test_spack_managed_dirs_are_prioritized
13591397test_frandom_seed_not_added_without_env
13601398test_frandom_seed_filters_args
13611399test_add_debug_flags_validation
1400+ test_debug_prefix_map
13621401'
13631402
13641403all_tests=" $wrapper_tests $list_ops_tests "
0 commit comments