Promote HAL driver and target backend CMake variables to options. - #7936
Conversation
Also fully removed the list helpers. They would be useful to add back in some form though...
| ${CMAKE_CURRENT_LIST_DIR}/build_tools/cmake/ | ||
| ${CMAKE_CURRENT_LIST_DIR}/bindings/python/build_tools/cmake/ | ||
| ) | ||
| option(IREE_HAL_DRIVER_CUDA "Enables the CUDA runtime HAL driver" ${IREE_HAL_DRIVER_CUDA_DEFAULT}) |
There was a problem hiding this comment.
Whooo! This has always sketched me out also
As noted in Ben's comment, I think that having one easy variable to set things can still be nice maybe. But I think more important: it gave the ability to list exactly which drivers you wanted to build. If I only want Dylib, it's pretty annoying to have to list every single thing I want to disable, especially if that set changes over time. The single string variable gave that option, though it also was not super ergonomic to use. Another way to achieve that would be to have a single variable for setting the default for all "standard" drivers, which defaults to ON, then I can set it to OFF and only enable the one driver I want.
Something like
option(IREE_HAL_DRIVER_DEFAULT "Sets the default value for all standard drivers. Is overridden by platform-specific logic (e.g. disable cuda on android) and explicitly setting the variable for a specific driver" ON)
if (APPLE)
set(IREE_HAL_DRIVER_VULKAN_DEFAULT OFF)
else()
set(IREE_HAL_DRIVER_VULKAN_DEFAULT ${IREE_HAL_DRIVER_DEFAULT})
endif()
option(IREE_HAL_DRIVER_DYLIB "Enables the Dylib runtime HAL driver" ${IREE_HAL_DRIVER_DEFAULT})There was a problem hiding this comment.
Nice, overriding the default is pretty clean. Thanks for the suggestion!
| # Disable WebGPU by default - it has complex deps and is under development. | ||
| option(IREE_TARGET_BACKEND_WEBGPU "Enables the WebGPU compiler target backend" OFF) | ||
|
|
||
| message(STATUS "IREE build runtime HAL driver 'CUDA': ${IREE_HAL_DRIVER_CUDA}") |
There was a problem hiding this comment.
This is a lot of repetition. Could we have a little macro/function that does both the option creation and the status message? Would still definitely want the variable names as literals. Something like:
function(OPTION NAME DEFAULT)
option(${OPTION} "Enables the '${NAME}' compiler target backend")
message(STATUS "IREE build compiler target backend '${NAME}': ${OPTION}")
endfunction()There was a problem hiding this comment.
I actually like the repetition here, as a user of the project. No logic to follow, just WYSIWYG :P
There was a problem hiding this comment.
Elaborating on this a bit:
When integrating a project that uses CMake, the root CMakeLists.txt is the first (and sometimes only) place to look. It is very helpful if that file is organized into sections and has easy to follow logic. I don't think wrapping this in a function offers much benefit for maintainers (find/replace and multicursor editing within 40 contiguous lines of code is easy), and having each option spelled out with no loops, branches, or string manipulation makes it easy for users to scan the file and see which options they may want to enable/disable for their use.
| "-B", hostBuildDir , | ||
| "-DIREE_TARGET_BACKENDS_TO_BUILD=vmvx", | ||
| "-DIREE_HAL_DRIVERS_TO_BUILD=vmvx", | ||
| "-DIREE_HAL_DRIVER_VMVX=ON" |
There was a problem hiding this comment.
Yeah so this case is exactly what I was talking about above :-) Not terrible for CI, but imagine being a human
There was a problem hiding this comment.
🤖 haha yeah, imagine being a human... 👀
|
|
||
| if(IREE_HAL_DRIVERS_TO_BUILD STREQUAL "default") | ||
| set(IREE_HAL_DRIVERS_TO_BUILD ${IREE_ALL_HAL_DRIVERS}) | ||
| option(IREE_HAL_DRIVER_DEFAULT "Sets the default value for all runtime HAL drivers" ON) |
There was a problem hiding this comment.
worth making this plural (DEFAULTS) or something - "IREE_HAL_DRIVER_DEFAULT" makes me think it's picking a default driver, not that it's using the set of default drivers.
There was a problem hiding this comment.
SG, changed to plural.
| # Disable WebGPU by default - it has complex deps and is under development. | ||
| option(IREE_TARGET_BACKEND_WEBGPU "Enables the 'webgpu' compiler target backend" OFF) | ||
|
|
||
| message(STATUS "IREE build runtime HAL driver 'cuda': ${IREE_HAL_DRIVER_CUDA}") |
There was a problem hiding this comment.
do we need this? feels a bit spammy - especially when we are used as part of a larger project - VERBOSE seems like a better category if we do have it
There was a problem hiding this comment.
Changed to verbose. I like having it, since a few settings do have some logic (CUDA/Vulkan), and having the full list is useful in bug reports.
There was a problem hiding this comment.
BTW, VERBOSE is new in CMake 3.15: https://cmake.org/cmake/help/latest/command/message.html. We require 3.16.3+: cmake_minimum_required(VERSION 3.16.3...3.21)
log level can be controlled with --log-level=<ERROR|WARNING|NOTICE|STATUS|VERBOSE|DEBUG|TRACE> to the cmake command or with the CMAKE_MESSAGE_LOG_LEVEL option
| # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
|
|
||
| if(NOT ${IREE_TARGET_BACKEND_DYLIB-LLVM-AOT} | ||
| if(NOT ${IREE_TARGET_BACKEND_DYLIB_LLVM_AOT} |
Remove two obsolete iree flags IREE_TARGET_BACKENDS_TO_BUILD and IREE_HAL_DRIVERS_TO_BUILD. They were removed from IREE codebase at iree-org/iree#7936. Change-Id: If505172caca03a0c5ee4c922ad4cc8548760a013 GitOrigin-RevId: 4c10699fcb81d824e4945d21f80ceada09aacff0
Remove two obsolete iree flags IREE_TARGET_BACKENDS_TO_BUILD and IREE_HAL_DRIVERS_TO_BUILD. They were removed from IREE codebase at iree-org/iree#7936. Change-Id: If505172caca03a0c5ee4c922ad4cc8548760a013
Following up on #7905 (comment), this uses regular options for these settings, which are easier to search for and set. The CMakeLists from Tint was used as a reference: https://dawn.googlesource.com/tint/+/refs/heads/main/CMakeLists.txt. The main focus is to use explicit names instead of dynamic name construction, but using option is a nice bonus.
New
IREE_HAL_DRIVER_DEFAULTSandIREE_TARGET_BACKEND_DEFAULTSoptions can be used to set only a specific subset (set toOFFby default, then enable just the features you want).