From fc24e1c262a4f45787d129ebb73ccc7060481152 Mon Sep 17 00:00:00 2001 From: Andreas Herrmann Date: Wed, 3 Mar 2021 12:47:22 +0100 Subject: [PATCH 1/2] osx_cc_wrapper: Only expand existing response files Not all arguments starting with `@` represent response files, e.g. `-install_name @rpath/...` or `-Xlinker -rpath -Xlinker @loader_path/...`. With this change `osx_cc_wrapper` will only interpret arguments starting with `@` as response files if the corresponding file exists and is readable. This is analogous to the behavior defined in `wrapped_clang.cc`. See https://github.com/bazelbuild/bazel/pull/13044#issuecomment-783539568 for discussion. --- tools/cpp/osx_cc_wrapper.sh | 2 +- tools/cpp/osx_cc_wrapper.sh.tpl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/cpp/osx_cc_wrapper.sh b/tools/cpp/osx_cc_wrapper.sh index 8c9c111a750587..7c9702bd2bf8a7 100755 --- a/tools/cpp/osx_cc_wrapper.sh +++ b/tools/cpp/osx_cc_wrapper.sh @@ -53,7 +53,7 @@ function parse_option() { # let parse the option list for i in "$@"; do - if [[ "$i" = @* ]]; then + if [[ "$i" = @* && "${i:1}" ]]; then while IFS= read -r opt do parse_option "$opt" diff --git a/tools/cpp/osx_cc_wrapper.sh.tpl b/tools/cpp/osx_cc_wrapper.sh.tpl index 28bd47ba1a4a97..25ed2ece8e8b4e 100644 --- a/tools/cpp/osx_cc_wrapper.sh.tpl +++ b/tools/cpp/osx_cc_wrapper.sh.tpl @@ -52,7 +52,7 @@ function parse_option() { # let parse the option list for i in "$@"; do - if [[ "$i" = @* ]]; then + if [[ "$i" = @* && -r "${i:1}" ]]; then while IFS= read -r opt do parse_option "$opt" From 7acc8f332119e3b090ab0aac207632a23c31c0d1 Mon Sep 17 00:00:00 2001 From: Andreas Herrmann Date: Wed, 3 Mar 2021 18:20:31 +0100 Subject: [PATCH 2/2] Update tools/cpp/osx_cc_wrapper.sh Co-authored-by: Keith Smiley --- tools/cpp/osx_cc_wrapper.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/cpp/osx_cc_wrapper.sh b/tools/cpp/osx_cc_wrapper.sh index 7c9702bd2bf8a7..bd8f12f26a9747 100755 --- a/tools/cpp/osx_cc_wrapper.sh +++ b/tools/cpp/osx_cc_wrapper.sh @@ -53,7 +53,7 @@ function parse_option() { # let parse the option list for i in "$@"; do - if [[ "$i" = @* && "${i:1}" ]]; then + if [[ "$i" = @* && -r "${i:1}" ]]; then while IFS= read -r opt do parse_option "$opt"