Move compiler APIs to final locations. (#12554)
* compiler/API/python -> bindings/python
* compiler/API2 -> compiler/API
diff --git a/build_tools/bazel/iree.bazelrc b/build_tools/bazel/iree.bazelrc
index 827036a..d98544c 100644
--- a/build_tools/bazel/iree.bazelrc
+++ b/build_tools/bazel/iree.bazelrc
@@ -37,7 +37,7 @@
# Build settings flag aliases. See https://bazel.build/rules/config
###############################################################################
build --flag_alias=iree_drivers=//runtime/src/iree/hal/drivers:enabled_drivers
-build --flag_alias=iree_link_compiler_shared=//compiler/src/iree/compiler/API2:link_shared
+build --flag_alias=iree_link_compiler_shared=//compiler/src/iree/compiler/API:link_shared
# Equivalent to CMake flag IREE_ENABLE_RUNTIME_TRACING.
# Builds the runtime with tracing support enabled.
build --flag_alias=iree_enable_runtime_tracing=@tracy_client//:runtime_enable
diff --git a/build_tools/cmake/ctest_all.sh b/build_tools/cmake/ctest_all.sh
index b1a2560..720a5b1 100755
--- a/build_tools/cmake/ctest_all.sh
+++ b/build_tools/cmake/ctest_all.sh
@@ -103,7 +103,7 @@
#TODO(#12496): Remove after fixing the test on macOS
"iree/compiler/bindings/c/loader_test"
#TODO(#12496): Remove after fixing the test on macOS
- "iree/compiler/API/python/test/transforms/ireec/compile_sample_module"
+ "iree/compiler/bindings/python/test/transforms/ireec/compile_sample_module"
)
fi
diff --git a/build_tools/scripts/integrate/README.md b/build_tools/scripts/integrate/README.md
index 675369c..a365f6a 100644
--- a/build_tools/scripts/integrate/README.md
+++ b/build_tools/scripts/integrate/README.md
@@ -304,11 +304,11 @@
### Update C-API exported
-If a new symbol needs to be export in the C-API run this [script](https://github.com/openxla/iree/blob/main/compiler/src/iree/compiler/API2/generate_exports.py)
+If a new symbol needs to be export in the C-API run this [script](https://github.com/openxla/iree/blob/main/compiler/src/iree/compiler/API/generate_exports.py)
from IREE root directory:
```
-python compiler/src/iree/compiler/API2/generate_exports.py
+python compiler/src/iree/compiler/API/generate_exports.py
```
Missing symbols would usually cause the following kind of errors in python builf kind of error:
diff --git a/compiler/CMakeLists.txt b/compiler/CMakeLists.txt
index 4af8f85..5991a12 100644
--- a/compiler/CMakeLists.txt
+++ b/compiler/CMakeLists.txt
@@ -17,5 +17,6 @@
if(IREE_BUILD_PYTHON_BINDINGS)
configure_file(pyproject.toml pyproject.toml COPYONLY)
configure_file(setup.py setup.py @ONLY)
+ add_subdirectory(bindings/python)
endif()
endif()
diff --git a/compiler/README.md b/compiler/README.md
index 0acc18a..47b9a18 100644
--- a/compiler/README.md
+++ b/compiler/README.md
@@ -41,5 +41,5 @@
In order to sanity check once the package is installed:
```
-python compiler/src/iree/compiler/API/python/test/transforms/ireec/compile_sample_module.py
+python compiler/src/iree/compiler/bindings/python/test/transforms/ireec/compile_sample_module.py
```
diff --git a/compiler/bindings/c/CMakeLists.txt b/compiler/bindings/c/CMakeLists.txt
index 3c5a114..14c6567 100644
--- a/compiler/bindings/c/CMakeLists.txt
+++ b/compiler/bindings/c/CMakeLists.txt
@@ -49,7 +49,7 @@
SRCS
"iree/compiler/loader/loader_test.c"
ARGS
- "$<TARGET_FILE:iree::compiler::API2::SharedImpl>"
+ "$<TARGET_FILE:iree::compiler::API::SharedImpl>"
DEPS
::loader
)
@@ -59,7 +59,7 @@
# TODO: Find a better way to do this.
add_dependencies(
iree_compiler_bindings_c_loader_test
- iree::compiler::API2::SharedImpl
+ iree::compiler::API::SharedImpl
)
endif()
else()
diff --git a/compiler/bindings/c/README.md b/compiler/bindings/c/README.md
index 00be908..a3d588b 100644
--- a/compiler/bindings/c/README.md
+++ b/compiler/bindings/c/README.md
@@ -31,5 +31,5 @@
can happen in a variety of cases (i.e. avoiding symbol conflicts, integrating
across build systems, etc).
-See the implementation under `compiler/src/iree/compiler/API2` (TODO: rename
+See the implementation under `compiler/src/iree/compiler/API` (TODO: rename
to `ApiImpl`).
\ No newline at end of file
diff --git a/compiler/src/iree/compiler/API/python/CMakeLists.txt b/compiler/bindings/python/CMakeLists.txt
similarity index 90%
rename from compiler/src/iree/compiler/API/python/CMakeLists.txt
rename to compiler/bindings/python/CMakeLists.txt
index 7d8221f..d0e5283 100644
--- a/compiler/src/iree/compiler/API/python/CMakeLists.txt
+++ b/compiler/bindings/python/CMakeLists.txt
@@ -4,6 +4,18 @@
# See https://llvm.org/LICENSE.txt for license information.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+################################################################################
+# CAPI library using the LLVM build system.
+#
+# WARNING WILL ROBINSON!
+# This does not look like the rest of IREE. It is directly using the upstream
+# LLVM build system in order to create bundled compiler API binaries that
+# are consistent with LLVM. Consult upstream CMake macros if you don't
+# understand what this does.
+################################################################################
+
+include(AddLLVM)
+include(AddMLIR)
include(AddMLIRPython)
# Specifies that all MLIR packages are co-located under npcomp.
@@ -114,7 +126,7 @@
INSTALL_PREFIX "${_PYTHON_INSTALL_PREFIX}/iree/compiler"
DECLARED_SOURCES ${_SOURCE_COMPONENTS}
COMMON_CAPI_LINK_LIBS
- iree_compiler_API2_SharedImpl
+ iree_compiler_API_SharedImpl
)
@@ -135,7 +147,7 @@
)
target_link_libraries(${target}
iree_compiler_bindings_c_headers
- iree_compiler_API2_Impl)
+ iree_compiler_API_Impl)
set_target_properties(${target}
PROPERTIES
OUTPUT_NAME "${ARG_OUTPUT_NAME}"
@@ -177,7 +189,7 @@
cmake_language(DEFER DIRECTORY \"${IREE_SOURCE_DIR}/compiler\"
CALL install
TARGETS
- iree_compiler_API2_SharedImpl
+ iree_compiler_API_SharedImpl
DESTINATION \"${_PYTHON_INSTALL_PREFIX}/iree/compiler/_mlir_libs\"
)
")
@@ -193,9 +205,9 @@
add_custom_command(
OUTPUT "${_local_dll_copy}"
COMMAND "${CMAKE_COMMAND}" -E copy_if_different
- "$<TARGET_FILE:iree_compiler_API2_SharedImpl>"
+ "$<TARGET_FILE:iree_compiler_API_SharedImpl>"
"${_local_dll_copy}"
- DEPENDS iree_compiler_API2_SharedImpl
+ DEPENDS iree_compiler_API_SharedImpl
)
add_custom_target(IREEPythonCopyDLL ALL
DEPENDS "${_local_dll_copy}")
diff --git a/compiler/src/iree/compiler/API/python/IREECTransforms.cpp b/compiler/bindings/python/IREECTransforms.cpp
similarity index 98%
rename from compiler/src/iree/compiler/API/python/IREECTransforms.cpp
rename to compiler/bindings/python/IREECTransforms.cpp
index 828b374..95a9f85 100644
--- a/compiler/src/iree/compiler/API/python/IREECTransforms.cpp
+++ b/compiler/bindings/python/IREECTransforms.cpp
@@ -4,7 +4,7 @@
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-#include "iree/compiler/API2/MLIRInterop.h"
+#include "iree/compiler/API/MLIRInterop.h"
#include "mlir/Bindings/Python/PybindAdaptors.h"
namespace py = pybind11;
diff --git a/compiler/src/iree/compiler/API/python/IREECompileTool.c b/compiler/bindings/python/IREECompileTool.c
similarity index 100%
rename from compiler/src/iree/compiler/API/python/IREECompileTool.c
rename to compiler/bindings/python/IREECompileTool.c
diff --git a/compiler/src/iree/compiler/API/python/LldTool.c b/compiler/bindings/python/LldTool.c
similarity index 100%
rename from compiler/src/iree/compiler/API/python/LldTool.c
rename to compiler/bindings/python/LldTool.c
diff --git a/compiler/src/iree/compiler/API/python/iree/compiler/__init__.py b/compiler/bindings/python/iree/compiler/__init__.py
similarity index 100%
rename from compiler/src/iree/compiler/API/python/iree/compiler/__init__.py
rename to compiler/bindings/python/iree/compiler/__init__.py
diff --git a/compiler/src/iree/compiler/API/python/iree/compiler/tf.py b/compiler/bindings/python/iree/compiler/tf.py
similarity index 100%
rename from compiler/src/iree/compiler/API/python/iree/compiler/tf.py
rename to compiler/bindings/python/iree/compiler/tf.py
diff --git a/compiler/src/iree/compiler/API/python/iree/compiler/tflite.py b/compiler/bindings/python/iree/compiler/tflite.py
similarity index 100%
rename from compiler/src/iree/compiler/API/python/iree/compiler/tflite.py
rename to compiler/bindings/python/iree/compiler/tflite.py
diff --git a/compiler/src/iree/compiler/API/python/iree/compiler/tools/__init__.py b/compiler/bindings/python/iree/compiler/tools/__init__.py
similarity index 100%
rename from compiler/src/iree/compiler/API/python/iree/compiler/tools/__init__.py
rename to compiler/bindings/python/iree/compiler/tools/__init__.py
diff --git a/compiler/src/iree/compiler/API/python/iree/compiler/tools/binaries.py b/compiler/bindings/python/iree/compiler/tools/binaries.py
similarity index 100%
rename from compiler/src/iree/compiler/API/python/iree/compiler/tools/binaries.py
rename to compiler/bindings/python/iree/compiler/tools/binaries.py
diff --git a/compiler/src/iree/compiler/API/python/iree/compiler/tools/core.py b/compiler/bindings/python/iree/compiler/tools/core.py
similarity index 100%
rename from compiler/src/iree/compiler/API/python/iree/compiler/tools/core.py
rename to compiler/bindings/python/iree/compiler/tools/core.py
diff --git a/compiler/src/iree/compiler/API/python/iree/compiler/tools/debugging.py b/compiler/bindings/python/iree/compiler/tools/debugging.py
similarity index 100%
rename from compiler/src/iree/compiler/API/python/iree/compiler/tools/debugging.py
rename to compiler/bindings/python/iree/compiler/tools/debugging.py
diff --git a/compiler/src/iree/compiler/API/python/iree/compiler/tools/scripts/__init__.py b/compiler/bindings/python/iree/compiler/tools/scripts/__init__.py
similarity index 100%
rename from compiler/src/iree/compiler/API/python/iree/compiler/tools/scripts/__init__.py
rename to compiler/bindings/python/iree/compiler/tools/scripts/__init__.py
diff --git a/compiler/src/iree/compiler/API/python/iree/compiler/tools/scripts/ireec/__main__.py b/compiler/bindings/python/iree/compiler/tools/scripts/ireec/__main__.py
similarity index 100%
rename from compiler/src/iree/compiler/API/python/iree/compiler/tools/scripts/ireec/__main__.py
rename to compiler/bindings/python/iree/compiler/tools/scripts/ireec/__main__.py
diff --git a/compiler/src/iree/compiler/API/python/iree/compiler/tools/tf.py b/compiler/bindings/python/iree/compiler/tools/tf.py
similarity index 100%
rename from compiler/src/iree/compiler/API/python/iree/compiler/tools/tf.py
rename to compiler/bindings/python/iree/compiler/tools/tf.py
diff --git a/compiler/src/iree/compiler/API/python/iree/compiler/tools/tflite.py b/compiler/bindings/python/iree/compiler/tools/tflite.py
similarity index 100%
rename from compiler/src/iree/compiler/API/python/iree/compiler/tools/tflite.py
rename to compiler/bindings/python/iree/compiler/tools/tflite.py
diff --git a/compiler/src/iree/compiler/API/python/iree/compiler/tools/xla.py b/compiler/bindings/python/iree/compiler/tools/xla.py
similarity index 100%
rename from compiler/src/iree/compiler/API/python/iree/compiler/tools/xla.py
rename to compiler/bindings/python/iree/compiler/tools/xla.py
diff --git a/compiler/src/iree/compiler/API/python/iree/compiler/transforms/ireec.py b/compiler/bindings/python/iree/compiler/transforms/ireec.py
similarity index 100%
rename from compiler/src/iree/compiler/API/python/iree/compiler/transforms/ireec.py
rename to compiler/bindings/python/iree/compiler/transforms/ireec.py
diff --git a/compiler/src/iree/compiler/API/python/iree/compiler/xla.py b/compiler/bindings/python/iree/compiler/xla.py
similarity index 100%
rename from compiler/src/iree/compiler/API/python/iree/compiler/xla.py
rename to compiler/bindings/python/iree/compiler/xla.py
diff --git a/compiler/src/iree/compiler/API/python/test/CMakeLists.txt b/compiler/bindings/python/test/CMakeLists.txt
similarity index 100%
rename from compiler/src/iree/compiler/API/python/test/CMakeLists.txt
rename to compiler/bindings/python/test/CMakeLists.txt
diff --git a/compiler/src/iree/compiler/API/python/test/tools/CMakeLists.txt b/compiler/bindings/python/test/tools/CMakeLists.txt
similarity index 100%
rename from compiler/src/iree/compiler/API/python/test/tools/CMakeLists.txt
rename to compiler/bindings/python/test/tools/CMakeLists.txt
diff --git a/compiler/src/iree/compiler/API/python/test/tools/README.md b/compiler/bindings/python/test/tools/README.md
similarity index 100%
rename from compiler/src/iree/compiler/API/python/test/tools/README.md
rename to compiler/bindings/python/test/tools/README.md
diff --git a/compiler/src/iree/compiler/API/python/test/tools/compiler_core_test.py b/compiler/bindings/python/test/tools/compiler_core_test.py
similarity index 100%
rename from compiler/src/iree/compiler/API/python/test/tools/compiler_core_test.py
rename to compiler/bindings/python/test/tools/compiler_core_test.py
diff --git a/compiler/src/iree/compiler/API/python/test/tools/compiler_tf_test.py b/compiler/bindings/python/test/tools/compiler_tf_test.py
similarity index 100%
rename from compiler/src/iree/compiler/API/python/test/tools/compiler_tf_test.py
rename to compiler/bindings/python/test/tools/compiler_tf_test.py
diff --git a/compiler/src/iree/compiler/API/python/test/tools/compiler_tflite_test.py b/compiler/bindings/python/test/tools/compiler_tflite_test.py
similarity index 100%
rename from compiler/src/iree/compiler/API/python/test/tools/compiler_tflite_test.py
rename to compiler/bindings/python/test/tools/compiler_tflite_test.py
diff --git a/compiler/src/iree/compiler/API/python/test/tools/compiler_xla_test.py b/compiler/bindings/python/test/tools/compiler_xla_test.py
similarity index 100%
rename from compiler/src/iree/compiler/API/python/test/tools/compiler_xla_test.py
rename to compiler/bindings/python/test/tools/compiler_xla_test.py
diff --git a/compiler/src/iree/compiler/API/python/test/tools/testdata/generate_tflite.py b/compiler/bindings/python/test/tools/testdata/generate_tflite.py
similarity index 100%
rename from compiler/src/iree/compiler/API/python/test/tools/testdata/generate_tflite.py
rename to compiler/bindings/python/test/tools/testdata/generate_tflite.py
diff --git a/compiler/src/iree/compiler/API/python/test/tools/testdata/generate_xla.py b/compiler/bindings/python/test/tools/testdata/generate_xla.py
similarity index 100%
rename from compiler/src/iree/compiler/API/python/test/tools/testdata/generate_xla.py
rename to compiler/bindings/python/test/tools/testdata/generate_xla.py
diff --git a/compiler/src/iree/compiler/API/python/test/tools/testdata/tflite_sample.fb b/compiler/bindings/python/test/tools/testdata/tflite_sample.fb
similarity index 100%
rename from compiler/src/iree/compiler/API/python/test/tools/testdata/tflite_sample.fb
rename to compiler/bindings/python/test/tools/testdata/tflite_sample.fb
Binary files differ
diff --git a/compiler/src/iree/compiler/API/python/test/tools/testdata/xla_sample.hlo b/compiler/bindings/python/test/tools/testdata/xla_sample.hlo
similarity index 100%
rename from compiler/src/iree/compiler/API/python/test/tools/testdata/xla_sample.hlo
rename to compiler/bindings/python/test/tools/testdata/xla_sample.hlo
diff --git a/compiler/src/iree/compiler/API/python/test/tools/testdata/xla_sample.pb b/compiler/bindings/python/test/tools/testdata/xla_sample.pb
similarity index 100%
rename from compiler/src/iree/compiler/API/python/test/tools/testdata/xla_sample.pb
rename to compiler/bindings/python/test/tools/testdata/xla_sample.pb
Binary files differ
diff --git a/compiler/src/iree/compiler/API/python/test/transforms/CMakeLists.txt b/compiler/bindings/python/test/transforms/CMakeLists.txt
similarity index 100%
rename from compiler/src/iree/compiler/API/python/test/transforms/CMakeLists.txt
rename to compiler/bindings/python/test/transforms/CMakeLists.txt
diff --git a/compiler/src/iree/compiler/API/python/test/transforms/ireec/CMakeLists.txt b/compiler/bindings/python/test/transforms/ireec/CMakeLists.txt
similarity index 100%
rename from compiler/src/iree/compiler/API/python/test/transforms/ireec/CMakeLists.txt
rename to compiler/bindings/python/test/transforms/ireec/CMakeLists.txt
diff --git a/compiler/src/iree/compiler/API/python/test/transforms/ireec/compile_sample_module.py b/compiler/bindings/python/test/transforms/ireec/compile_sample_module.py
similarity index 100%
rename from compiler/src/iree/compiler/API/python/test/transforms/ireec/compile_sample_module.py
rename to compiler/bindings/python/test/transforms/ireec/compile_sample_module.py
diff --git a/compiler/src/iree/compiler/API/python/test/transforms/ireec/compiler_options_test.py b/compiler/bindings/python/test/transforms/ireec/compiler_options_test.py
similarity index 100%
rename from compiler/src/iree/compiler/API/python/test/transforms/ireec/compiler_options_test.py
rename to compiler/bindings/python/test/transforms/ireec/compiler_options_test.py
diff --git a/compiler/src/iree/compiler/API/BUILD b/compiler/src/iree/compiler/API/BUILD
index 7bccd38..487a811 100644
--- a/compiler/src/iree/compiler/API/BUILD
+++ b/compiler/src/iree/compiler/API/BUILD
@@ -4,48 +4,76 @@
# See https://llvm.org/LICENSE.txt for license information.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+load("@bazel_skylib//rules:common_settings.bzl", "bool_flag")
+load("//build_tools/bazel:build_defs.oss.bzl", "defaulting_select", "iree_compiler_cc_library")
+
package(
default_visibility = ["//visibility:public"],
features = ["layering_check"],
- licenses = ["notice"],
+ licenses = ["notice"], # Apache 2.0
)
-# Allow all python sources to be built externally.
-exports_files(glob([
- "python/*.cpp",
- "python/*.c",
- "python/**/*.py",
- "unittests/**/*.py",
-]))
+exports_files([
+ "api_exports.c",
+ "api_exports.def",
+ "api_exports.ld",
+ "api_exports.lst",
+])
-################################################################################
-# Package-by-package filegroup exports.
-# Some tools can make use of such non-nested groups.
-################################################################################
-
-filegroup(
- name = "python_compiler_tools",
- srcs = glob(["python/iree/compiler/tools/*.py"]),
-)
-
-filegroup(
- name = "python_compiler_tools_deprecated_redirects",
- srcs = [
- "python/iree/compiler/__init__.py",
- "python/iree/compiler/tf.py",
- "python/iree/compiler/tflite.py",
- "python/iree/compiler/xla.py",
+# All headers for APIs exported by the library.
+iree_compiler_cc_library(
+ name = "MLIRInteropHeaders",
+ hdrs = [
+ "MLIRInterop.h",
+ ],
+ deps = [
+ "@llvm-project//mlir:CAPIIRHeaders",
],
)
-filegroup(
- name = "python_compiler_api",
- srcs = glob(["python/iree/compiler/transforms/*.py"]),
+iree_compiler_cc_library(
+ name = "StaticImpl",
+ deps = [
+ "//compiler/src/iree/compiler/API/Internal:Embed",
+ "//compiler/src/iree/compiler/API/Internal:IREECompileToolEntryPoint",
+ "//compiler/src/iree/compiler/API/Internal:IREEMLIRLSPServerToolEntryPoint",
+ "//compiler/src/iree/compiler/API/Internal:IREEOptToolEntryPoint",
+ "//compiler/src/iree/compiler/API/Internal:LLDToolEntryPoint",
+ "//compiler/src/iree/compiler/API/Internal:MLIRInterop",
+ "//llvm-external-projects/iree-dialects:CAPI",
+ "@llvm-project//mlir:CAPIDebug",
+ "@llvm-project//mlir:CAPIIR",
+ "@llvm-project//mlir:CAPIInterfaces",
+ "@llvm-project//mlir:CAPILinalg",
+ "@llvm-project//mlir:CAPIPDL",
+ "@llvm-project//mlir:CAPITransformDialect",
+ ],
)
-filegroup(
- name = "unittests_tools_testdata",
- srcs = glob([
- "python/test/tools/testdata/*",
- ]),
+iree_compiler_cc_library(
+ name = "SharedImpl",
+ srcs = [
+ "//lib:libIREECompiler.so",
+ ],
+ tags = ["skip-bazel_to_cmake"],
+)
+
+bool_flag(
+ name = "link_shared",
+ build_setting_default = False,
+)
+
+config_setting(
+ name = "link_shared_config",
+ flag_values = {
+ ":link_shared": "True",
+ },
+)
+
+alias(
+ name = "Impl",
+ actual = defaulting_select({
+ ":link_shared_config": ":SharedImpl",
+ "//conditions:default": ":StaticImpl",
+ }),
)
diff --git a/compiler/src/iree/compiler/API/CMakeLists.txt b/compiler/src/iree/compiler/API/CMakeLists.txt
index 2471e24..7860727 100644
--- a/compiler/src/iree/compiler/API/CMakeLists.txt
+++ b/compiler/src/iree/compiler/API/CMakeLists.txt
@@ -1,43 +1,131 @@
-# Copyright 2022 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
-
################################################################################
-# CAPI library using the LLVM build system.
-#
-# WARNING WILL ROBINSON!
-# This does not look like the rest of IREE. It is directly using the upstream
-# LLVM build system in order to create bundled compiler API binaries that
-# are consistent with LLVM. Consult upstream CMake macros if you don't
-# understand what this does.
+# Autogenerated by build_tools/bazel_to_cmake/bazel_to_cmake.py from #
+# compiler/src/iree/compiler/API/BUILD #
+# #
+# Use iree_cmake_extra_content from iree/build_defs.oss.bzl to add arbitrary #
+# CMake-only content. #
+# #
+# To disable autogeneration for this file entirely, delete this header. #
################################################################################
-include(AddLLVM)
-include(AddMLIR)
+iree_add_all_subdirs()
-# LLD may not have been enabled at the global level (typically because we
-# are not building for a CPU backend). If not, don't add API support for it.
-set(_OPTIONAL_SOURCES)
-set(_OPTIONAL_LINK_LIBS)
-if(TARGET lld)
- list(APPEND _OPTIONAL_SOURCES Lld.cpp)
- list(APPEND _OPTIONAL_LINK_LIBS
- lldCommon
- lldCOFF
- lldELF
- lldMachO
- lldMinGW
- lldWasm
+iree_cc_library(
+ NAME
+ MLIRInteropHeaders
+ HDRS
+ "MLIRInterop.h"
+ DEPS
+ IREELLVMIncludeSetup
+ PUBLIC
+)
+
+iree_cc_library(
+ NAME
+ StaticImpl
+ DEPS
+ IREEDialectsCAPI
+ MLIRCAPIDebug
+ MLIRCAPIIR
+ MLIRCAPIInterfaces
+ MLIRCAPILinalg
+ MLIRCAPIPDL
+ MLIRCAPITransformDialect
+ iree::compiler::API::Internal::Embed
+ iree::compiler::API::Internal::IREECompileToolEntryPoint
+ iree::compiler::API::Internal::IREEMLIRLSPServerToolEntryPoint
+ iree::compiler::API::Internal::IREEOptToolEntryPoint
+ iree::compiler::API::Internal::LLDToolEntryPoint
+ iree::compiler::API::Internal::MLIRInterop
+ PUBLIC
+)
+
+### BAZEL_TO_CMAKE_PRESERVES_ALL_CONTENT_BELOW_THIS_LINE ###
+
+iree_cc_library(
+ SHARED
+ NAME
+ SharedImpl
+ WINDOWS_DEF_FILE
+ # On Windows, include the generated def file.
+ ${CMAKE_CURRENT_SOURCE_DIR}/api_exports.def
+ SRCS
+ api_exports.c
+ LINKOPTS
+ # Linux uses a linker script.
+ $<$<PLATFORM_ID:Linux>:-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/api_exports.ld>
+ # MacOS uses a symbol list. Note that this option is only accepted
+ # with a single dash.
+ $<$<PLATFORM_ID:Darwin>:-Wl,-exported_symbols_list,${CMAKE_CURRENT_SOURCE_DIR}/api_exports.macos.lst>
+)
+
+# If not using sanitizers, ask linkers to error on undefined symbols.
+# For shared libraries, using sanitizers implies undefined symbols on Unix-like.
+if(NOT IREE_ENABLE_ASAN
+ AND NOT IREE_ENABLE_MSAN
+ AND NOT IREE_ENABLE_TSAN
+ AND NOT IREE_ENABLE_UBSAN)
+ target_link_options(iree_compiler_API_SharedImpl PRIVATE
+ $<$<PLATFORM_ID:Linux>:-Wl,--no-undefined>
+ $<$<PLATFORM_ID:Darwin>:-Wl,-undefined,error>
)
endif()
-################################################################################
-# Language specific bindings.
-# These have an ordering dependency on the backing CAPI being defined.
-################################################################################
+# DANGER: iree_cc_library links its deps with PUBLIC scope, which causes
+# usage requirements to propagate from dependents to users of the shared
+# library. The shared library is intended to be used as an isolated boundary
+# for C consumers. Therefore, we depend on the backing static library with
+# PRIVATE scope explicitly here vs using a DEPS above. This kind of "boundary
+# shared library" seems to be the only place this happens, so we special
+# case vs generalizing.
+target_link_libraries(
+ iree_compiler_API_SharedImpl
+ PRIVATE
+ iree_compiler_API_StaticImpl
+)
-if(IREE_BUILD_PYTHON_BINDINGS)
- add_subdirectory(python)
+set_target_properties(
+ iree_compiler_API_SharedImpl
+ PROPERTIES
+ OUTPUT_NAME "IREECompiler"
+ VERSION "0"
+ SOVERSION "0"
+
+ LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib"
+ # On Windows, DLLs go to the runtime directory and import
+ # libraries go to the lib directory.
+ # TODO: We should really be dumping binaries into bin/ not
+ # tools/. This must line up with binaries built this way because
+ # DLLs must be in the same directory as the binary.
+ # See: https://github.com/openxla/iree/issues/11297
+ RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/tools"
+ ARCHIVE_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib"
+)
+
+install(
+ TARGETS iree_compiler_API_SharedImpl
+ COMPONENT Compiler
+)
+
+# The bazel side uses a "Impl" library alias to generically represent
+# static or shared. Provide a corresponding one here.
+# When in BUILD_SHARED_LIBS mode, we do CMake level linking against the
+# non-shared library, since strict layering is enforced there. The mondo
+# shared library can still be generated and used dynamically but is not
+# generally depended on from a normal C++ link.
+
+if(IREE_LINK_COMPILER_SHARED_LIBRARY AND NOT BUILD_SHARED_LIBS)
+iree_cc_library(
+ NAME
+ Impl
+ DEPS
+ ::SharedImpl
+)
+else()
+iree_cc_library(
+ NAME
+ Impl
+ DEPS
+ ::StaticImpl
+)
endif()
diff --git a/compiler/src/iree/compiler/API2/Internal/BUILD b/compiler/src/iree/compiler/API/Internal/BUILD
similarity index 98%
rename from compiler/src/iree/compiler/API2/Internal/BUILD
rename to compiler/src/iree/compiler/API/Internal/BUILD
index d4ca338..e02d1db 100644
--- a/compiler/src/iree/compiler/API2/Internal/BUILD
+++ b/compiler/src/iree/compiler/API/Internal/BUILD
@@ -103,7 +103,7 @@
"MLIRInterop.cpp",
],
deps = [
- "//compiler/src/iree/compiler/API2:MLIRInteropHeaders",
+ "//compiler/src/iree/compiler/API:MLIRInteropHeaders",
"//compiler/src/iree/compiler/ConstEval",
"//compiler/src/iree/compiler/Dialect/VM/IR",
"//compiler/src/iree/compiler/Dialect/VM/Target:init_targets",
diff --git a/compiler/src/iree/compiler/API2/Internal/CMakeLists.txt b/compiler/src/iree/compiler/API/Internal/CMakeLists.txt
similarity index 96%
rename from compiler/src/iree/compiler/API2/Internal/CMakeLists.txt
rename to compiler/src/iree/compiler/API/Internal/CMakeLists.txt
index 5e03e14..b5b4cd0 100644
--- a/compiler/src/iree/compiler/API2/Internal/CMakeLists.txt
+++ b/compiler/src/iree/compiler/API/Internal/CMakeLists.txt
@@ -1,6 +1,6 @@
################################################################################
# Autogenerated by build_tools/bazel_to_cmake/bazel_to_cmake.py from #
-# compiler/src/iree/compiler/API2/Internal/BUILD #
+# compiler/src/iree/compiler/API/Internal/BUILD #
# #
# Use iree_cmake_extra_content from iree/build_defs.oss.bzl to add arbitrary #
# CMake-only content. #
@@ -102,7 +102,7 @@
DEPS
MLIRCAPIIR
MLIRIR
- iree::compiler::API2::MLIRInteropHeaders
+ iree::compiler::API::MLIRInteropHeaders
iree::compiler::ConstEval
iree::compiler::Dialect::VM::IR
iree::compiler::Dialect::VM::Target::Bytecode
diff --git a/compiler/src/iree/compiler/API2/Internal/Diagnostics.cpp b/compiler/src/iree/compiler/API/Internal/Diagnostics.cpp
similarity index 98%
rename from compiler/src/iree/compiler/API2/Internal/Diagnostics.cpp
rename to compiler/src/iree/compiler/API/Internal/Diagnostics.cpp
index 153b327..a390d06 100644
--- a/compiler/src/iree/compiler/API2/Internal/Diagnostics.cpp
+++ b/compiler/src/iree/compiler/API/Internal/Diagnostics.cpp
@@ -4,7 +4,7 @@
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-#include "iree/compiler/API2/Internal/Diagnostics.h"
+#include "iree/compiler/API/Internal/Diagnostics.h"
#include "llvm/ADT/TypeSwitch.h"
#include "llvm/Support/raw_ostream.h"
diff --git a/compiler/src/iree/compiler/API2/Internal/Diagnostics.h b/compiler/src/iree/compiler/API/Internal/Diagnostics.h
similarity index 90%
rename from compiler/src/iree/compiler/API2/Internal/Diagnostics.h
rename to compiler/src/iree/compiler/API/Internal/Diagnostics.h
index 48e7e17..0939611 100644
--- a/compiler/src/iree/compiler/API2/Internal/Diagnostics.h
+++ b/compiler/src/iree/compiler/API/Internal/Diagnostics.h
@@ -4,8 +4,8 @@
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-#ifndef IREE_COMPILER_API2_INTERNAL_DIAGNOSTICS_H
-#define IREE_COMPILER_API2_INTERNAL_DIAGNOSTICS_H
+#ifndef IREE_COMPILER_API_INTERNAL_DIAGNOSTICS_H
+#define IREE_COMPILER_API_INTERNAL_DIAGNOSTICS_H
#include <functional>
#include <string_view>
@@ -42,4 +42,4 @@
} // namespace mlir::iree_compiler::embed
-#endif // IREE_COMPILER_API2_INTERNAL_DIAGNOSTICS_H
+#endif // IREE_COMPILER_API_INTERNAL_DIAGNOSTICS_H
diff --git a/compiler/src/iree/compiler/API2/Internal/Embed.cpp b/compiler/src/iree/compiler/API/Internal/Embed.cpp
similarity index 99%
rename from compiler/src/iree/compiler/API2/Internal/Embed.cpp
rename to compiler/src/iree/compiler/API/Internal/Embed.cpp
index ca3bc23..b8e15fa 100644
--- a/compiler/src/iree/compiler/API2/Internal/Embed.cpp
+++ b/compiler/src/iree/compiler/API/Internal/Embed.cpp
@@ -9,7 +9,7 @@
#include <atomic>
-#include "iree/compiler/API2/Internal/Diagnostics.h"
+#include "iree/compiler/API/Internal/Diagnostics.h"
#include "iree/compiler/ConstEval/Passes.h"
#include "iree/compiler/Dialect/VM/Target/init_targets.h"
#include "iree/compiler/Pipelines/Pipelines.h"
diff --git a/compiler/src/iree/compiler/API2/Internal/IREECompileToolEntryPoint.cpp b/compiler/src/iree/compiler/API/Internal/IREECompileToolEntryPoint.cpp
similarity index 100%
rename from compiler/src/iree/compiler/API2/Internal/IREECompileToolEntryPoint.cpp
rename to compiler/src/iree/compiler/API/Internal/IREECompileToolEntryPoint.cpp
diff --git a/compiler/src/iree/compiler/API2/Internal/IREEMLIRLSPServerToolEntryPoint.cpp b/compiler/src/iree/compiler/API/Internal/IREEMLIRLSPServerToolEntryPoint.cpp
similarity index 100%
rename from compiler/src/iree/compiler/API2/Internal/IREEMLIRLSPServerToolEntryPoint.cpp
rename to compiler/src/iree/compiler/API/Internal/IREEMLIRLSPServerToolEntryPoint.cpp
diff --git a/compiler/src/iree/compiler/API2/Internal/IREEOptToolEntryPoint.cpp b/compiler/src/iree/compiler/API/Internal/IREEOptToolEntryPoint.cpp
similarity index 100%
rename from compiler/src/iree/compiler/API2/Internal/IREEOptToolEntryPoint.cpp
rename to compiler/src/iree/compiler/API/Internal/IREEOptToolEntryPoint.cpp
diff --git a/compiler/src/iree/compiler/API2/Internal/LLDToolEntryPoint.cpp b/compiler/src/iree/compiler/API/Internal/LLDToolEntryPoint.cpp
similarity index 100%
rename from compiler/src/iree/compiler/API2/Internal/LLDToolEntryPoint.cpp
rename to compiler/src/iree/compiler/API/Internal/LLDToolEntryPoint.cpp
diff --git a/compiler/src/iree/compiler/API2/Internal/MLIRInterop.cpp b/compiler/src/iree/compiler/API/Internal/MLIRInterop.cpp
similarity index 98%
rename from compiler/src/iree/compiler/API2/Internal/MLIRInterop.cpp
rename to compiler/src/iree/compiler/API/Internal/MLIRInterop.cpp
index ad09f51..2381a04 100644
--- a/compiler/src/iree/compiler/API2/Internal/MLIRInterop.cpp
+++ b/compiler/src/iree/compiler/API/Internal/MLIRInterop.cpp
@@ -4,7 +4,7 @@
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-#include "iree/compiler/API2/MLIRInterop.h"
+#include "iree/compiler/API/MLIRInterop.h"
#include "iree/compiler/ConstEval/Passes.h"
#include "iree/compiler/Dialect/VM/IR/VMOps.h"
diff --git a/compiler/src/iree/compiler/API2/MLIRInterop.h b/compiler/src/iree/compiler/API/MLIRInterop.h
similarity index 95%
rename from compiler/src/iree/compiler/API2/MLIRInterop.h
rename to compiler/src/iree/compiler/API/MLIRInterop.h
index f2aa2e3..322d764 100644
--- a/compiler/src/iree/compiler/API2/MLIRInterop.h
+++ b/compiler/src/iree/compiler/API/MLIRInterop.h
@@ -9,8 +9,8 @@
// Stability: This API, like the MLIR C-API, offers no ABI stability guarantees,
// and API stability is best effort.
-#ifndef IREE_COMPILER_API2_MLIR_INTEROP_H
-#define IREE_COMPILER_API2_MLIR_INTEROP_H
+#ifndef IREE_COMPILER_API_MLIR_INTEROP_H
+#define IREE_COMPILER_API_MLIR_INTEROP_H
#include "mlir-c/Pass.h"
#include "mlir-c/Support.h"
@@ -75,4 +75,4 @@
}
#endif
-#endif // IREE_COMPILER_API2_MLIR_INTEROP_H
+#endif // IREE_COMPILER_API_MLIR_INTEROP_H
diff --git a/compiler/src/iree/compiler/API/README.md b/compiler/src/iree/compiler/API/README.md
index 08f8fe8..2168aeb 100644
--- a/compiler/src/iree/compiler/API/README.md
+++ b/compiler/src/iree/compiler/API/README.md
@@ -1,4 +1,18 @@
-# IREE Compiler API (deprecated)
+# IREE Compiler API Implementation
-This directory is being refactored into API2. Currently, it only contains
-the Python bindings, which will be moved soon.
+This directory contains the implementation for the publicly exported
+C API. See the headers and stub implementation in `compiler/bindings/c`,
+which are available for standalone use, regardless of whether the compiler
+is built (i.e. can be used to dynamically bind to a shared library, etc).
+
+## Exported symbols
+
+See the script `generate_exports.py` which generates a number of checked
+in files with names `api_exports.*` which are needed for various styles of
+linking. Presently, this script scrapes a number of headers to generate an
+export list, but this is a WIP: we would like to align upstream better and
+be explicit.
+
+It is typically pretty obvious to determine that an update is needed: libraries
+will fail to build on missing symbols, or language bindings will fail to load
+at runtime (complaining of missing symbols).
diff --git a/compiler/src/iree/compiler/API2/api_exports.c b/compiler/src/iree/compiler/API/api_exports.c
similarity index 100%
rename from compiler/src/iree/compiler/API2/api_exports.c
rename to compiler/src/iree/compiler/API/api_exports.c
diff --git a/compiler/src/iree/compiler/API2/api_exports.def b/compiler/src/iree/compiler/API/api_exports.def
similarity index 100%
rename from compiler/src/iree/compiler/API2/api_exports.def
rename to compiler/src/iree/compiler/API/api_exports.def
diff --git a/compiler/src/iree/compiler/API2/api_exports.ld b/compiler/src/iree/compiler/API/api_exports.ld
similarity index 100%
rename from compiler/src/iree/compiler/API2/api_exports.ld
rename to compiler/src/iree/compiler/API/api_exports.ld
diff --git a/compiler/src/iree/compiler/API2/api_exports.macos.lst b/compiler/src/iree/compiler/API/api_exports.macos.lst
similarity index 100%
rename from compiler/src/iree/compiler/API2/api_exports.macos.lst
rename to compiler/src/iree/compiler/API/api_exports.macos.lst
diff --git a/compiler/src/iree/compiler/API2/generate_exports.py b/compiler/src/iree/compiler/API/generate_exports.py
similarity index 100%
rename from compiler/src/iree/compiler/API2/generate_exports.py
rename to compiler/src/iree/compiler/API/generate_exports.py
diff --git a/compiler/src/iree/compiler/API2/test/BUILD b/compiler/src/iree/compiler/API/test/BUILD
similarity index 84%
rename from compiler/src/iree/compiler/API2/test/BUILD
rename to compiler/src/iree/compiler/API/test/BUILD
index d7669e2..2a83bc9 100644
--- a/compiler/src/iree/compiler/API2/test/BUILD
+++ b/compiler/src/iree/compiler/API/test/BUILD
@@ -17,8 +17,8 @@
srcs = ["api-test-main.c"],
deps = [
"//compiler/bindings/c:headers",
- "//compiler/src/iree/compiler/API2:Impl",
- "//compiler/src/iree/compiler/API2:MLIRInteropHeaders",
+ "//compiler/src/iree/compiler/API:Impl",
+ "//compiler/src/iree/compiler/API:MLIRInteropHeaders",
"//runtime/src/iree/base",
"@llvm-project//mlir:CAPIIRHeaders",
],
diff --git a/compiler/src/iree/compiler/API2/test/CMakeLists.txt b/compiler/src/iree/compiler/API/test/CMakeLists.txt
similarity index 82%
rename from compiler/src/iree/compiler/API2/test/CMakeLists.txt
rename to compiler/src/iree/compiler/API/test/CMakeLists.txt
index 7676f10..772cb59 100644
--- a/compiler/src/iree/compiler/API2/test/CMakeLists.txt
+++ b/compiler/src/iree/compiler/API/test/CMakeLists.txt
@@ -1,6 +1,6 @@
################################################################################
# Autogenerated by build_tools/bazel_to_cmake/bazel_to_cmake.py from #
-# compiler/src/iree/compiler/API2/test/BUILD #
+# compiler/src/iree/compiler/API/test/BUILD #
# #
# Use iree_cmake_extra_content from iree/build_defs.oss.bzl to add arbitrary #
# CMake-only content. #
@@ -18,8 +18,8 @@
DEPS
IREELLVMIncludeSetup
iree::base
- iree::compiler::API2::Impl
- iree::compiler::API2::MLIRInteropHeaders
+ iree::compiler::API::Impl
+ iree::compiler::API::MLIRInteropHeaders
iree::compiler::bindings::c::headers
)
@@ -27,8 +27,8 @@
# Move to bin/ directory and systematically name more appropriately.
# See: https://github.com/openxla/iree/issues/11297
-if(TARGET iree_compiler_API2_test_api-test-binary)
- set_target_properties(iree_compiler_API2_test_api-test-binary
+if(TARGET iree_compiler_API_test_api-test-binary)
+ set_target_properties(iree_compiler_API_test_api-test-binary
PROPERTIES
OUTPUT_NAME "test-iree-compiler-api-test-binary"
RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/tools"
diff --git a/compiler/src/iree/compiler/API2/test/api-test-main.c b/compiler/src/iree/compiler/API/test/api-test-main.c
similarity index 98%
rename from compiler/src/iree/compiler/API2/test/api-test-main.c
rename to compiler/src/iree/compiler/API/test/api-test-main.c
index 740c3e9..507682b 100644
--- a/compiler/src/iree/compiler/API2/test/api-test-main.c
+++ b/compiler/src/iree/compiler/API/test/api-test-main.c
@@ -15,7 +15,7 @@
#include <stdio.h>
#include "iree/base/api.h"
-#include "iree/compiler/API2/MLIRInterop.h"
+#include "iree/compiler/API/MLIRInterop.h"
static void bytecode_builder_callback(MlirStringRef str, void* userdata) {
iree_string_builder_t* builder = (iree_string_builder_t*)userdata;
diff --git a/compiler/src/iree/compiler/API2/BUILD b/compiler/src/iree/compiler/API2/BUILD
deleted file mode 100644
index 98ef722..0000000
--- a/compiler/src/iree/compiler/API2/BUILD
+++ /dev/null
@@ -1,79 +0,0 @@
-# Copyright 2022 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("@bazel_skylib//rules:common_settings.bzl", "bool_flag")
-load("//build_tools/bazel:build_defs.oss.bzl", "defaulting_select", "iree_compiler_cc_library")
-
-package(
- default_visibility = ["//visibility:public"],
- features = ["layering_check"],
- licenses = ["notice"], # Apache 2.0
-)
-
-exports_files([
- "api_exports.c",
- "api_exports.def",
- "api_exports.ld",
- "api_exports.lst",
-])
-
-# All headers for APIs exported by the library.
-iree_compiler_cc_library(
- name = "MLIRInteropHeaders",
- hdrs = [
- "MLIRInterop.h",
- ],
- deps = [
- "@llvm-project//mlir:CAPIIRHeaders",
- ],
-)
-
-iree_compiler_cc_library(
- name = "StaticImpl",
- deps = [
- "//compiler/src/iree/compiler/API2/Internal:Embed",
- "//compiler/src/iree/compiler/API2/Internal:IREECompileToolEntryPoint",
- "//compiler/src/iree/compiler/API2/Internal:IREEMLIRLSPServerToolEntryPoint",
- "//compiler/src/iree/compiler/API2/Internal:IREEOptToolEntryPoint",
- "//compiler/src/iree/compiler/API2/Internal:LLDToolEntryPoint",
- "//compiler/src/iree/compiler/API2/Internal:MLIRInterop",
- "//llvm-external-projects/iree-dialects:CAPI",
- "@llvm-project//mlir:CAPIDebug",
- "@llvm-project//mlir:CAPIIR",
- "@llvm-project//mlir:CAPIInterfaces",
- "@llvm-project//mlir:CAPILinalg",
- "@llvm-project//mlir:CAPIPDL",
- "@llvm-project//mlir:CAPITransformDialect",
- ],
-)
-
-iree_compiler_cc_library(
- name = "SharedImpl",
- srcs = [
- "//lib:libIREECompiler.so",
- ],
- tags = ["skip-bazel_to_cmake"],
-)
-
-bool_flag(
- name = "link_shared",
- build_setting_default = False,
-)
-
-config_setting(
- name = "link_shared_config",
- flag_values = {
- ":link_shared": "True",
- },
-)
-
-alias(
- name = "Impl",
- actual = defaulting_select({
- ":link_shared_config": ":SharedImpl",
- "//conditions:default": ":StaticImpl",
- }),
-)
diff --git a/compiler/src/iree/compiler/API2/CMakeLists.txt b/compiler/src/iree/compiler/API2/CMakeLists.txt
deleted file mode 100644
index 751ffe5..0000000
--- a/compiler/src/iree/compiler/API2/CMakeLists.txt
+++ /dev/null
@@ -1,131 +0,0 @@
-################################################################################
-# Autogenerated by build_tools/bazel_to_cmake/bazel_to_cmake.py from #
-# compiler/src/iree/compiler/API2/BUILD #
-# #
-# Use iree_cmake_extra_content from iree/build_defs.oss.bzl to add arbitrary #
-# CMake-only content. #
-# #
-# To disable autogeneration for this file entirely, delete this header. #
-################################################################################
-
-iree_add_all_subdirs()
-
-iree_cc_library(
- NAME
- MLIRInteropHeaders
- HDRS
- "MLIRInterop.h"
- DEPS
- IREELLVMIncludeSetup
- PUBLIC
-)
-
-iree_cc_library(
- NAME
- StaticImpl
- DEPS
- IREEDialectsCAPI
- MLIRCAPIDebug
- MLIRCAPIIR
- MLIRCAPIInterfaces
- MLIRCAPILinalg
- MLIRCAPIPDL
- MLIRCAPITransformDialect
- iree::compiler::API2::Internal::Embed
- iree::compiler::API2::Internal::IREECompileToolEntryPoint
- iree::compiler::API2::Internal::IREEMLIRLSPServerToolEntryPoint
- iree::compiler::API2::Internal::IREEOptToolEntryPoint
- iree::compiler::API2::Internal::LLDToolEntryPoint
- iree::compiler::API2::Internal::MLIRInterop
- PUBLIC
-)
-
-### BAZEL_TO_CMAKE_PRESERVES_ALL_CONTENT_BELOW_THIS_LINE ###
-
-iree_cc_library(
- SHARED
- NAME
- SharedImpl
- WINDOWS_DEF_FILE
- # On Windows, include the generated def file.
- ${CMAKE_CURRENT_SOURCE_DIR}/api_exports.def
- SRCS
- api_exports.c
- LINKOPTS
- # Linux uses a linker script.
- $<$<PLATFORM_ID:Linux>:-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/api_exports.ld>
- # MacOS uses a symbol list. Note that this option is only accepted
- # with a single dash.
- $<$<PLATFORM_ID:Darwin>:-Wl,-exported_symbols_list,${CMAKE_CURRENT_SOURCE_DIR}/api_exports.macos.lst>
-)
-
-# If not using sanitizers, ask linkers to error on undefined symbols.
-# For shared libraries, using sanitizers implies undefined symbols on Unix-like.
-if(NOT IREE_ENABLE_ASAN
- AND NOT IREE_ENABLE_MSAN
- AND NOT IREE_ENABLE_TSAN
- AND NOT IREE_ENABLE_UBSAN)
- target_link_options(iree_compiler_API2_SharedImpl PRIVATE
- $<$<PLATFORM_ID:Linux>:-Wl,--no-undefined>
- $<$<PLATFORM_ID:Darwin>:-Wl,-undefined,error>
- )
-endif()
-
-# DANGER: iree_cc_library links its deps with PUBLIC scope, which causes
-# usage requirements to propagate from dependents to users of the shared
-# library. The shared library is intended to be used as an isolated boundary
-# for C consumers. Therefore, we depend on the backing static library with
-# PRIVATE scope explicitly here vs using a DEPS above. This kind of "boundary
-# shared library" seems to be the only place this happens, so we special
-# case vs generalizing.
-target_link_libraries(
- iree_compiler_API2_SharedImpl
- PRIVATE
- iree_compiler_API2_StaticImpl
-)
-
-set_target_properties(
- iree_compiler_API2_SharedImpl
- PROPERTIES
- OUTPUT_NAME "IREECompiler"
- VERSION "0"
- SOVERSION "0"
-
- LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib"
- # On Windows, DLLs go to the runtime directory and import
- # libraries go to the lib directory.
- # TODO: We should really be dumping binaries into bin/ not
- # tools/. This must line up with binaries built this way because
- # DLLs must be in the same directory as the binary.
- # See: https://github.com/openxla/iree/issues/11297
- RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/tools"
- ARCHIVE_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib"
-)
-
-install(
- TARGETS iree_compiler_API2_SharedImpl
- COMPONENT Compiler
-)
-
-# The bazel side uses a "Impl" library alias to generically represent
-# static or shared. Provide a corresponding one here.
-# When in BUILD_SHARED_LIBS mode, we do CMake level linking against the
-# non-shared library, since strict layering is enforced there. The mondo
-# shared library can still be generated and used dynamically but is not
-# generally depended on from a normal C++ link.
-
-if(IREE_LINK_COMPILER_SHARED_LIBRARY AND NOT BUILD_SHARED_LIBS)
-iree_cc_library(
- NAME
- Impl
- DEPS
- ::SharedImpl
-)
-else()
-iree_cc_library(
- NAME
- Impl
- DEPS
- ::StaticImpl
-)
-endif()
diff --git a/compiler/src/iree/compiler/API2/README.md b/compiler/src/iree/compiler/API2/README.md
deleted file mode 100644
index 2168aeb..0000000
--- a/compiler/src/iree/compiler/API2/README.md
+++ /dev/null
@@ -1,18 +0,0 @@
-# IREE Compiler API Implementation
-
-This directory contains the implementation for the publicly exported
-C API. See the headers and stub implementation in `compiler/bindings/c`,
-which are available for standalone use, regardless of whether the compiler
-is built (i.e. can be used to dynamically bind to a shared library, etc).
-
-## Exported symbols
-
-See the script `generate_exports.py` which generates a number of checked
-in files with names `api_exports.*` which are needed for various styles of
-linking. Presently, this script scrapes a number of headers to generate an
-export list, but this is a WIP: we would like to align upstream better and
-be explicit.
-
-It is typically pretty obvious to determine that an update is needed: libraries
-will fail to build on missing symbols, or language bindings will fail to load
-at runtime (complaining of missing symbols).
diff --git a/compiler/src/iree/compiler/Tools/BUILD b/compiler/src/iree/compiler/Tools/BUILD
index f9ad3b3..bc6200a 100644
--- a/compiler/src/iree/compiler/Tools/BUILD
+++ b/compiler/src/iree/compiler/Tools/BUILD
@@ -228,7 +228,7 @@
deps = [
":init_iree",
"//compiler/bindings/c:headers",
- "//compiler/src/iree/compiler/API2/Internal:Embed",
+ "//compiler/src/iree/compiler/API/Internal:Embed",
"//compiler/src/iree/compiler/Pipelines",
"@llvm-project//llvm:Support",
],
diff --git a/compiler/src/iree/compiler/Tools/CMakeLists.txt b/compiler/src/iree/compiler/Tools/CMakeLists.txt
index 50d934e..5b9f1da 100644
--- a/compiler/src/iree/compiler/Tools/CMakeLists.txt
+++ b/compiler/src/iree/compiler/Tools/CMakeLists.txt
@@ -232,7 +232,7 @@
DEPS
::init_iree
LLVMSupport
- iree::compiler::API2::Internal::Embed
+ iree::compiler::API::Internal::Embed
iree::compiler::Pipelines
iree::compiler::bindings::c::headers
PUBLIC
diff --git a/lib/BUILD b/lib/BUILD
index daf2d17..beb5c6c 100644
--- a/lib/BUILD
+++ b/lib/BUILD
@@ -13,17 +13,17 @@
cc_binary(
name = "libIREECompiler.so",
srcs = [
- "//compiler/src/iree/compiler/API2:api_exports.c",
+ "//compiler/src/iree/compiler/API:api_exports.c",
],
linkopts = [
- "-Wl,--version-script=$(location //compiler/src/iree/compiler/API2:api_exports.ld)",
+ "-Wl,--version-script=$(location //compiler/src/iree/compiler/API:api_exports.ld)",
"-Wl,--no-undefined",
],
linkshared = 1,
deps = [
"//compiler/bindings/c:headers",
- "//compiler/src/iree/compiler/API2:MLIRInteropHeaders",
- "//compiler/src/iree/compiler/API2:StaticImpl",
- "//compiler/src/iree/compiler/API2:api_exports.ld",
+ "//compiler/src/iree/compiler/API:MLIRInteropHeaders",
+ "//compiler/src/iree/compiler/API:StaticImpl",
+ "//compiler/src/iree/compiler/API:api_exports.ld",
],
)
diff --git a/tools/BUILD b/tools/BUILD
index 3a37662..f3e8da9 100644
--- a/tools/BUILD
+++ b/tools/BUILD
@@ -109,7 +109,7 @@
tags = ["hostonly"],
deps = [
"//compiler/bindings/c:headers",
- "//compiler/src/iree/compiler/API2:Impl",
+ "//compiler/src/iree/compiler/API:Impl",
],
)
@@ -118,7 +118,7 @@
srcs = ["iree-mlir-lsp-server.cc"],
deps = [
"//compiler/bindings/c:headers",
- "//compiler/src/iree/compiler/API2:Impl",
+ "//compiler/src/iree/compiler/API:Impl",
],
)
@@ -245,6 +245,6 @@
tags = ["hostonly"],
deps = [
"//compiler/bindings/c:headers",
- "//compiler/src/iree/compiler/API2:Impl",
+ "//compiler/src/iree/compiler/API:Impl",
],
)
diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt
index 50e56d1..aa011d8 100644
--- a/tools/CMakeLists.txt
+++ b/tools/CMakeLists.txt
@@ -233,7 +233,7 @@
"iree-compile-main.cc"
DEPS
iree::compiler::bindings::c::headers
- iree::compiler::API2::Impl
+ iree::compiler::API::Impl
DATA
${IREE_LLD_TARGET}
HOSTONLY
@@ -247,7 +247,7 @@
"iree-opt-main.cc"
DEPS
iree::compiler::bindings::c::headers
- iree::compiler::API2::Impl
+ iree::compiler::API::Impl
DATA
${IREE_LLD_TARGET}
HOSTONLY
@@ -261,7 +261,7 @@
"iree-mlir-lsp-server.cc"
DEPS
iree::compiler::bindings::c::headers
- iree::compiler::API2::Impl
+ iree::compiler::API::Impl
SETUP_INSTALL_RPATH
)