Skip to content

CMake cross compilation assumes a host build of the compiler is needed #4520

Closed

Description

@ScottTodd

Relates to #4323

CMAKE_CROSSCOMPILING (docs) can be set by toolchain files under a variety of circumstances.

#4512 builds IREE's Java bindings using CMake under Gradle. This invokes a runtime-only build using an Android NDK toolchain.

However, we have this code in our root CMakeLists.txt that assumes cross compilation builds will always want a host build of the compiler parts of the project:

https://github.com/google/iree/blob/176b5803d616f09002e6cea619363cf61688e406/CMakeLists.txt#L187-L200

This then goes down into iree_cross_compile.cmake:

https://github.com/google/iree/blob/176b5803d616f09002e6cea619363cf61688e406/build_tools/cmake/iree_cross_compile.cmake#L61-L67

We should not be requiring IREE_HOST_C_COMPILER / IREE_HOST_CXX_COMPILER or always generating a host build whenever cross compilation is detected.

Activity

  1. added
    bug 🐞
    platform/android 🤖
    on Jan 14, 2021
  2. benvanik commented on Jan 14, 2021

    @benvanik
    Collaborator

    Lei and I were chatting about some of this yesterday - the goal of resolving #4323 is to remove the split-transition style single-command-to-build-both-host-compiler-and-target-runtime. If you want to build the compiler you should have to configure and make for the host, and if you want to build the runtime for a different target you should have to configure again. That removes a tremendous amount of the deps in here and simplifies things a lot: pip install of compiler + configure/make for target runtime should work naturally, etc.

    Basically, instead of any of the IREE_HOST_* flags we should just use the cmake standard toolchain variables - and once we do that we should be able to invoke cmake for a bajillion targets just like ncnn https://github.com/Tencent/ncnn/tree/master/.github/workflows

  3. ScottTodd commented on Jan 14, 2021

    @ScottTodd
    MemberAuthor

    Agreed that getting to a state where configure+make for host and configure+make for target are separate steps will be a natural solution. For this particular case, we could either put up with the weirdness as it affects the Java bindings or add some special handling (like our own IREE_CROSS_COMPILING that makes it explicit or consider IREE_BUILD_JAVA_BINDINGS when deciding how to treat cross compilation).

  4. benvanik commented on Jan 14, 2021

    @benvanik
    Collaborator

    I'm not sure we should do anything for the java bindings until we clean things up - I'm honestly still not sure we even want anyone using these bindings at all (and instead using tflite via java) - which may require some of the same infra - but we should only add complexity where we need it - things are already too confusing/broken :/

  5. added
    infrastructure
    on May 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug 🐞infrastructureplatform/android 🤖

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions