Move iree/compiler to top-level compiler/. (#9022)
* Source files are clean renames (no changes).
* CMake files should be mostly clean renames (just a changed comment about the file path in each).
* Several bazel fixes. Mainly introducing trampoline macros iree_compiler_cc_library, iree_gentbl_cc_library, iree_td_library that inject appropriate includes and deps. And platform_trampoline_deps now takes a repo relative package (vs an //iree relative).
* Uses the CMake "defs" library as done in samples. This is a bit different/better than what was done for runtime/, so I also fixed that one to be the same. So we now have implicit iree::compiler::defs, iree::runtime::defs and iree::samples::defs targets that do the right thing if depended on.
* Re-rigs some absolute paths in the iree-compiler python package build and gets that working in the new layout.
* All deep BUILD files (below iree/compiler/src) were updated with just a combination of sed commands followed by a buildifier fix to clean everything up. I didn't manually tweak any of them (with the exception of the platform_trampoline_deps change mentioned above, in one place).
* Also removes some obsolete "non_darwin" bazelrc thing. I'm not sure why it started yelling at me now (about some bad flag/packages). Folks may need to manually remove those lines from their configured.bazelrc or rerun configure_bazel.py.
diff --git a/build_tools/bazel/build_core.sh b/build_tools/bazel/build_core.sh
index ddc3e9d..a3101a3 100755
--- a/build_tools/bazel/build_core.sh
+++ b/build_tools/bazel/build_core.sh
@@ -82,7 +82,6 @@
--noworkspace_rc \
--bazelrc=build_tools/bazel/iree.bazelrc \
query \
- --config=non_darwin \
//iree/... + //runtime/... + //samples/... + //build_tools/... + \
//llvm-external-projects/iree-dialects/... | \
xargs --max-args 1000000 --max-chars 1000000 --exit \
@@ -93,7 +92,6 @@
--color=yes \
${test_env_args[@]} \
--config=generic_clang \
- --config=non_darwin \
--build_tag_filters="${BUILD_TAG_FILTERS?}" \
--test_tag_filters="${TEST_TAG_FILTERS?}" \
--keep_going \
diff --git a/build_tools/bazel/iree.bazelrc b/build_tools/bazel/iree.bazelrc
index af5a32b..8cea1b0 100644
--- a/build_tools/bazel/iree.bazelrc
+++ b/build_tools/bazel/iree.bazelrc
@@ -363,10 +363,3 @@
# Assume the newer version and alias to --config=windows
build:msvc --config=msvc2019
build:windows --config=msvc
-
-###############################################################################
-# disable metal stuff for non Darwin platforms
-###############################################################################
-common:non_darwin --deleted_packages=//iree/hal/metal,//iree/hal/metal/registration
-build:non_darwin --test_tag_filters="-driver=metal"
-###############################################################################
diff --git a/build_tools/bazel/iree_tablegen.bzl b/build_tools/bazel/iree_tablegen.bzl
new file mode 100644
index 0000000..fab6562
--- /dev/null
+++ b/build_tools/bazel/iree_tablegen.bzl
@@ -0,0 +1,32 @@
+# Copyright 2020 The IREE Authors
+#
+# Licensed under the Apache License v2.0 with LLVM Exceptions.
+# See https://llvm.org/LICENSE.txt for license information.
+# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+
+load("@llvm-project//mlir:tblgen.bzl", "gentbl_cc_library", "gentbl_filegroup", "td_library")
+
+def iree_tablegen_doc(includes = [], **kwargs):
+ """iree_tablegen_doc() generates documentation from a table definition file.
+
+ This is a simple wrapper over gentbl() so we can differentiate between
+ documentation and others. See gentbl() for details regarding arguments.
+ """
+
+ gentbl_filegroup(includes = includes + [
+ "/compiler/src",
+ ], **kwargs)
+
+def iree_gentbl_cc_library(includes = [], **kwargs):
+ """IREE version of gentbl_cc_library which sets up includes properly."""
+
+ gentbl_cc_library(includes = includes + [
+ "/compiler/src",
+ ], **kwargs)
+
+def iree_td_library(includes = [], **kwargs):
+ """IREE version of td_library."""
+
+ td_library(includes = includes + [
+ "/compiler/src",
+ ], **kwargs)
diff --git a/build_tools/bazel/iree_tablegen_doc.bzl b/build_tools/bazel/iree_tablegen_doc.bzl
deleted file mode 100644
index 6a414d2..0000000
--- a/build_tools/bazel/iree_tablegen_doc.bzl
+++ /dev/null
@@ -1,16 +0,0 @@
-# Copyright 2020 The IREE Authors
-#
-# Licensed under the Apache License v2.0 with LLVM Exceptions.
-# See https://llvm.org/LICENSE.txt for license information.
-# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-
-load("@llvm-project//mlir:tblgen.bzl", "gentbl_filegroup")
-
-def iree_tablegen_doc(*args, **kwargs):
- """iree_tablegen_doc() generates documentation from a table definition file.
-
- This is a simple wrapper over gentbl() so we can differentiate between
- documentation and others. See gentbl() for details regarding arguments.
- """
-
- gentbl_filegroup(*args, **kwargs)
diff --git a/build_tools/bazel_to_cmake/bazel_to_cmake.py b/build_tools/bazel_to_cmake/bazel_to_cmake.py
index a9acae9..217934d 100755
--- a/build_tools/bazel_to_cmake/bazel_to_cmake.py
+++ b/build_tools/bazel_to_cmake/bazel_to_cmake.py
@@ -81,7 +81,7 @@
nargs="+",
help=
"Converts all BUILD files under a root directory (defaults to iree, runtime)",
- default=["iree", "runtime", "samples"])
+ default=["compiler", "iree", "runtime", "samples"])
args = parser.parse_args()
diff --git a/build_tools/bazel_to_cmake/bazel_to_cmake_converter.py b/build_tools/bazel_to_cmake/bazel_to_cmake_converter.py
index 93d485b..d2e5ff6 100644
--- a/build_tools/bazel_to_cmake/bazel_to_cmake_converter.py
+++ b/build_tools/bazel_to_cmake/bazel_to_cmake_converter.py
@@ -289,7 +289,7 @@
# TODO(gcmn) implement these types of functions in a less hard-coded way
def platform_trampoline_deps(self, basename, path="base"):
- return [f"//iree/{path}/internal:{basename}_internal"]
+ return [f"//{path}/internal:{basename}_internal"]
def select(self, d):
self._convert_unimplemented_function("select", str(d))
@@ -333,6 +333,9 @@
f"{testonly_block}"
f" PUBLIC\n)\n\n")
+ def iree_compiler_cc_library(self, deps=[], **kwargs):
+ self.cc_library(deps=deps + ["//compiler/src:defs"], **kwargs)
+
def iree_runtime_cc_library(self, deps=[], **kwargs):
self.cc_library(deps=deps + ["//runtime/src:runtime_defines"], **kwargs)
@@ -507,6 +510,11 @@
f"{tblgen_block}"
f")\n\n")
+ def iree_gentbl_cc_library(self, **kwargs):
+ # The bazel version of this rule adds some include directories and defs
+ # that are implicitly handled by the cmake version.
+ self.gentbl_cc_library(**kwargs)
+
def iree_tablegen_doc(self,
name,
tblgen,
diff --git a/build_tools/bazel_to_cmake/bazel_to_cmake_targets.py b/build_tools/bazel_to_cmake/bazel_to_cmake_targets.py
index 32a572a..f49a0a4 100644
--- a/build_tools/bazel_to_cmake/bazel_to_cmake_targets.py
+++ b/build_tools/bazel_to_cmake/bazel_to_cmake_targets.py
@@ -13,6 +13,7 @@
# Internal utilities to emulate various binary/library options.
"//build_tools:default_linkopts": [],
"//build_tools:dl": ["${CMAKE_DL_LIBS}"],
+ "//compiler/src:defs": [],
"//runtime/src:runtime_defines": [],
# IREE llvm-external-projects
@@ -234,6 +235,12 @@
# IREE root paths map to package names based on explicit rules.
# If changing these, make the corresponding change in iree_macros.cmake
# (iree_package_ns function).
+
+ # Map //compiler/src/iree/(.*) -> iree::\1 (i.e. iree::compiler::\1)
+ m = re.match("^//compiler/src/iree/(.+)", target)
+ if m:
+ return ["iree::" + _convert_bazel_path(m.group(1))]
+
# Map //runtime/src/iree/(.*) -> iree::\1
m = re.match("^//runtime/src/iree/(.+)", target)
if m:
diff --git a/build_tools/cmake/iree_c_module.cmake b/build_tools/cmake/iree_c_module.cmake
index feaadf6..f57ca45 100644
--- a/build_tools/cmake/iree_c_module.cmake
+++ b/build_tools/cmake/iree_c_module.cmake
@@ -75,7 +75,7 @@
"${_TESTONLY_ARG}"
DEPS
# Include paths and options for the runtime sources.
- iree_defs_runtime
+ iree::runtime::defs
)
set(_GEN_TARGET "${_NAME}_gen")
diff --git a/build_tools/cmake/iree_macros.cmake b/build_tools/cmake/iree_macros.cmake
index c205279..debe853 100644
--- a/build_tools/cmake/iree_macros.cmake
+++ b/build_tools/cmake/iree_macros.cmake
@@ -64,9 +64,18 @@
# the corresponding rule in:
# build_tools/bazel_to_cmake/bazel_to_cmake_targets.py
# Some sub-trees form their own roots for package purposes. Rewrite them.
- if(_RELATIVE_PATH MATCHES "^runtime/src/(.*)")
+ if(_RELATIVE_PATH MATCHES "^compiler/src/(.*)")
+ # compiler/src/iree/compiler -> iree/compiler
+ set(_PACKAGE "${CMAKE_MATCH_1}")
+ elseif(_RELATIVE_PATH MATCHES "^compiler/src$")
+ # compiler/src (defs) -> iree::compiler::defs
+ set(_PACKAGE "iree::compiler")
+ elseif(_RELATIVE_PATH MATCHES "^runtime/src/(.*)")
# runtime/src/iree/base -> iree/base
set(_PACKAGE "${CMAKE_MATCH_1}")
+ elseif(_RELATIVE_PATH MATCHES "^runtime/src$")
+ # runtime/src (defs) -> iree::runtime::defs
+ set(_PACKAGE "iree::runtime")
elseif(_RELATIVE_PATH MATCHES "^samples/(.*)")
set(_PACKAGE "iree::samples::${CMAKE_MATCH_1}")
elseif(_RELATIVE_PATH MATCHES "^samples$")
diff --git a/build_tools/cmake/iree_python.cmake b/build_tools/cmake/iree_python.cmake
index 0dc833b..26ee287 100644
--- a/build_tools/cmake/iree_python.cmake
+++ b/build_tools/cmake/iree_python.cmake
@@ -339,7 +339,7 @@
LABELS
${_RULE_LABELS}
PACKAGE_DIRS
- "${IREE_BINARY_DIR}/iree/compiler/python"
+ "${IREE_BINARY_DIR}/compiler/bindings/python"
"${IREE_BINARY_DIR}/runtime/bindings/python"
GENERATED_IN_BINARY_DIR
"${_RULE_GENERATED_IN_BINARY_DIR}"
diff --git a/build_tools/cmake/iree_tablegen_doc.cmake b/build_tools/cmake/iree_tablegen_doc.cmake
index 8099475..b8e6373 100644
--- a/build_tools/cmake/iree_tablegen_doc.cmake
+++ b/build_tools/cmake/iree_tablegen_doc.cmake
@@ -47,7 +47,8 @@
set(_INCLUDE_DIRS
"${MLIR_INCLUDE_DIRS}"
- "${IREE_SOURCE_DIR}"
+ "${IREE_SOURCE_DIR}/compiler/src"
+ "${IREE_BINARY_DIR}/compiler/src"
)
list(APPEND _INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR})
list(TRANSFORM _INCLUDE_DIRS PREPEND "-I")
diff --git a/build_tools/cmake/iree_tablegen_library.cmake b/build_tools/cmake/iree_tablegen_library.cmake
index bd728f8..a621530 100644
--- a/build_tools/cmake/iree_tablegen_library.cmake
+++ b/build_tools/cmake/iree_tablegen_library.cmake
@@ -35,7 +35,8 @@
set(LLVM_TARGET_DEFINITIONS ${_RULE_TD_FILE})
set(_INCLUDE_DIRS
"${MLIR_INCLUDE_DIRS}"
- "${IREE_SOURCE_DIR}"
+ "${IREE_SOURCE_DIR}/compiler/src"
+ "${IREE_BINARY_DIR}/compiler/src"
)
list(APPEND _INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR})
list(TRANSFORM _INCLUDE_DIRS PREPEND "-I")
diff --git a/build_tools/python_deploy/build_linux_packages.sh b/build_tools/python_deploy/build_linux_packages.sh
index 33dcbad..be5096f 100755
--- a/build_tools/python_deploy/build_linux_packages.sh
+++ b/build_tools/python_deploy/build_linux_packages.sh
@@ -32,7 +32,7 @@
#
# Note that this script is meant to be run on CI and it will pollute both the
# output directory and in-tree build/ directories (under runtime/ and
-# iree/compiler/) with docker created, root owned builds. Sorry - there is
+# compiler/) with docker created, root owned builds. Sorry - there is
# no good way around it.
#
# It can be run on a workstation but recommend using a git worktree dedicated
@@ -126,7 +126,7 @@
function build_iree_compiler() {
IREE_TARGET_BACKEND_CUDA=ON \
- python -m pip wheel -v -w /wheelhouse /main_checkout/iree/iree/compiler/
+ python -m pip wheel -v -w /wheelhouse /main_checkout/iree/compiler/
}
function run_audit_wheel() {
diff --git a/build_tools/python_deploy/build_macos_packages.sh b/build_tools/python_deploy/build_macos_packages.sh
index 8204470..d9af801 100755
--- a/build_tools/python_deploy/build_macos_packages.sh
+++ b/build_tools/python_deploy/build_macos_packages.sh
@@ -94,7 +94,7 @@
}
function build_iree_compiler() {
- python3 -m pip wheel -v -w $output_dir $repo_root/iree/compiler/
+ python3 -m pip wheel -v -w $output_dir $repo_root/compiler/
}
function clean_wheels() {