From 94caff1a804ce81e391fbe2689c9042cbba7249c Mon Sep 17 00:00:00 2001 From: Parker Timmerman Date: Sun, 5 Jan 2025 22:35:27 -0500 Subject: [PATCH] start, spill expanded command line options from a response file, back into a response file --- toolchain/cc_wrapper.sh.tpl | 9 +++++++-- toolchain/osx_cc_wrapper.sh.tpl | 7 ++++++- 2 files changed, 13 insertions(+), 3 deletions(-) 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