Skip to content

Bazel-inside-Cmake breaks Bazel interactive builds #4480

Closed

Description

@GMNGeoffrey

Describe the bug
A clear and concise description of what the bug is.

To Reproduce
Steps to reproduce the behavior:

# from iree git directory
$ USE_CLANG=OFF USE_CLANGCPP=OFF python3 ./build_tools/cmake/cmake_ci.py \
  -B ~/build/iree/tf-main \
  -DCMAKE_INSTALL_PREFIX=~/install/iree/tf-main \
  -DCMAKE_BUILD_TYPE=Release \
  -DIREE_BUILD_SAMPLES=OFF \
  -DIREE_BUILD_PYTHON_BINDINGS=ON \
  -DIREE_BUILD_TENSORFLOW_COMPILER=OFF \
  -DIREE_BUILD_TFLITE_COMPILER=OFF \
  -DIREE_BUILD_XLA_COMPILER=ON
$ python3 ./build_tools/cmake/cmake_ci.py --build ~/build/iree/tf-main --target install
$ bazel build --nobuild ...
INFO: Invocation ID: e0b482c8-1b27-4da8-918a-cc9a1e13e5fa
ERROR: infinite symlink expansion detected
[start of symlink chain]
/usr/local/google/home/gcmn/build/iree/xla-main/bazel-out/execroot/iree_core/bazel-out/k8-opt/bin/bin
/usr/local/google/home/gcmn/build/iree/xla-main/bazel-out/execroot/iree_core/bazel-out/k8-opt/bin
[end of symlink chain]
ERROR: Infinite symlink expansion, for bazel-bin/bin, skipping: Infinite symlink expansion
ERROR: infinite symlink expansion detected
[start of symlink chain]
/usr/local/google/home/gcmn/build/iree/xla-main/bazel-out/execroot/iree_core/bazel-out/bazel-out
/usr/local/google/home/gcmn/build/iree/xla-main/bazel-out/execroot/iree_core/bazel-out
[end of symlink chain]
ERROR: Infinite symlink expansion, for bazel-out/bazel-out, skipping: Infinite symlink expansion
INFO: Repository rules_cc instantiated at:
  /usr/local/google/home/gcmn/src/iree/WORKSPACE:243:16: in <toplevel>
  /usr/local/google/home/gcmn/.cache/bazel/_bazel_gcmn/25237b3cb6ed89ec2682e30983e9ed82/external/org_tensorflow/tensorflow/workspace.bzl:1001:20: in tf_repositories
Repository rule tf_http_archive defined at:
  /usr/local/google/home/gcmn/.cache/bazel/_bazel_gcmn/25237b3cb6ed89ec2682e30983e9ed82/external/org_tensorflow/third_party/repo.bzl:131:34: in <toplevel>
ERROR: error loading package 'bazel-out/install/embedded_tools/tools/cpp': in /usr/local/google/home/gcmn/src/iree/bazel-out/install/embedded_tools/tools/cpp/compiler_flag.bzl: Label '//tools/cpp:toolchain_utils.bzl' is invalid because 'tools/cpp' is not a package; perhaps you meant to put the colon here: '//:tools/cpp/toolchain_utils.bzl'?
INFO: Elapsed time: 1.448s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (12 packages loaded)
    currently loading: bazel-out/install/embedded_tools/tools/objc ... (4 packages)

Note that the directory symlinks still point to the weird output base

$ ll bazel-*
lrwxrwxrwx 1 gcmn primarygroup  97 Jan 11 19:34 bazel-bin -> /usr/local/google/home/gcmn/build/iree/xla-main/bazel-out/execroot/iree_core/bazel-out/k8-opt/bin/
lrwxrwxrwx 1 gcmn primarygroup  76 Jan 11 19:34 bazel-iree -> /usr/local/google/home/gcmn/build/iree/xla-main/bazel-out/execroot/iree_core/
lrwxrwxrwx 1 gcmn primarygroup  86 Jan 11 19:34 bazel-out -> /usr/local/google/home/gcmn/build/iree/xla-main/bazel-out/execroot/iree_core/bazel-out/
lrwxrwxrwx 1 gcmn primarygroup 102 Jan 11 19:34 bazel-testlogs -> /usr/local/google/home/gcmn/build/iree/xla-main/bazel-out/execroot/iree_core/bazel-out/k8-opt/testlogs/
$ rm bazel-* # or `bazel clean`
$ bazel build --nobuild ...
...
INFO: Build completed successfully, 0 total actions

I think this has something to do with setting --output_base in the invocation. Bazel has latched on to that part and is still looking in those directories.

Shortly I'll be changing things around so we're actually doing the bazel build from integrations/tensorflow, but I still hit the issue.

Activity

  1. added
    bug 🐞
    integrations/tensorflow
    on Jan 12, 2021
  2. GMNGeoffrey commented on Jan 12, 2021

    @GMNGeoffrey
    MemberAuthor

    I think this might actually be as simple as --output_base shouldn't end in bazel-out. The default is just some hash under user root. There are like a million directories in the output tree, so understandable to have messed it up 😁. I'll try out some things in a bit

  3. stellaraccident commented on Jan 12, 2021

    @stellaraccident
    Collaborator

    Is it creating symlinks in the source tree? It shouldn't be... Of course, bazel has a ridiculous way to say don't mess up the source tree. Probably need one of these flags: https://stackoverflow.com/questions/47018499/bazel-i-want-to-avoid-all-the-convenience-symlinks-to-be-generated

  4. stellaraccident commented on Jan 12, 2021

    @stellaraccident
    Collaborator

    I imagine this will eliminate the ability for these things to interfere: #4481

    Feel free to pull the one liner into your change or submit separately. Whichever helps.

  5. stellaraccident commented on Jan 12, 2021

    @stellaraccident
    Collaborator

    With the above, this worked: bazel build --nobuild iree/tools/... (just building ... from the root seems to have other unrelated problems)

  6. GMNGeoffrey commented on Jan 12, 2021

    @GMNGeoffrey
    MemberAuthor

    Ah didn't realize you weren't trying to have symlinks there. A lot of the naming conventions in that file specifically conflict with some Bazel's naming, which was confusing :-) (e.g. we have both "bazel-bin" and "bazel-out" in there that don't mean the symlinks that I'm used to seeing)

  7. stellaraccident commented on Jan 12, 2021

    @stellaraccident
    Collaborator

    Yeah, first rule of bazel automation is to set up the output base independently and then query bazel for its locations instead of using the symlinks. Just didn't realize such a basic thing would be so broken. This usage gets a lot of mileage in Google, but I don't think bazel sees a lot of diverse usage.

  8. GMNGeoffrey commented on Jan 12, 2021

    @GMNGeoffrey
    MemberAuthor

    I've incorporated your changes into my TF split PR, since I'm changing a few related things in that file as well. Thanks for the help! I still don't actually understand where the circular symlinks come from, but at least now they don't seem to affect anything :-D

  9. added
    infrastructure
    on May 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bug 🐞infrastructureintegrations/tensorflow

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions