Merge "sw/vec_iree: Merge ITCM and DTCM into TCM."
diff --git a/CMakeLists.txt b/CMakeLists.txt
index bc8c402..0e22756 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -20,6 +20,9 @@
 include_directories(BEFORE SYSTEM "${RISCV_TOOLCHAIN_ROOT}/riscv32-unknown-elf/include/newlib-nano/")
 link_directories(BEFORE "${RISCV_TOOLCHAIN_ROOT}/riscv32-unknown-elf/lib/newlib-nano/")
 
+include_directories(BEFORE SYSTEM ${CMAKE_CURRENT_LIST_DIR})
+include_directories(BEFORE SYSTEM ${CMAKE_CURRENT_BINARY_DIR})
+
 #-------------------------------------------------------------------------------
 # Springbok-specific settings
 #-------------------------------------------------------------------------------
@@ -79,7 +82,8 @@
 
 # Apply IREE's CMake variables and build options so we can use IREE build
 # functions properly in this project.
-include(${IREE_SOURCE_DIR}/build_tools/cmake/iree_copts.cmake)
+set(IREE_ROOT_DIR "${IREE_SOURCE_DIR}" CACHE PATH "IREE Root directory")
+include(springbok_ops)
 
 include(springbok_bytecode_module)
 include(springbok_c_module)
@@ -94,22 +98,6 @@
 REQUIRED)
 link_libraries(m)
 
-# Apply hacks to avoid adding the `iree::` prefix to the out-of-tree
-# `iree_cc_library` function usage
-function(add_library library)
-  cmake_parse_arguments(AL "ALIAS;IMPORTED" "" "" ${ARGN})
-  _add_library(${library} ${ARGN})
-  if(AL_ALIAS)
-    string(FIND "${library}" "iree::samples::" _AL_IREE_SAMPLES)
-    if(_AL_IREE_SAMPLES EQUAL 0)
-      string(REPLACE "iree::" "" _AL_IREE_SAMPLES_ALIAS "${library}")
-      string(REPLACE "ALIAS;" "" _AL_IREE_REAL_TARGET "${ARGN}")
-      # Add an alias target starting with the iree:: prefix removed
-      _add_library(${_AL_IREE_SAMPLES_ALIAS} ALIAS ${_AL_IREE_REAL_TARGET})
-    endif()
-  endif()
-endfunction()
-
 # Add the included directory here.
 add_subdirectory(samples)
 
diff --git a/cmake/springbok_ops.cmake b/cmake/springbok_ops.cmake
new file mode 100644
index 0000000..7456694
--- /dev/null
+++ b/cmake/springbok_ops.cmake
@@ -0,0 +1,84 @@
+# Add Compilation and Linker options based on iree/build_tools/cmake/iree_cops.cmake
+
+# Key compilation options
+iree_select_compiler_opts(IREE_DEFAULT_COPTS
+  CLANG_OR_GCC
+  "-fvisibility=hidden"
+
+  # NOTE: The RTTI setting must match what LLVM was compiled with (defaults
+  # to RTTI disabled).
+  "$<$<COMPILE_LANGUAGE:CXX>:-fno-rtti>"
+  "$<$<COMPILE_LANGUAGE:CXX>:-fno-exceptions>"
+)
+
+# Compiler diagnostics.
+# Please keep these in sync with build_tools/bazel/iree.bazelrc
+iree_select_compiler_opts(IREE_DEFAULT_COPTS
+
+  # Clang diagnostics. These largely match the set of warnings used within
+  # Google. They have not been audited super carefully by the IREE team but are
+  # generally thought to be a good set and consistency with those used
+  # internally is very useful when importing. If you feel that some of these
+  # should be different (especially more strict), please raise an issue!
+  CLANG
+  "-Werror"
+  "-Wall"
+
+  # Disable warnings we don't care about or that generally have a low
+  # signal/noise ratio.
+  "-Wno-ambiguous-member-template"
+  "-Wno-char-subscripts"
+  "-Wno-deprecated-declarations"
+  "-Wno-extern-c-compat" # Matches upstream. Cannot impact due to extern C inclusion method.
+  "-Wno-gnu-alignof-expression"
+  "-Wno-gnu-variable-sized-type-not-at-end"
+  "-Wno-ignored-optimization-argument"
+  "-Wno-invalid-offsetof" # Technically UB but needed for intrusive ptrs
+  "-Wno-invalid-source-encoding"
+  "-Wno-mismatched-tags"
+  "-Wno-pointer-sign"
+  "-Wno-reserved-user-defined-literal"
+  "-Wno-return-type-c-linkage"
+  "-Wno-self-assign-overloaded"
+  "-Wno-sign-compare"
+  "-Wno-signed-unsigned-wchar"
+  "-Wno-strict-overflow"
+  "-Wno-trigraphs"
+  "-Wno-unknown-pragmas"
+  "-Wno-unknown-warning-option"
+  "-Wno-unused-command-line-argument"
+  "-Wno-unused-const-variable"
+  "-Wno-unused-function"
+  "-Wno-unused-local-typedef"
+  "-Wno-unused-private-field"
+  "-Wno-user-defined-warnings"
+
+  # Explicitly enable some additional warnings.
+  # Some of these aren't on by default, or under -Wall, or are subsets of
+  # warnings turned off above.
+  "-Wctad-maybe-unsupported"
+  "-Wfloat-overflow-conversion"
+  "-Wfloat-zero-conversion"
+  "-Wfor-loop-analysis"
+  "-Wformat-security"
+  "-Wgnu-redeclared-enum"
+  "-Wimplicit-fallthrough"
+  "-Winfinite-recursion"
+  "-Wliteral-conversion"
+  "-Wnon-virtual-dtor"
+  "-Woverloaded-virtual"
+  "-Wself-assign"
+  "-Wstring-conversion"
+  "-Wtautological-overlap-compare"
+  "-Wthread-safety"
+  "-Wthread-safety-beta"
+  "-Wunused-comparison"
+  "-Wvla"
+)
+
+
+iree_select_compiler_opts(IREE_DEFAULT_LINKOPTS
+  CLANG_OR_GCC
+  # Required by all modern software, effectively:
+  "-lm"
+)
diff --git a/samples/util/util.c b/samples/util/util.c
index 3d2e9f9..858a0ec 100644
--- a/samples/util/util.c
+++ b/samples/util/util.c
@@ -79,8 +79,8 @@
   }
   iree_vm_module_t *hal_module = NULL;
   if (iree_status_is_ok(result)) {
-    result =
-        iree_hal_module_create(device, iree_allocator_system(), &hal_module);
+    result = iree_hal_module_create(device, IREE_HAL_MODULE_FLAG_NONE,
+                                    iree_allocator_system(), &hal_module);
   }
   // Load bytecode or C module.
   iree_vm_module_t *module = NULL;