File tree Expand file tree Collapse file tree 3 files changed +12
-1
lines changed Expand file tree Collapse file tree 3 files changed +12
-1
lines changed Original file line number Diff line number Diff 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" ]
Original file line number Diff line number Diff line change @@ -34,12 +34,14 @@ set -euo pipefail
3434
3535if [[ -f %{toolchain_path_prefix}bin/clang ]]; then
3636 execroot_path=" "
37+ execroot_abs_path=" ${PWD} /"
3738elif [[ ${BASH_SOURCE[0]} == " /" * ]]; then
3839 # Some consumers of `CcToolchainConfigInfo` (e.g. `cmake` from rules_foreign_cc)
3940 # change CWD and call $CC (this script) with its absolute path.
4041 # For cases like this, we'll try to find `clang` through an absolute path.
4142 # This script is at _execroot_/external/_repo_name_/bin/cc_wrapper.sh
4243 execroot_path=" ${BASH_SOURCE[0]%/*/*/*/* } /"
44+ execroot_abs_path=" $( cd " ${execroot_path} " && pwd -P) /"
4345else
4446 echo >&2 " ERROR: could not find clang; PWD=\" ${PWD} \" ; PATH=\" ${PATH} \" ."
4547 exit 5
@@ -53,6 +55,9 @@ function sanitize_option() {
5355 # shellcheck disable=SC2206
5456 parts=(${opt/ =/ } ) # Split flag name and value into array.
5557 printf " %s" " ${parts[0]} =${execroot_path}${parts[1]} "
58+ elif [[ ${opt} == * " \$ {{pwd}}" * ]]; then
59+ # Replace the literal string '${{pwd}}' with the execroot.
60+ printf " %s" " ${opt// \$\{\{ pwd\}\} / ${execroot_abs_path%/ } } "
5661 else
5762 printf " %s" " ${opt} "
5863 fi
Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments