sw:vec_iree: Remove target library alias hack IREE macro supports out-of-tree build after https://github.com/iree-org/iree/pull/9639 Add ops cmake macro to apply all the compile and linker options. Change-Id: I1201a458fa366b046f74d34e73a8e091da5d4a1f
diff --git a/CMakeLists.txt b/CMakeLists.txt index 46f4279..14c8046 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 #------------------------------------------------------------------------------- @@ -81,7 +84,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) @@ -96,22 +100,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" +)