Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions utils/bazel/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,14 @@ load("@llvm-raw//utils/bazel:configure.bzl", "llvm_configure")

llvm_configure(name = "llvm-project")

maybe(
http_archive,
name = "rules_python",
sha256 = "778aaeab3e6cfd56d681c89f5c10d7ad6bf8d2f1a72de9de55b23081b2d31618",
strip_prefix = "rules_python-0.34.0",
url = "https://github.com/bazelbuild/rules_python/releases/download/0.34.0/rules_python-0.34.0.tar.gz",
)

maybe(
http_archive,
name = "llvm_zlib",
Expand Down Expand Up @@ -129,3 +137,21 @@ maybe(
"https://github.com/facebook/zstd/releases/download/v1.5.2/zstd-1.5.2.tar.gz",
],
)

maybe(
http_archive,
name = "pybind11",
build_file = "@llvm-raw//utils/bazel/third_party_build:pybind.BUILD",
sha256 = "201966a61dc826f1b1879a24a3317a1ec9214a918c8eb035be2f30c3e9cfbdcb",
strip_prefix = "pybind11-2.10.3",
url = "https://github.com/pybind/pybind11/archive/v2.10.3.zip",
)

load("@rules_python//python:repositories.bzl", "py_repositories", "python_register_toolchains")

py_repositories()

python_register_toolchains(
name = "python_3_12",
python_version = "3.12",
)
73 changes: 6 additions & 67 deletions utils/bazel/llvm-project-overlay/mlir/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -918,19 +918,6 @@ exports_files(
glob(["lib/Bindings/Python/**/*.cpp"]),
)

# In the targets related to Python bindings, the projects @pybind11 and
# @local_config_python are defined by @pybind11_bazel. The latter contains
# python headers, and can be configured in an out-of-tree bazel project via
#
# load("@pybind11_bazel//:python_configure.bzl", "python_configure")
# python_configure(name = "local_config_python")
#
# For more up-to-date instructions, see
# https://github.com/pybind/pybind11_bazel
#
# Some out-of-tree projects alias @python_runtime//:headers to
# @local_config_python//:python_headers.

