Adding libyaml submodule and getting it building. (#6319)
The yaml_util.* files are here to ensure the cmake/bazel configuration is
correct and don't yet do anything meaningful.
diff --git a/.gitmodules b/.gitmodules
index e3a9b26..448b61c 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -50,3 +50,6 @@
[submodule "third_party/stblib"]
path = third_party/stblib
url = https://github.com/nothings/stb
+[submodule "third_party/libyaml"]
+ path = third_party/libyaml
+ url = https://github.com/yaml/libyaml.git
diff --git a/CMakeLists.txt b/CMakeLists.txt
index b4bb2d5..ca49b92 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -436,8 +436,9 @@
add_subdirectory(build_tools/third_party/cuda EXCLUDE_FROM_ALL)
add_subdirectory(build_tools/third_party/flatcc EXCLUDE_FROM_ALL)
-add_subdirectory(build_tools/third_party/vulkan_memory_allocator EXCLUDE_FROM_ALL)
+add_subdirectory(build_tools/third_party/libyaml EXCLUDE_FROM_ALL)
add_subdirectory(build_tools/third_party/stblib EXCLUDE_FROM_ALL)
+add_subdirectory(build_tools/third_party/vulkan_memory_allocator EXCLUDE_FROM_ALL)
add_subdirectory(third_party/googletest EXCLUDE_FROM_ALL)
if(${IREE_ENABLE_THREADING})
diff --git a/SUBMODULE_VERSIONS.txt b/SUBMODULE_VERSIONS.txt
index cda18ac..525b9a0 100644
--- a/SUBMODULE_VERSIONS.txt
+++ b/SUBMODULE_VERSIONS.txt
@@ -3,6 +3,7 @@
32aabef14ccc0e3ac15602c99476d25dcd230d19 third_party/flatcc
aa533abfd4232b01f9e57041d70114d5a77e6de0 third_party/googletest
88b845dee001723c4a0db1fe5477de735b6d3bb0 third_party/liburing
+acd6f6f014c25e46363e718381e0b35205df2d83 third_party/libyaml
1fbbae798591b6a800e7f3ae7ab722f7bef149a7 third_party/llvm-bazel
9393894331e9eba97bdafe92454af74550baf6d3 third_party/llvm-project
1a4dea1387e34538ba159a56204a6982e728e337 third_party/mlir-emitc
diff --git a/build_tools/bazel/workspace.bzl b/build_tools/bazel/workspace.bzl
index 076c3a3..49ed2d6 100644
--- a/build_tools/bazel/workspace.bzl
+++ b/build_tools/bazel/workspace.bzl
@@ -35,6 +35,13 @@
path = paths.join(iree_path, "third_party/flatcc"),
)
+ maybe(
+ native.new_local_repository,
+ name = "com_github_yaml_libyaml",
+ build_file = iree_repo_alias + "//:build_tools/third_party/libyaml/BUILD.overlay",
+ path = paths.join(iree_path, "third_party/libyaml"),
+ )
+
# TODO(scotttodd): TensorFlow is squatting on the vulkan_headers repo name, so
# we use a temporary one until resolved. Theirs is set to an outdated version.
maybe(
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 d6413f9..00063a2 100644
--- a/build_tools/bazel_to_cmake/bazel_to_cmake_targets.py
+++ b/build_tools/bazel_to_cmake/bazel_to_cmake_targets.py
@@ -55,6 +55,7 @@
"@com_google_benchmark//:benchmark": ["benchmark"],
"@com_github_dvidelabs_flatcc//:flatcc": ["flatcc"],
"@com_github_dvidelabs_flatcc//:runtime": ["flatcc::runtime"],
+ "@com_github_yaml_libyaml//:yaml": ["yaml"],
"@com_google_googletest//:gtest": ["gmock", "gtest"],
"@spirv_cross//:spirv_cross_lib": ["spirv-cross-msl"],
"@cpuinfo": ["cpuinfo"],
diff --git a/build_tools/third_party/libyaml/BUILD.overlay b/build_tools/third_party/libyaml/BUILD.overlay
new file mode 100644
index 0000000..ca7ede9
--- /dev/null
+++ b/build_tools/third_party/libyaml/BUILD.overlay
@@ -0,0 +1,38 @@
+# Copyright 2021 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
+
+package(default_visibility = ["//visibility:public"])
+
+cc_library(
+ name = "yaml",
+ srcs = [
+ "src/api.c",
+ "src/dumper.c",
+ "src/emitter.c",
+ "src/loader.c",
+ "src/parser.c",
+ "src/reader.c",
+ "src/scanner.c",
+ "src/writer.c",
+ "src/yaml_private.h",
+ ],
+ hdrs = [
+ "include/yaml.h",
+ ],
+ copts = [
+ "-D_CRT_SECURE_NO_WARNINGS",
+ "-DYAML_DECLARE_STATIC",
+ '-DYAML_VERSION_STRING=\\"0.2.5\\"',
+ "-DYAML_VERSION_MAJOR=0",
+ "-DYAML_VERSION_MINOR=2",
+ "-DYAML_VERSION_PATCH=5",
+ "-Iexternal/com_github_yaml_libyaml/include/",
+ ],
+ includes = [
+ "include/",
+ ],
+ strip_include_prefix = "include",
+)
diff --git a/build_tools/third_party/libyaml/CMakeLists.txt b/build_tools/third_party/libyaml/CMakeLists.txt
new file mode 100644
index 0000000..d060fe6
--- /dev/null
+++ b/build_tools/third_party/libyaml/CMakeLists.txt
@@ -0,0 +1,44 @@
+# Copyright 2021 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
+
+set(LIBYAML_ROOT "${IREE_ROOT_DIR}/third_party/libyaml/")
+
+external_cc_library(
+ PACKAGE
+ yaml
+ NAME
+ yaml
+ ROOT
+ ${LIBYAML_ROOT}
+ INCLUDES
+ "${FLATCC_ROOT}/include"
+ SRCS
+ "src/api.c"
+ "src/dumper.c"
+ "src/emitter.c"
+ "src/loader.c"
+ "src/parser.c"
+ "src/reader.c"
+ "src/scanner.c"
+ "src/writer.c"
+ "src/yaml_private.h"
+ HDRS
+ "include/yaml.h"
+ COPTS
+ "-D_CRT_SECURE_NO_WARNINGS"
+ "-DYAML_DECLARE_STATIC"
+ "-DYAML_VERSION_STRING=\"0.2.5\""
+ "-DYAML_VERSION_MAJOR=0"
+ "-DYAML_VERSION_MINOR=2"
+ "-DYAML_VERSION_PATCH=5"
+ INCLUDES
+ "${LIBYAML_ROOT}/include"
+ PUBLIC
+)
+
+if(MSVC)
+ target_compile_options(yaml_yaml PRIVATE /wd4996)
+endif()
diff --git a/iree/tools/BUILD b/iree/tools/BUILD
index 0f2ea53..5ee6e9b 100644
--- a/iree/tools/BUILD
+++ b/iree/tools/BUILD
@@ -285,6 +285,7 @@
"//iree/hal/drivers",
"//iree/modules/hal",
"//iree/tools/utils:vm_util",
+ "//iree/tools/utils:yaml_util",
"//iree/vm",
"//iree/vm:bytecode_module",
"//iree/vm:cc",
diff --git a/iree/tools/CMakeLists.txt b/iree/tools/CMakeLists.txt
index c15cd28..34f6cee 100644
--- a/iree/tools/CMakeLists.txt
+++ b/iree/tools/CMakeLists.txt
@@ -128,6 +128,7 @@
iree::hal::drivers
iree::modules::hal
iree::tools::utils::vm_util
+ iree::tools::utils::yaml_util
iree::vm
iree::vm::bytecode_module
)
diff --git a/iree/tools/iree-run-module-main.cc b/iree/tools/iree-run-module-main.cc
index 0141273..9167b62 100644
--- a/iree/tools/iree-run-module-main.cc
+++ b/iree/tools/iree-run-module-main.cc
@@ -21,6 +21,7 @@
#include "iree/hal/drivers/init.h"
#include "iree/modules/hal/module.h"
#include "iree/tools/utils/vm_util.h"
+#include "iree/tools/utils/yaml_util.h"
#include "iree/vm/api.h"
#include "iree/vm/bytecode_module.h"
#include "iree/vm/ref_cc.h"
diff --git a/iree/tools/utils/BUILD b/iree/tools/utils/BUILD
index 6441cc1..1af0ded 100644
--- a/iree/tools/utils/BUILD
+++ b/iree/tools/utils/BUILD
@@ -45,3 +45,15 @@
"//iree/vm:cc",
],
)
+
+cc_library(
+ name = "yaml_util",
+ srcs = ["yaml_util.c"],
+ hdrs = ["yaml_util.h"],
+ deps = [
+ "//iree/base",
+ "//iree/hal",
+ "//iree/vm",
+ "@com_github_yaml_libyaml//:yaml",
+ ],
+)
diff --git a/iree/tools/utils/CMakeLists.txt b/iree/tools/utils/CMakeLists.txt
index 0930922..476faad 100644
--- a/iree/tools/utils/CMakeLists.txt
+++ b/iree/tools/utils/CMakeLists.txt
@@ -49,6 +49,21 @@
iree::vm::cc
)
+iree_cc_library(
+ NAME
+ yaml_util
+ HDRS
+ "yaml_util.h"
+ SRCS
+ "yaml_util.c"
+ DEPS
+ iree::base
+ iree::hal
+ iree::vm
+ yaml
+ PUBLIC
+)
+
### BAZEL_TO_CMAKE_PRESERVES_ALL_CONTENT_BELOW_THIS_LINE ###
# image utility library based on stb_image.h in https://github.com/nothings/stb
diff --git a/iree/tools/utils/yaml_util.c b/iree/tools/utils/yaml_util.c
new file mode 100644
index 0000000..f16c2d0
--- /dev/null
+++ b/iree/tools/utils/yaml_util.c
@@ -0,0 +1,16 @@
+// Copyright 2021 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
+
+#include "iree/tools/utils/yaml_util.h"
+
+#include <yaml.h>
+
+// TODO(benvanik): yaml parsing/printing to vm types.
+
+void yaml_util_dummy() {
+ // Just here to make linking issues visible.
+ yaml_get_version_string();
+}
diff --git a/iree/tools/utils/yaml_util.h b/iree/tools/utils/yaml_util.h
new file mode 100644
index 0000000..433291c
--- /dev/null
+++ b/iree/tools/utils/yaml_util.h
@@ -0,0 +1,16 @@
+// Copyright 2021 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
+
+#ifndef IREE_TOOLS_UTILS_YAML_UTIL_H_
+#define IREE_TOOLS_UTILS_YAML_UTIL_H_
+
+#include "iree/base/api.h"
+#include "iree/hal/api.h"
+#include "iree/vm/api.h"
+
+// TODO(benvanik): yaml parsing/printing to vm types.
+
+#endif // IREE_TOOLS_UTILS_YAML_UTIL_H_
diff --git a/third_party/libyaml b/third_party/libyaml
new file mode 160000
index 0000000..acd6f6f
--- /dev/null
+++ b/third_party/libyaml
@@ -0,0 +1 @@
+Subproject commit acd6f6f014c25e46363e718381e0b35205df2d83