Skip to content

Commit

Permalink
osx_cc_wrapper: Only expand existing response files (bazelbuild#15090)
Browse files Browse the repository at this point in the history
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
(cherry picked from commit efb2b80)

Co-authored-by: Andreas Herrmann <andreash87@gmx.ch>
  • Loading branch information
brentleyjones and aherrmann committed Mar 21, 2022
1 parent 376cd47 commit 48b60d2
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion tools/cpp/osx_cc_wrapper.sh
Expand Up @@ -53,7 +53,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"
Expand Down
2 changes: 1 addition & 1 deletion tools/cpp/osx_cc_wrapper.sh.tpl
Expand Up @@ -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"
Expand Down

0 comments on commit 48b60d2

Please sign in to comment.