Repository navigation
Replace CMake IREE_HOST_BINARY_ROOT var with IREE_HOST_BIN_DIR. - #11812
Conversation
The new variable is documented in the root CMakeLists.txt and is initialized from the (new deprecated) old variable.
```
iree-build/ # CMake build directory
install/ # Set by -DCMAKE_INSTALL_PREFIX, IREE_HOST_BINARY_ROOT pointed here
bin/ # IREE_HOST_BIN_DIR should point here
lib/
src/
tests/
```
Now we can also point to other binary distributions that don't have CMake's build/install structure.
GMNGeoffrey
left a comment
There was a problem hiding this comment.
Somewhat tangential musing: For compiler configuration detection without silent failures should we make the IREE_TARGET_BACKEND_* options available (maybe hidden) even if IREE_BUILD_COMPILER is OFF? We could do a single configure step to set them by calling iree-compile --iree-list-target-backends, but explicit setting would take precedence. Then users can get nice behavior of just "run all the supported things" and in CI we can set everything explicitly
Maybe something like this? if(IREE_HOST_BIN_DIR)
if(IREE_BUILD_COMPILER)
# Disallow because it would be ambiguous whether to use the prebuilt tools or build from source.
message(FATAL_ERROR "IREE_HOST_BIN_DIR and IREE_BUILD_COMPILER cannot be set together")
endif()
get_target_property(_IREE_COMPILE_LOCATION iree-compile IMPORTED_LOCATION)
execute_process(
COMMAND ${_IREE_COMPILE_LOCATION} --iree-hal-list-target-backends
OUTPUT_VARIABLE _TARGET_BACKENDS_OUTPUT
)
if(_TARGET_BACKENDS_OUTPUT MATCHES "cuda")
set(IREE_TARGET_BACKEND_CUDA ON)
elseif(IREE_TARGET_BACKEND_CUDA)
message(FATAL_ERROR "IREE_TARGET_BACKEND_CUDA is set, but the imported iree-compile does not support CUDA")
endif()
# ... handle other target backends (maybe with a macro to save typing?)
endif() |
I think explicit "OFF" should probably be allowed also, but I'm not quite sure how to do that. I don't think you can differentiate between options being set and unset. Also should probably make the matching logic a bit more robust. Maybe this works? set(_IREE_TARGET_BACKEND_VMVX_DEFAULT ON)
set(_IREE_TARGET_BACKEND_CUDA_DEFAULT OFF)
if(IREE_HOST_BIN_DIR)
if(IREE_BUILD_COMPILER)
# Disallow because it would be ambiguous whether to use the prebuilt tools or build from source.
message(FATAL_ERROR "IREE_HOST_BIN_DIR and IREE_BUILD_COMPILER cannot be set together")
endif()
get_target_property(_IREE_COMPILE_LOCATION iree-compile IMPORTED_LOCATION)
execute_process(
COMMAND ${_IREE_COMPILE_LOCATION} --iree-hal-list-target-backends
OUTPUT_VARIABLE _TARGET_BACKENDS_OUTPUT
)
if(_TARGET_BACKENDS_OUTPUT MATCHES "cuda")
# These variables will always have the same value, but named separately because they're
# conceptually different.
set(_IREE_TARGET_BACKEND_CUDA_DETECTED ON)
set(_IREE_TARGET_BACKEND_CUDA_DEFAULT ON)
endif()
if(_TARGET_BACKENDS_OUTPUT MATCHES "vmvx")
set(_IREE_TARGET_BACKEND_VMVX_DETECTED ON)
set(_IREE_TARGET_BACKEND_VMVX_DEFAULT ON)
endif()
endif()
option(IREE_TARGET_BACKEND_VMVX "Turns on VMVX" "${_IREE_TARGET_BACKEND_VMVX_DEFAULT}")
option(IREE_TARGET_BACKEND_CUDA "Turns on Cuda" "${_IREE_TARGET_BACKEND_CUDA_DEFAULT}")
if(IREE_HOST_BIN_DIR)
if(IREE_TARGET_BACKEND_CUDA AND NOT _IREE_TARGET_BACKEND_CUDA_DETECTED)
message(FATAL_ERROR "IREE_TARGET_BACKEND_CUDA is set, but the imported iree-compile does not support CUDA")
endif()
if(IREE_TARGET_BACKEND_VMVX AND NOT _IREE_TARGET_BACKEND_VMVX_DETECTED)
message(FATAL_ERROR "IREE_TARGET_BACKEND_VMVX is set, but the imported iree-compile does not support VMVX")
endif()
endif()I think that works, but it's pretty convoluted. Not sure of another way... |
Co-authored-by: Geoffrey Martin-Noble <[email protected]>
Follow-up to #11812. `IREE_HOST_BIN_DIR` will still be populated from the deprecated `IREE_HOST_BINARY_ROOT` to give downstream users time to update to the new variable.
…11812) The new variable is documented in the root CMakeLists.txt and is initialized from the (new deprecated) old variable. ``` iree-build/ # CMake build directory install/ # Set by -DCMAKE_INSTALL_PREFIX, IREE_HOST_BINARY_ROOT pointed here bin/ # IREE_HOST_BIN_DIR should point here lib/ src/ tests/ ``` Now we can also point to other binary distributions that don't have CMake's build/install structure. --- Closes #11441. Fixes #4662. This new variable approach was discussed on #11764 (comment). Co-authored-by: Geoffrey Martin-Noble <[email protected]>
Follow-up to #11812. `IREE_HOST_BIN_DIR` will still be populated from the deprecated `IREE_HOST_BINARY_ROOT` to give downstream users time to update to the new variable.
The new variable is documented in the root CMakeLists.txt and is initialized from the (new deprecated) old variable.
Now we can also point to other binary distributions that don't have CMake's build/install structure.
Closes #11441. Fixes #4662. This new variable approach was discussed on #11764 (comment).