diff --git a/tensorflow/setup_llvm.bzl b/tensorflow/setup_llvm.bzl new file mode 100644 index 00000000000..68729b0191c --- /dev/null +++ b/tensorflow/setup_llvm.bzl @@ -0,0 +1,23 @@ +"""TensorFlow workspace initialization. Consult the WORKSPACE on how to use it.""" + +load("@llvm-bazel//:terminfo.bzl", "llvm_terminfo_disable") +load("@llvm-bazel//:zlib.bzl", "llvm_zlib_disable") +load("@llvm-bazel//:configure.bzl", "llvm_configure") + +def setup_llvm(): + # Disable terminfo and zlib that are bundled with LLVM + llvm_terminfo_disable( + name = "llvm_terminfo", + ) + llvm_zlib_disable( + name = "llvm_zlib", + ) + + # Now that all LLVM settings are loaded, configure the LLVM project. + # This mixes llvm-bazel and llvm-project-raw to create llvm-project. + # The result has both the source code and the BUILD files in one place. + llvm_configure( + name = "llvm-project", + src_path = ".", + src_workspace = "@llvm-project-raw//:WORKSPACE", + ) diff --git a/third_party/llvm-bazel.patch b/third_party/llvm-bazel.patch new file mode 100644 index 00000000000..8917fe5f910 --- /dev/null +++ b/third_party/llvm-bazel.patch @@ -0,0 +1,15 @@ +diff --git a/llvm-project-overlay/llvm/BUILD b/llvm-project-overlay/llvm/BUILD +index 9f1d8c339..e1ab25e88 100644 +--- a/llvm-project-overlay/llvm/BUILD ++++ b/llvm-project-overlay/llvm/BUILD +@@ -1730,6 +1730,10 @@ gentbl( + srcs = ["lib/Target/" + target["name"] + "/TargetInfo/" + target["name"] + "TargetInfo.cpp"], + hdrs = glob(["lib/Target/" + target["name"] + "/TargetInfo/*.h"]), + copts = llvm_copts, ++ # Workaround for https://github.com/bazelbuild/bazel/issues/3828 ++ # TODO(gcmn): Remove this when upgrading to a Bazel version containing ++ # https://github.com/bazelbuild/bazel/commit/e3b7e17b05f1 ++ includes = ["lib/Target/" + target["name"]], + strip_include_prefix = "lib/Target/" + target["name"], + deps = [ + ":" + target["name"] + "CommonTableGen", diff --git a/third_party/llvm-project/BUILD.bazel b/third_party/llvm-project/BUILD.bazel new file mode 100644 index 00000000000..92ff4516559 --- /dev/null +++ b/third_party/llvm-project/BUILD.bazel @@ -0,0 +1 @@ +# Empty BUILD file for integrating LLVM.