Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compatibility with Xcode and Command Line Developer Tools on macOS #5178

Closed
shiltian opened this issue May 9, 2018 · 19 comments
Closed

Compatibility with Xcode and Command Line Developer Tools on macOS #5178

shiltian opened this issue May 9, 2018 · 19 comments
Labels
category: rules > ObjC / iOS / J2ObjC P4 This is either out of scope or we don't have bandwidth to review a PR. (No assignee) z-team-Apple Deprecated. Send to rules_apple, or label team-Rules-CPP + platform:apple

Comments

@shiltian
Copy link

shiltian commented May 9, 2018

Description of the problem / feature request:

As you know, xcode-select is used to select the developer directory on macOS. Both Xcode and Command Line Developer Tools are installed in my Mac. Due to the reason that the compiler Xcode provides seems not to support the OpenMP, I need to switch to the Command Line Developer Tools. I've executed the command sudo xcode-select -s /Library/Developer/CommandLineTools, but when I build with Bazel, it still told me that Xcode version must be specified to use an Apple CROSSTOOL. If your Xcode version has changed recently, try: "bazel clean --expunge" to re-run Xcode configuration. And of course, I've cleaned the workspace and rerun the command, but it was useless.

Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

  1. Install Xcode, and now the active developer directory will be switched to Xcode.
  2. Open the Terminal.app, execute sudo xcode-select -s /Library/Developer/CommandLineTools to switch back to the Command Line Developer Tools.
  3. Build with Bazel.

What operating system are you running Bazel on?

macOS High Sierra 10.13.4

What's the output of bazel info release?

release 0.12.0-homebrew

What's the output of git remote get-url origin ; git rev-parse master ; git rev-parse HEAD ?

Private branch of TensorFlow.

Have you found anything relevant by searching the web?

Nope.

Any other information, logs, or outputs that you want to share?

$ bazel clean --expunge
WARNING: ignoring http_proxy in environment.
INFO: Starting clean.
$ bazel build --copt=-DINTEL_MKL_DNN --config=mkl -c opt //tensorflow/tools/pip_package:build_pip_package
WARNING: ignoring http_proxy in environment.
..............
WARNING: /private/var/tmp/_bazel_shilei/d84c9594019614910b5a52be437fcea4/external/protobuf_archive/WORKSPACE:1: Workspace name in /private/var/tmp/_bazel_shilei/d84c9594019614910b5a52be437fcea4/external/protobuf_archive/WORKSPACE (@com_google_protobuf) does not match the name given in the repository's definition (@protobuf_archive); this will cause a build error in future versions
ERROR: /private/var/tmp/_bazel_shilei/d84c9594019614910b5a52be437fcea4/external/local_config_cc/BUILD:50:5: in apple_cc_toolchain rule @local_config_cc//:cc-compiler-darwin_x86_64: Xcode version must be specified to use an Apple CROSSTOOL. If your Xcode version has changed recently, try: "bazel clean --expunge" to re-run Xcode configuration
ERROR: Analysis of target '//tensorflow/tools/pip_package:build_pip_package' failed; build aborted: Analysis of target '@local_config_cc//:cc-compiler-darwin_x86_64' failed; build aborted
INFO: Elapsed time: 13.244s
FAILED: Build did NOT complete successfully (63 packages loaded)
    currently loading: tensorflow/python ... (2 packages)
$ xcode-select -p
/Library/Developer/CommandLineTools
@shiltian
Copy link
Author

shiltian commented May 9, 2018

In addition, if the Xcode is not installed, Bazel could work well. A same issue occurred before, and I just uninstalled the Xcode, and then it could work.

@sergiocampama
Copy link
Contributor

Are you using VSCode by any chance?

@shiltian
Copy link
Author

shiltian commented May 9, 2018

@sergiocampama Yeap. Anything to do with it?

@sergiocampama
Copy link
Contributor

Check out #4603, it has a long discussion on how VSCode messes up with the workspace. Try running expunge and build after closing VSCode

@shiltian
Copy link
Author

shiltian commented May 9, 2018

@sergiocampama Really?! Unbelievable…Thanks for your notification. I'll try it tomorrow and feedback to you.

@shiltian
Copy link
Author

Hi @sergiocampama I've closed the VSCode, cleaned up the project and tried to build with Bazel, but unfortunately, it failed too with the same error.

@dslomov
Copy link
Contributor

dslomov commented May 14, 2018

@sergiocampama should this be moved to https://github.com/bazelbuild/rules_apple/issues?

@sergiocampama
Copy link
Contributor

@dslomov The xcode locator functionality is provided to rules_apple by bazel. Furthermore, the xcode locator functionality is also depended upon from the C++ rules so they work on macOS. This issue belongs in bazel, not rules_apple.

@shiltian
Copy link
Author

Update: This issue still exists in the the latest released version 0.13.1.

@jin jin added z-team-Apple Deprecated. Send to rules_apple, or label team-Rules-CPP + platform:apple untriaged labels Feb 19, 2019
@jin
Copy link
Member

jin commented Feb 19, 2019

Is this still an issue?

@shiltian
Copy link
Author

@jin No idea. I've moved to new project.

@aragos aragos added P4 This is either out of scope or we don't have bandwidth to review a PR. (No assignee) and removed untriaged labels Feb 21, 2019
@artem-zinnatullin
Copy link
Contributor

I've just hit this on a fresh Bazel clone (bc5a9b1):

~/DesktopDesktop git clone git@github.com:bazelbuild/bazel.git
Cloning into 'bazel'...
remote: Enumerating objects: 157, done.
remote: Counting objects: 100% (157/157), done.
remote: Compressing objects: 100% (82/82), done.
remote: Total 408534 (delta 61), reused 114 (delta 48), pack-reused 408377
Receiving objects: 100% (408534/408534), 651.51 MiB | 57.78 MiB/s, done.
Resolving deltas: 100% (248658/248658), done.
Checking out files: 100% (11232/11232), done.Desktop cd bazelbazel git:(master) bazel build //src:bazel
Starting local Bazel server and connecting to it...
DEBUG: /private/var/tmp/_bazel_azinnatullin/28ee7600c34548f30dad58754d5eebde/external/bazel_toolchains/rules/rbe_repo/checked_in.bzl:103:9: rbe_ubuntu1804_java11 not using checked in configs as detect_java_home was set to True
DEBUG: /private/var/tmp/_bazel_azinnatullin/28ee7600c34548f30dad58754d5eebde/external/bazel_toolchains/rules/rbe_repo/checked_in.bzl:103:9: rbe_ubuntu1604_java8 not using checked in configs as detect_java_home was set to True
ERROR: /private/var/tmp/_bazel_azinnatullin/28ee7600c34548f30dad58754d5eebde/external/local_config_cc/BUILD:62:5: in apple_cc_toolchain rule @local_config_cc//:cc-compiler-armeabi-v7a: Xcode version must be specified to use an Apple CROSSTOOL. If your Xcode version has changed recently, verify that "xcode-select -p" is correct and then try: "bazel shutdown" to re-run Xcode configuration
INFO: Call stack for the definition of repository 'remotejdk11_macos' which is a http_archive (rule definition at /private/var/tmp/_bazel_azinnatullin/28ee7600c34548f30dad58754d5eebde/external/bazel_tools/tools/build_defs/repo/http.bzl:237:16):
 - /DEFAULT.WORKSPACE.SUFFIX:219:1
INFO: Call stack for the definition of repository 'remote_java_tools_darwin' which is a http_archive (rule definition at /private/var/tmp/_bazel_azinnatullin/28ee7600c34548f30dad58754d5eebde/external/bazel_tools/tools/build_defs/repo/http.bzl:237:16):
 - /DEFAULT.WORKSPACE.SUFFIX:255:1
ERROR: Analysis of target '//src:bazel' failed; build aborted: Analysis of target '@local_config_cc//:cc-compiler-armeabi-v7a' failed; build aborted
INFO: Elapsed time: 5.700s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (160 packages loaded, 2040 targets configured)

