Skip to content

Commit

Permalink
Add explicit -sdk argument to xcrun calls
Browse files Browse the repository at this point in the history
Xcode 11 (and possibly earlier versions) has a bug where, when you don't
pass `-sdk macosx`, it can either pick the global
`/Library/Developer/CommandLineTools` SDK path, or the SDK path bundled
within Xcode itself. This seems to depend on if you have other versions
of Xcode installed, and which versions of the command line tools you
have installed. Passing `-sdk macosx` seems to always force it to pick
the Xcode bundled version, which is what we prefer. This fixes issues
with remote cache misses caused by these tools not being the same
because of this difference.

You can see which path it's picking by running:

```
env -i xcrun -l -n clang
```
  • Loading branch information
keith committed Sep 11, 2019
1 parent 9ce145a commit f867852
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/tools/xcode/realpath/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ genrule(
name = "realpath_genrule",
srcs = ["realpath.c"],
outs = ["realpath"],
cmd = "/usr/bin/xcrun clang -o $@ $<",
cmd = "/usr/bin/xcrun -sdk macosx clang -o $@ $<",
output_to_bindir = 1,
visibility = ["//visibility:public"],
)
Expand Down
2 changes: 2 additions & 0 deletions tools/cpp/osx_cc_configure.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ def configure_osx_toolchain(repository_ctx, overriden_tools):
"env",
"-i",
"xcrun",
"-sdk",
"macosx",
"clang",
"-std=c++11",
"-lc++",
Expand Down
2 changes: 1 addition & 1 deletion tools/osx/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ exports_files([
])

DARWIN_XCODE_LOCATOR_COMPILE_COMMAND = """
/usr/bin/xcrun clang -fobjc-arc -framework CoreServices \
/usr/bin/xcrun -sdk macosx clang -fobjc-arc -framework CoreServices \
-framework Foundation -o $@ $<
"""

Expand Down
2 changes: 2 additions & 0 deletions tools/osx/xcode_configure.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ def run_xcode_locator(repository_ctx, xcode_locator_src_label):
"env",
"-i",
"xcrun",
"-sdk",
"macosx",
"clang",
"-fobjc-arc",
"-framework",
Expand Down

0 comments on commit f867852

Please sign in to comment.