diff --git a/utils/bazel/llvm-project-overlay/mlir/BUILD.bazel b/utils/bazel/llvm-project-overlay/mlir/BUILD.bazel --- a/utils/bazel/llvm-project-overlay/mlir/BUILD.bazel +++ b/utils/bazel/llvm-project-overlay/mlir/BUILD.bazel @@ -620,20 +620,22 @@ ], ) +MLIR_PYTHON_BINDINGS_SOURCES = [ + "lib/Bindings/Python/DialectLinalg.cpp", + "lib/Bindings/Python/DialectSparseTensor.cpp", + "lib/Bindings/Python/IRAffine.cpp", + "lib/Bindings/Python/IRAttributes.cpp", + "lib/Bindings/Python/IRCore.cpp", + "lib/Bindings/Python/IRInterfaces.cpp", + "lib/Bindings/Python/IRModule.cpp", + "lib/Bindings/Python/IRTypes.cpp", + "lib/Bindings/Python/Pass.cpp", + "lib/Bindings/Python/PybindUtils.cpp", +] + cc_library( - name = "MLIRBindingsPythonCoreNoCAPI", - srcs = [ - "lib/Bindings/Python/DialectLinalg.cpp", - "lib/Bindings/Python/DialectSparseTensor.cpp", - "lib/Bindings/Python/IRAffine.cpp", - "lib/Bindings/Python/IRAttributes.cpp", - "lib/Bindings/Python/IRCore.cpp", - "lib/Bindings/Python/IRInterfaces.cpp", - "lib/Bindings/Python/IRModule.cpp", - "lib/Bindings/Python/IRTypes.cpp", - "lib/Bindings/Python/Pass.cpp", - "lib/Bindings/Python/PybindUtils.cpp", - ], + name = "MLIRBindingsPythonCore", + srcs = MLIR_PYTHON_BINDINGS_SOURCES, # These flags are needed for pybind11 to work. copts = [ "-fexceptions", @@ -648,14 +650,15 @@ "nobuildkite", # TODO(gcmn): Add support for this target ], deps = [ - ":CAPIAsyncHeaders", - ":CAPIDebugHeaders", - ":CAPIGPUHeaders", - ":CAPIIRHeaders", - ":CAPILinalgHeaders", - ":CAPIRegistrationHeaders", - ":CAPISparseTensorHeaders", - ":MLIRBindingsPythonHeaders", + ":CAPIAsync", + ":CAPIDebug", + ":CAPIGPU", + ":CAPIIR", + ":CAPIInterfaces", + ":CAPILinalg", + ":CAPIRegistration", + ":CAPISparseTensor", + ":MLIRBindingsPythonHeadersAndDeps", "//llvm:Support", "@pybind11", "@python_runtime//:headers", @@ -663,23 +666,38 @@ ) cc_library( - name = "MLIRBindingsPythonCAPIDeps", + name = "MLIRBindingsPythonCoreNoCAPI", + srcs = MLIR_PYTHON_BINDINGS_SOURCES, + # These flags are needed for pybind11 to work. + copts = [ + "-fexceptions", + "-frtti", + ], + features = [ + # Cannot use header_modules (parse_headers feature fails). + "-use_header_modules", + ], tags = [ "manual", # External dependency "nobuildkite", # TODO(gcmn): Add support for this target ], deps = [ - ":CAPIAsync", - ":CAPIDebug", - ":CAPIGPU", - ":CAPIIR", - ":CAPIInterfaces", - ":CAPILinalg", - ":CAPIRegistration", - ":CAPISparseTensor", + ":CAPIAsyncHeaders", + ":CAPIDebugHeaders", + ":CAPIGPUHeaders", + ":CAPIIRHeaders", + ":CAPILinalgHeaders", + ":CAPIRegistrationHeaders", + ":CAPISparseTensorHeaders", + ":MLIRBindingsPythonHeaders", + "//llvm:Support", + "@pybind11", + "@python_runtime//:headers", ], ) +# Target that bundles together the CAPI objects needed for +# MLIRBindingsPythonCoreNoCAPI. cc_library( name = "MLIRBindingsPythonCAPIObjects", tags = [ @@ -698,18 +716,6 @@ ], ) -cc_library( - name = "MLIRBindingsPythonCore", - tags = [ - "manual", # External dependency - "nobuildkite", # TODO(gcmn): Add support for this target - ], - deps = [ - ":MLIRBindingsPythonCAPIDeps", - ":MLIRBindingsPythonCoreNoCAPI", - ], -) - PYBIND11_COPTS = [ "-fexceptions", "-frtti",