Repository navigation
Conversation
We don't really care about cross compilation per se... just that the tools should be provided somehow.
|
Maybe we still want to have HOST in this name? ( |
Note that you can use this even when not cross compiling, so there doesn't need to be a "host" vs "target" distinction in the build. This setting should be a mechanism to use some tools from an existing build rather than building them from source. The real distinction we're making is compiler + other host tools ( Naming ideas:
|
|
The use of this is for the build host binaries, so that iree-run-module exists in an install is orthogonal as iree-run-module should not be used by the build host. I think INSTALL may be the wrong word as it's kind of tying this to a cmake install of something. If it's really just a directory of the tools required by the host to build then "IREE_HOST_TOOLS_PATH" or something seems appropriate. A user shouldn't need to build iree-run-module/etc for this and instead just the tools a build host needs to complete an IREE target build. That a cmake install produces a superset of the requirements feels incidental - a user may want to build/ship just what's required for their bot to cross-compile. Maybe the root problem being addressed could be satisfied with a cmake helper for verifying that a path has all the required host tools (iree-opt, iree-compile, etc) - that may let us give the right error messages and such without enforcing the workflow ("you pointed us at foo/ but that doesn't have tool X" etc). (just riffing, not sure exactly what's trying to be solved with the changes - I just worried it may be changing one misnamed thing to another :) |
|
The impetus for this bit of work was #11331 and how cross compilation is complicating that. We don't just have a folder of binaries now - we have Linux: Windows: I'm trying to unwind some of the complexity that has grown in our CMake files while also cleanly supporting the new dynamic linking modes for our tools. |
|
I'm a bit scared by that - the bin/lib split is arbitrary and we really don't want to be requiring that - we should only require the executables to exist and not anything about the directory structure containing them. Nearly always these kind of executable path flags just point at bin dirs such that you can interchangeably use them with PATH. Is there a reason we need to know the lib dir exists at all? |
|
(restating what you're trying to do may be useful - I'm still unclear - having a helper cmake var that given an install path sets up other more fundamental vars seems ok; it's letting the install concept proliferate around the codebase that's sketching me out) |
A bunch of things, each orthogonal but useful together:
|
|
yeah as you say those things should be orthogonal to this var and if they are intersecting then there's probably some undesirable conflation happening that we should fix instead of just renaming :) The place where we point to find the executables used for the build host tools shouldn't require a cmake install to have ever been performed (or cmake to have been used at all for the tools build), shouldn't be platform dependent, shouldn't have anything to do with cmake deps, and shouldn't relate to how the tool executables are linked (statically or dynamically). If anything differs based on any of those aspects we've got the var wrong and not just the naming. Whatever we do with the var should be something compatible with what we will do with vcpkg, pip, custom user directory mixins (bring your own compiler build), bazel builds/etc, and what we'll want to do with find_program/find_package. cmake installs and such may feed into those but we don't want to couple our cross-compiling builds with any one particular host tool acquisition mechanism. If we can decouple every other thing you're doing from this var renaming maybe we can think of a better name as I'm not sure what's being done here is it - maybe defer this until after all the other changes/fixes land and we can re-evaluate? I think we're doing tomato/tomatoe tradeoffs when really this is a burrito :) |
|
(to be clear I think fixing this var is really important, just not sure that renaming is helping and may just be cementing the current badness - I'm fine if the churn is deemed worth it to others in the short term but would like to fix it so we don't have to think about it again instead) |
|
Maybe we should rename to
or keep the I can stop searching the |
|
I think you're still circling around workarounds to an issue that shouldn't exist - we really should not be requiring anything of the executables like this - if you're needing to in cmake specify lib dirs and stuff things have already gone off the rails. |
|
(that is to say if a user can't launch an executable from the bin dir with an arbitrary cwd without doing anything extra then our build/install is wrong, and we shouldn't work around that in cmake consuming those same executables in a way a user would) |
|
I'm not working around something broken in just launching/running executables. What I've been debugging on #11331 and proposing fixes for in #11402 is how on Windows with shared libraries, changes to compiler code do not trigger rebuilding generated targets. That's because I have a fix for that (add a |
|
I think we're going in circles (which is probably my fault - sorry!) - let's chat in the morning :) |
BTW yes, completely agree with this :) |
…11764) This changes how to access host tools during CMake's configure step from using a custom `iree_get_executable_path()` function to using `IMPORTED` targets (https://cmake.org/cmake/help/latest/guide/importing-exporting/index.html). A new helper `iree_import_binary` is added to keep `IREE_HOST_BINARY_ROOT` use centralized. ## Details Previously, each CMake file that wanted to use a tool that might be provided by either the current build or a "host install" would use the `iree_get_executable_path` function, e.g. ```cmake # tools/CMakeLists.txt if(IREE_BUILD_COMPILER) iree_cc_binary(NAME iree-compile ...) endif() # some other file iree_get_executable_path(_COMPILE_TOOL_EXECUTABLE "iree-compile") add_custom_command( OUTPUT ${_OUTPUT_FILES} COMMAND ${_COMPILE_TOOL_EXECUTABLE} ${_ARGS} DEPENDS ${_COMPILE_TOOL_EXECUTABLE} ${_SRC_PATH} ) ``` The `iree_get_executable_path` function attempted to find an executable with that name and would add an `IMPORTED` target if one did not already exist. We can simplify that to just defining `IMPORTED` targets directly, right where the targets are normally defined when `IREE_BUILD_COMPILER` is enabled (or `CMAKE_CROSSCOMPILING` is disabled). Importing targets where they are defined (rather than where they are used) will also let us more cleanly solve issues like #11331. Now this looks more like ```cmake # tools/CMakeLists.txt if(IREE_HOST_BINARY_ROOT AND NOT IREE_BUILD_COMPILER) iree_import_binary(NAME iree-compile) elseif(IREE_BUILD_COMPILER) iree_cc_binary(NAME iree-compile ...) else() # warn about not building or importing endif() # some other file - use the target without caring if it was imported or not add_custom_command( OUTPUT ${_OUTPUT_FILES} COMMAND iree-compile ${_ARGS} DEPENDS iree-compile ${_SRC_PATH} ) ``` ## Other context This is an alternate take on #11441 and was discussed a bit here: #11402 (comment). Future PRs may * Remove the implicit `bin/` suffix from `IREE_HOST_BINARY_ROOT` to decouple it from the CMake `install` process * Add `SHARED_LIBRARY_DEPS` to `iree_import_binary`, along with `iree_import_library`, for proper dependency modeling of IREECompiler.dll (assuming that `IMPORTED_RUNTIME_ARTIFACTS` doesn't already do what I want)
…11764) This changes how to access host tools during CMake's configure step from using a custom `iree_get_executable_path()` function to using `IMPORTED` targets (https://cmake.org/cmake/help/latest/guide/importing-exporting/index.html). A new helper `iree_import_binary` is added to keep `IREE_HOST_BINARY_ROOT` use centralized. ## Details Previously, each CMake file that wanted to use a tool that might be provided by either the current build or a "host install" would use the `iree_get_executable_path` function, e.g. ```cmake # tools/CMakeLists.txt if(IREE_BUILD_COMPILER) iree_cc_binary(NAME iree-compile ...) endif() # some other file iree_get_executable_path(_COMPILE_TOOL_EXECUTABLE "iree-compile") add_custom_command( OUTPUT ${_OUTPUT_FILES} COMMAND ${_COMPILE_TOOL_EXECUTABLE} ${_ARGS} DEPENDS ${_COMPILE_TOOL_EXECUTABLE} ${_SRC_PATH} ) ``` The `iree_get_executable_path` function attempted to find an executable with that name and would add an `IMPORTED` target if one did not already exist. We can simplify that to just defining `IMPORTED` targets directly, right where the targets are normally defined when `IREE_BUILD_COMPILER` is enabled (or `CMAKE_CROSSCOMPILING` is disabled). Importing targets where they are defined (rather than where they are used) will also let us more cleanly solve issues like #11331. Now this looks more like ```cmake # tools/CMakeLists.txt if(IREE_HOST_BINARY_ROOT AND NOT IREE_BUILD_COMPILER) iree_import_binary(NAME iree-compile) elseif(IREE_BUILD_COMPILER) iree_cc_binary(NAME iree-compile ...) else() # warn about not building or importing endif() # some other file - use the target without caring if it was imported or not add_custom_command( OUTPUT ${_OUTPUT_FILES} COMMAND iree-compile ${_ARGS} DEPENDS iree-compile ${_SRC_PATH} ) ``` ## Other context This is an alternate take on #11441 and was discussed a bit here: #11402 (comment). Future PRs may * Remove the implicit `bin/` suffix from `IREE_HOST_BINARY_ROOT` to decouple it from the CMake `install` process * Add `SHARED_LIBRARY_DEPS` to `iree_import_binary`, along with `iree_import_library`, for proper dependency modeling of IREECompiler.dll (assuming that `IMPORTED_RUNTIME_ARTIFACTS` doesn't already do what I want)
…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]>
Progress on #4662, depends on #11439
The expected path is the root of the install directory:
This also adds some documentation on the new variable in the root CMakeLists file. I'm also considering importing all binaries and libraries from the provided install directory, as a way to replace the current
iree_get_executable_path()and associated code for cross compilation in our test functions (see #11402 (review)).