Skip to content

Commit

Permalink
start, make built artifacts more reproducible but specifying -ffile-p…
Browse files Browse the repository at this point in the history
…refix-map
  • Loading branch information
ParkMyCar committed Jan 18, 2025
1 parent bb3f7d0 commit de3c616
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
5 changes: 4 additions & 1 deletion toolchain/cc_toolchain_config.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,12 @@ def cc_toolchain_config(
unfiltered_compile_flags = [
# Do not resolve our symlinked resource prefixes to real paths.
"-no-canonical-prefixes",
# Reproducibility
# Reproducibility.
"-Wno-builtin-macro-redefined",
"-D__DATE__=\"redacted\"",
"-D__TIMESTAMP__=\"redacted\"",
"-D__TIME__=\"redacted\"",
"-ffile-prefix-map=${{pwd}}=__bazel_toolchain_llvm_repo__",
]

is_xcompile = not (exec_os == target_os and exec_arch == target_arch)
Expand Down Expand Up @@ -150,6 +151,8 @@ def cc_toolchain_config(
link_flags = [
"--target=" + target_system_name,
"-no-canonical-prefixes",
# Reproducibility.
"-ffile-prefix-map=${{pwd}}=__bazel_toolchain_llvm_repo__",
]

stdlib = compiler_configuration["stdlib"]
Expand Down
3 changes: 3 additions & 0 deletions toolchain/cc_wrapper.sh.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ function sanitize_option() {
# shellcheck disable=SC2206
parts=(${opt/=/ }) # Split flag name and value into array.
printf "%s" "${parts[0]}=${execroot_path}${parts[1]}"
elif [[ ${opt} == *"\${{pwd}}"* ]]; then
# Replace the literal string '${{pwd}}' with the execroot.
printf "%s" "${opt//\$\{\{pwd\}\}/${execroot_abs_path%/}}"
else
printf "%s" "${opt}"
fi
Expand Down
3 changes: 3 additions & 0 deletions toolchain/osx_cc_wrapper.sh.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ function sanitize_option() {
# shellcheck disable=SC2206
parts=(${opt/=/ }) # Split flag name and value into array.
printf "%s" "${parts[0]}=${execroot_path}${parts[1]}"
elif [[ ${opt} == *"\${{pwd}}"* ]]; then
# Replace the literal string '${{pwd}}' with the execroot.
printf "%s" "${opt//\$\{\{pwd\}\}/${execroot_abs_path%/}}"
else
printf "%s" "${opt}"
fi
Expand Down

0 comments on commit de3c616

Please sign in to comment.