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

Bazel use tbb as a external dependency has a “Make” Variables not defined error about tbb.BUILD #5

Open
yuandcc opened this issue Sep 25, 2020 · 2 comments

Comments

@yuandcc
Copy link

yuandcc commented Sep 25, 2020

Hello, when I use bazel build my project, I had a error "ERROR: external/tbb/BUILD.bazel:11:1: in cmd attribute of genrule rule @tbb//:build_tbb: $(AR) not defined". I try the update the tbb.BUILD follow the #2, but it not work. The details is in https://stackoverflow.com/questions/64022414/ . Do you know how can I set up it work? Thanks!

@yuandcc yuandcc changed the title Bazel use tensorflow ( or only use tbb) as a external dependency has a “Make” Variables not defined error about tbb.BUILD Bazel use tbb as a external dependency has a “Make” Variables not defined error about tbb.BUILD Sep 25, 2020
@rnburn
Copy link
Owner

rnburn commented Sep 25, 2020

Try replacing it with this version

genrule(
  name = "build_tbb",
  srcs = glob(["**"]) + [
    "@local_config_cc//:toolchain",
  ],
  cmd = """
         set -e
         WORK_DIR=$$PWD
         DEST_DIR=$$PWD/$(@D)
         cd $$(dirname $(location :Makefile))

         #TBB's build needs some help to figure out what compiler it's using
         if $$CXX --version | grep clang &> /dev/null; then 
           COMPILER_OPT="compiler=clang"
         else
           COMPILER_OPT="compiler=gcc"
         fi 

         # uses extra_inc=big_iron.inc to specify that static libraries are
         # built. See https://software.intel.com/en-us/forums/intel-threading-building-blocks/topic/297792
         make tbb_build_prefix="build" \
              extra_inc=big_iron.inc \
              $$COMPILER_OPT; \

         echo cp build/build_release/*.a $$DEST_DIR
         cp build/build_release/*.a $$DEST_DIR
         cd $$WORK_DIR
  """,
  outs = [
    "libtbb.a",
    "libtbbmalloc.a",
  ]  
)

cc_library(
    name = "tbb",
    hdrs = glob([
        "include/serial/**",
        "include/tbb/**/**",
        ]),
    srcs = ["libtbb.a"],
    includes = ["include"],
    visibility = ["//visibility:public"],
)

@yuandcc
Copy link
Author

yuandcc commented Sep 26, 2020

Thank you very much, it's work!
But I still have a question, Tensorflow-2.3.0 still uses the oldest version of tbb.BUILD, but the bazel version they declared in the .bazelversion file is already 3.1.0. Do you think they need to update tbb.BUILD to the latest one you provide ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants