Skip to content

Commit 7edd455

Browse files
-ffile-prefix-map=<staging>=. injection in compiler-wrapper (cc.sh). tests added in test/run.sh (test_debug_prefix_map)
Signed-off-by: SebastianPaucar <paucar.sebastian@hotmail.com>
1 parent 512a623 commit 7edd455

2 files changed

Lines changed: 45 additions & 1 deletion

File tree

cc.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -754,6 +754,11 @@ elif [ "$SPACK_ADD_DEBUG_FLAGS" = "custom" ]; then
754754
extend flags_list SPACK_DEBUG_FLAGS
755755
fi
756756

757+
# -ffile-prefix-map=<staging>=. injection for build reproducibility
758+
if [ -n "${SPACK_DEBUG_PREFIX_MAP:-}" ]; then
759+
append flags_list "-ffile-prefix-map=${SPACK_DEBUG_PREFIX_MAP}=."
760+
fi
761+
757762
spack_flags_list=""
758763

759764
# Fortran flags come before CPPFLAGS

test/run.sh

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ SPACK_COMPILER_EXTRA_RPATHS SPACK_COMPILER_IMPLICIT_RPATHS
187187
SPACK_CC_HAS_FRANDOM_SEED SPACK_CXX_HAS_FRANDOM_SEED
188188
SPACK_FC_HAS_FRANDOM_SEED SPACK_F77_HAS_FRANDOM_SEED
189189
SPACK_CCACHE_BINARY SPACK_TEST_COMMAND SPACK_ADD_DEBUG_FLAGS SPACK_DEBUG_FLAGS
190-
SPACK_DEBUG
190+
SPACK_DEBUG SPACK_DEBUG_PREFIX_MAP
191191
'
192192

193193
wrapper_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
13591397
test_frandom_seed_not_added_without_env
13601398
test_frandom_seed_filters_args
13611399
test_add_debug_flags_validation
1400+
test_debug_prefix_map
13621401
'
13631402

13641403
all_tests="$wrapper_tests $list_ops_tests"

0 commit comments

Comments
 (0)