Skip to content

Add flexible configuration options to CMake for building/reusing tools #4662

Closed

Description

@ScottTodd

Relates to (and may resolve) #4617

We have a few components like iree_check_test that require some tools to exist, but they don't necessarily need to (or can't, depending on the build configuration) build those tools themselves.

We currently use -DIREE_HOST_BINARY_ROOT=$PWD/../build-host/install and CMAKE_CROSSCOMPILING together with iree_get_executable_path as the main way to control what gets build or reused where:

https://github.com/google/iree/blob/8d74bfa28dd35203fba700aa1f1d88c200c848cd/build_tools/cmake/iree_macros.cmake#L115-L126

separately, we can make that produce more helpful error messages if tools are missing

However, this misses a few cases such as

  • host runtime-only builds reusing the tools from a binary distribution
  • Android builds excluding certain types of tests

Something like IREE_USE_INSTALLED_HOST_TOOLS was suggested on #4627

Activity

  1. added
    infrastructure
    on May 11, 2021
  2. GMNGeoffrey commented on Aug 8, 2022

    @GMNGeoffrey
    Member

    I ran into this when trying to create a job that builds the IREE benchmarks (essentially import and compile some TFLite models). Currently they're built as part of the android build, which really doesn't make any sense and is not something I want to duplicate in the migration to GitHub actions. It appears that there's no way to build them using prebuilt host tools. You have to do a full host build.

  3. marbre commented on Aug 10, 2022

    @marbre
    Member

    I ran into this when trying to create a job that builds the IREE benchmarks (essentially import and compile some TFLite models). Currently they're built as part of the android build, which really doesn't make any sense and is not something I want to duplicate in the migration to GitHub actions. It appears that there's no way to build them using prebuilt host tools. You have to do a full host build.

    Can you elaborate which tools exactly where causing trouble and required a full host build?

  4. self-assigned this
    on Aug 24, 2022
  5. ScottTodd commented on Aug 24, 2022

    @ScottTodd
    MemberAuthor

    I think the change in 5189399 was enough to enable this. I also audited our usage of CMAKE_CROSSCOMPILING and what we have today looks good (no unnecessary restrictions).

    function(iree_get_executable_path OUTPUT_PATH_VAR EXECUTABLE)
    -  if (NOT CMAKE_CROSSCOMPILING OR TARGET "${EXECUTABLE}")
    +  if (NOT DEFINED IREE_HOST_BINARY_ROOT OR TARGET "${EXECUTABLE}")

    we might want to rename or better document IREE_HOST_BINARY_ROOT to better convey "I want to use binary files / tools from this directory instead of building them from CMake targets" though.

    I'll see if I can tweak

    # TODO(#4662): building the benchmarks currently needs the entire build
    # dir archive just to get the host tools. This is silly and we should
    # make prebuilt host tools work even when not cross-compiling.
    - name: "Downloading build dir archive"
    run: gcloud alpha storage cp "${BUILD_DIR_GCS_ARTIFACT}" "${BUILD_DIR_ARCHIVE}"
    - name: "Extracting archive"
    and https://github.com/iree-org/iree/blob/main/build_tools/cmake/build_benchmarks.sh to use that

  6. GMNGeoffrey commented on Aug 24, 2022

    @GMNGeoffrey
    Member

    I've also noticed that IREE_HOST_BINARY_ROOT actually has to point one directory above the root where IREE binaries are. It points to a directory containing a directory called "bin" that has the binaries. Basically it's an IREE install directory. I think we should probably name it based on that. Maybe IREE_TOOLS_INSTALL?

  7. added a commit that references this issue on Aug 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancement ➕infrastructure

Type

No type

Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions