diff --git a/toolchain/cc_wrapper.sh.tpl b/toolchain/cc_wrapper.sh.tpl index e972d57e6..fb915b421 100644 --- a/toolchain/cc_wrapper.sh.tpl +++ b/toolchain/cc_wrapper.sh.tpl @@ -60,14 +60,19 @@ function sanitize_option() { cmd=() for ((i = 0; i <= $#; i++)); do - if [[ ${!i} == @* ]]; then + if [[ ${!i} == @* && -r "${i:1}" ]]; then + # Create a temporary file that we'll spill sanitized options to since they + # were originally read from a response file. + temp_file=$(mktemp) + while IFS= read -r opt; do opt="$( set -e sanitize_option "${opt}" )" - cmd+=("${opt}") + echo "${opt}" >> "${temp_file}" done <"${!i:1}" + mv "${temp_file}" "${!i:1}" else opt="$( set -e diff --git a/toolchain/osx_cc_wrapper.sh.tpl b/toolchain/osx_cc_wrapper.sh.tpl index 31122784b..33ae915e3 100755 --- a/toolchain/osx_cc_wrapper.sh.tpl +++ b/toolchain/osx_cc_wrapper.sh.tpl @@ -87,6 +87,10 @@ function sanitize_option() { cmd=() for ((i = 0; i <= $#; i++)); do if [[ ${!i} == @* && -r "${i:1}" ]]; then + # Create a temporary file that we'll spill sanitized options to since they + # were originally read from a response file. + temp_file=$(mktemp) + while IFS= read -r opt; do if [[ ${opt} == "-fuse-ld=ld64.lld" ]]; then cmd+=("-fuse-ld=lld") @@ -96,8 +100,9 @@ for ((i = 0; i <= $#; i++)); do sanitize_option "${opt}" )" parse_option "${opt}" - cmd+=("${opt}") + echo "${opt}" >> "${temp_file}" done <"${!i:1}" + mv "${temp_file}" "${!i:1}" else opt="$( set -e