Environment:

  • macOS 10.14.6
  • Xcode 10.3

I can confirm that I haven't run xcode-select ever, I'm not an iOS/macOS developer and reasons I have Xcode installed is because I played with Swift a bit.

I was able to fix it after some googling:

sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
bazel shutdown
bazel build //src:bazel

It seems that Bazel should be more resistant to system environment like this or this Xcode quirk should be reflected on the Setting up your coding environment page :)

@keith
Copy link
Member

keith commented Jul 24, 2019

This is very easy to reproduce for me:

% xcode-select -p
/Applications/Xcode-11.0.0b4.app/Contents/Developer
% sudo xcode-select -r
% sudo xcode-select -p
/Library/Developer/CommandLineTools
% bazel build src:bazel-dev
Starting local Bazel server and connecting to it...
DEBUG: /private/var/tmp/_bazel_ksmiley/5ef608190b288a339c09ffb210204e7f/external/bazel_toolchains/rules/rbe_repo/checked_in.bzl:103:9: rbe_ubuntu1804_java11 not using checked in configs as detect_java_home was set to True
DEBUG: /private/var/tmp/_bazel_ksmiley/5ef608190b288a339c09ffb210204e7f/external/bazel_toolchains/rules/rbe_repo/checked_in.bzl:103:9: rbe_ubuntu1604_java8 not using checked in configs as detect_java_home was set to True
ERROR: /private/var/tmp/_bazel_ksmiley/5ef608190b288a339c09ffb210204e7f/external/local_config_cc/BUILD:62:5: in apple_cc_toolchain rule @local_config_cc//:cc-compiler-armeabi-v7a: Xcode version must be specified to use an Apple CROSSTOOL. If your Xcode version has changed recently, verify that "xcode-select -p" is correct and then try: "bazel shutdown" to re-run Xcode configuration
INFO: Call stack for the definition of repository 'remote_java_tools_darwin' which is a http_archive (rule definition at /private/var/tmp/_bazel_ksmiley/5ef608190b288a339c09ffb210204e7f/external/bazel_tools/tools/build_defs/repo/http.bzl:237:16):
 - /DEFAULT.WORKSPACE.SUFFIX:255:1
INFO: Call stack for the definition of repository 'remotejdk11_macos' which is a http_archive (rule definition at /private/var/tmp/_bazel_ksmiley/5ef608190b288a339c09ffb210204e7f/external/bazel_tools/tools/build_defs/repo/http.bzl:237:16):
 - /DEFAULT.WORKSPACE.SUFFIX:219:1
ERROR: Analysis of target '//src:bazel-dev' failed; build aborted: Analysis of target '@local_config_cc//:cc-compiler-armeabi-v7a' failed; build aborted
INFO: Elapsed time: 5.521s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (152 packages loaded, 2240 targets configured)
    currently loading: @io_bazel//third_party/grpc ... (3 packages)

@keith
Copy link
Member

keith commented Jul 24, 2019

I've submitted a fix for this #8975

@mariusgrigoriu
Copy link

Best case scenario, the docs are wrong to instruct users to install command line tools and not full Xcode. Can we get the above PR merged?

@mariusgrigoriu
Copy link

Actually, I wonder if bazel 1.1.0 fixes this.

@keith
Copy link
Member

keith commented Nov 20, 2019

Is there a specific change you would have expected to fix this? I haven't seen anything related go in

@mariusgrigoriu
Copy link

I was thinking this change. Seems to work on my machine, but once I got 1.1.0 working, I could no longer repro with 0.28.1, so I'm not sure what's really going on.

bfbaed8

@yaroslav-protsenko-unitq

For those who get to this issue via googling: there is a SO answer that solved the issue for me: https://stackoverflow.com/a/46460129

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category: rules > ObjC / iOS / J2ObjC P4 This is either out of scope or we don't have bandwidth to review a PR. (No assignee) z-team-Apple Deprecated. Send to rules_apple, or label team-Rules-CPP + platform:apple
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants