Skip to content

Commit efb2b80

Browse files
aherrmanncopybara-github
authored andcommitted
osx_cc_wrapper: Only expand existing response files
Closes bazelbuild#13044 Applies the changes suggested in bazelbuild#13044 (comment) Not all arguments starting with `@` represent response files, e.g. `-install_name @rpath/...` or `-Xlinker -rpath -Xlinker @loader_path/...` do not refer to response files and attempting to read them as such will fail the build. Users don't always have control over these arguments, meaning transforming them to `-Wl,-install_name,@rpath/...` or `-Wl,-rpath,@loader_path/...` is not always an option. E.g. as described in bazelbuild#13044 (comment) where these flags are emitted by the Haskell compiler GHC (see bazelbuild#13044 (comment) for their reasoning). 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 bazelbuild#13044 (comment) for discussion. Closes bazelbuild#13148. PiperOrigin-RevId: 436207868
1 parent 7812bdc commit efb2b80

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

tools/cpp/osx_cc_wrapper.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ function parse_option() {
5353

5454
# let parse the option list
5555
for i in "$@"; do
56-
if [[ "$i" = @* ]]; then
56+
if [[ "$i" = @* && -r "${i:1}" ]]; then
5757
while IFS= read -r opt
5858
do
5959
parse_option "$opt"

tools/cpp/osx_cc_wrapper.sh.tpl

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ function parse_option() {
5252

5353
# let parse the option list
5454
for i in "$@"; do
55-
if [[ "$i" = @* ]]; then
55+
if [[ "$i" = @* && -r "${i:1}" ]]; then
5656
while IFS= read -r opt
5757
do
5858
parse_option "$opt"

0 commit comments

Comments
 (0)