filegroup(
name = "MLIRBindingsPythonHeaderFiles",
srcs = glob([
Expand All @@ -946,16 +933,12 @@ cc_library(
"include",
"lib/Bindings/Python",
],
tags = [
"manual", # External dependency
"nobuildkite", # TODO(gcmn): Add support for this target
],
textual_hdrs = [":MLIRBindingsPythonHeaderFiles"],
deps = [
":CAPIIRHeaders",
":CAPITransformsHeaders",
"@local_config_python//:python_headers",
"@pybind11",
"@rules_python//python/cc:current_py_cc_headers",
],
)

Expand All @@ -965,16 +948,12 @@ cc_library(
"include",
"lib/Bindings/Python",
],
tags = [
"manual", # External dependency
"nobuildkite", # TODO(gcmn): Add support for this target
],
textual_hdrs = [":MLIRBindingsPythonHeaderFiles"],
deps = [
":CAPIIR",
":CAPITransforms",
"@local_config_python//:python_headers",
"@pybind11",
"@rules_python//python/cc:current_py_cc_headers",
],
)

Expand Down Expand Up @@ -1008,10 +987,6 @@ cc_library(
srcs = [":MLIRBindingsPythonSourceFiles"],
copts = PYBIND11_COPTS,
features = PYBIND11_FEATURES,
tags = [
"manual", # External dependency
"nobuildkite", # TODO(gcmn): Add support for this target
],
deps = [
":CAPIAsync",
":CAPIDebug",
Expand All @@ -1021,8 +996,8 @@ cc_library(
":Support",
":config",
"//llvm:Support",
"@local_config_python//:python_headers",
"@pybind11",
"@rules_python//python/cc:current_py_cc_headers",
],
)

Expand All @@ -1031,10 +1006,6 @@ cc_library(
srcs = [":MLIRBindingsPythonSourceFiles"],
copts = PYBIND11_COPTS,
features = PYBIND11_FEATURES,
tags = [
"manual", # External dependency
"nobuildkite", # TODO(gcmn): Add support for this target
],
deps = [
":CAPIAsyncHeaders",
":CAPIDebugHeaders",
Expand All @@ -1043,19 +1014,15 @@ cc_library(
":Support",
":config",
"//llvm:Support",
"@local_config_python//:python_headers",
"@pybind11",
"@rules_python//python/cc:current_py_cc_headers",
],
)

# Target that bundles together the CAPI objects needed for
# MLIRBindingsPythonCoreNoCAPI.
cc_library(
name = "MLIRBindingsPythonCAPIObjects",
tags = [
"manual", # External dependency
"nobuildkite", # TODO(gcmn): Add support for this target
],
deps = [
":CAPIAsyncObjects",
":CAPIDebugObjects",
Expand All @@ -1074,10 +1041,6 @@ cc_binary(
features = PYBIND11_FEATURES,
linkshared = 1,
linkstatic = 0,
tags = [
"manual", # External dependency
"nobuildkite", # TODO(gcmn): Add support for this target
],
deps = [
":MLIRBindingsPythonCore",
":MLIRBindingsPythonHeadersAndDeps",
Expand All @@ -1091,10 +1054,6 @@ cc_binary(
features = PYBIND11_FEATURES,
linkshared = 1,
linkstatic = 0,
tags = [
"manual", # External dependency
"nobuildkite", # TODO(gcmn): Add support for this target
],
deps = [
":CAPIIR",
":CAPILinalg",
Expand All @@ -1109,10 +1068,6 @@ cc_binary(
features = PYBIND11_FEATURES,
linkshared = 1,
linkstatic = 0,
tags = [
"manual", # External dependency
"nobuildkite",
],
deps = [
":CAPIIR",
":CAPILLVM",
Expand All @@ -1128,10 +1083,6 @@ cc_binary(
features = PYBIND11_FEATURES,
linkshared = 1,
linkstatic = 0,
tags = [
"manual", # External dependency
"nobuildkite", # TODO(gcmn): Add support for this target
],
deps = [
":CAPIIR",
":CAPIQuant",
Expand All @@ -1147,10 +1098,6 @@ cc_binary(
features = PYBIND11_FEATURES,
linkshared = 1,
linkstatic = 0,
tags = [
"manual", # External dependency
"nobuildkite", # TODO(gcmn): Add support for this target
],
deps = [
":CAPIIR",
":CAPISparseTensor",
Expand All @@ -1167,15 +1114,11 @@ cc_binary(
features = PYBIND11_FEATURES,
linkshared = 1,
linkstatic = 0,
tags = [
"manual", # External dependency
"nobuildkite", # TODO(gcmn): Add support for this target
],
deps = [
":CAPIExecutionEngine",
":MLIRBindingsPythonHeadersAndDeps",
"@local_config_python//:python_headers",
"@pybind11",
"@rules_python//python/cc:current_py_cc_headers",
],
)

Expand All @@ -1187,15 +1130,11 @@ cc_binary(
features = PYBIND11_FEATURES,
linkshared = 1,
linkstatic = 0,
tags = [
"manual", # External dependency
"nobuildkite", # TODO(gcmn): Add support for this target
],
deps = [
":CAPILinalg",
":MLIRBindingsPythonHeadersAndDeps",
"@local_config_python//:python_headers",
"@pybind11",
"@rules_python//python/cc:current_py_cc_headers",
],
)

Expand Down
15 changes: 15 additions & 0 deletions utils/bazel/third_party_build/pybind.BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
cc_library(
name = "pybind11",
hdrs = glob(
include = ["include/pybind11/**/*.h"],
exclude = [
# Deprecated file that just emits a warning
"include/pybind11/common.h",
],
),
includes = ["include"],
visibility = ["//visibility:public"],
deps = [
"@rules_python//python/cc:current_py_cc_headers",
],
)