Skip to content

Commit de3c616

Browse files
committed
start, make built artifacts more reproducible but specifying -ffile-prefix-map
1 parent bb3f7d0 commit de3c616

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

toolchain/cc_toolchain_config.bzl

+4-1
Original file line numberDiff line numberDiff line change
@@ -113,11 +113,12 @@ def cc_toolchain_config(
113113
unfiltered_compile_flags = [
114114
# Do not resolve our symlinked resource prefixes to real paths.
115115
"-no-canonical-prefixes",
116-
# Reproducibility
116+
# Reproducibility.
117117
"-Wno-builtin-macro-redefined",
118118
"-D__DATE__=\"redacted\"",
119119
"-D__TIMESTAMP__=\"redacted\"",
120120
"-D__TIME__=\"redacted\"",
121+
"-ffile-prefix-map=${{pwd}}=__bazel_toolchain_llvm_repo__",
121122
]
122123

123124
is_xcompile = not (exec_os == target_os and exec_arch == target_arch)
@@ -150,6 +151,8 @@ def cc_toolchain_config(
150151
link_flags = [
151152
"--target=" + target_system_name,
152153
"-no-canonical-prefixes",
154+
# Reproducibility.
155+
"-ffile-prefix-map=${{pwd}}=__bazel_toolchain_llvm_repo__",
153156
]
154157

155158
stdlib = compiler_configuration["stdlib"]

toolchain/cc_wrapper.sh.tpl

+3
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ function sanitize_option() {
5353
# shellcheck disable=SC2206
5454
parts=(${opt/=/ }) # Split flag name and value into array.
5555
printf "%s" "${parts[0]}=${execroot_path}${parts[1]}"
56+
elif [[ ${opt} == *"\${{pwd}}"* ]]; then
57+
# Replace the literal string '${{pwd}}' with the execroot.
58+
printf "%s" "${opt//\$\{\{pwd\}\}/${execroot_abs_path%/}}"
5659
else
5760
printf "%s" "${opt}"
5861
fi

toolchain/osx_cc_wrapper.sh.tpl

+3
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,9 @@ function sanitize_option() {
7979
# shellcheck disable=SC2206
8080
parts=(${opt/=/ }) # Split flag name and value into array.
8181
printf "%s" "${parts[0]}=${execroot_path}${parts[1]}"
82+
elif [[ ${opt} == *"\${{pwd}}"* ]]; then
83+
# Replace the literal string '${{pwd}}' with the execroot.
84+
printf "%s" "${opt//\$\{\{pwd\}\}/${execroot_abs_path%/}}"
8285
else
8386
printf "%s" "${opt}"
8487
fi

0 commit comments

Comments
 (0)