Skip to content

Remove custom CMake cross compilation for Android. - #4584

Merged
ScottTodd merged 7 commits into
mainfrom
cmake-crosscompilation
Jan 25, 2021
Merged

ScottTodd merged 7 commits into
mainfrom
cmake-crosscompilation

Conversation

@ScottTodd

Copy link
Copy Markdown
Member

Cross compilation [for Android] is not special. Compiler tools are built on the host and installed (using CMake, Bazel, via vcpkg,
via pip, etc.). The runtime and target tests are built for the target, referencing host tools where needed using IREE_HOST_BINARY_ROOT. Some parts of the project only build or are only useful on the host, so some configuration like setting IREE_BUILD_COMPILER=OFF is still useful.

This removes our custom CMake code and updates all of our scripts and docs to invoke CMake in two explicit steps: once for the host and once for the target.

Fixes #4323.
Fixes #4520.
Fixes #2494 (tentatively).
Helps with #3843.

Cross compilation [for Android] is not special. Compiler tools are
built on the host and installed (using CMake, Bazel, via vcpkg,
via pip, etc.). The runtime and target tests are built for the target,
referencing host tools where needed using `IREE_HOST_BINARY_ROOT`.
@ScottTodd ScottTodd added infrastructure Relating to build systems, CI, or testing infrastructure/cmake platform/android 🤖 Android-specific build, execution, benchmarking, and deployment labels Jan 22, 2021
@google-cla google-cla Bot added the cla: yes label Jan 22, 2021
Comment thread CMakeLists.txt Resolved
@ScottTodd
ScottTodd force-pushed the cmake-crosscompilation branch from 2765751 to cbf015b Compare January 23, 2021 01:17
Comment thread build_tools/cmake/build_android.sh Resolved
@benvanik
benvanik self-requested a review January 23, 2021 02:39
@ScottTodd
ScottTodd marked this pull request as ready for review January 23, 2021 03:14

@antiagainst antiagainst left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread build_tools/cmake/build_android.sh Resolved
### Configure on Linux
### Host configuration

Build and install at least the compiler tools on your host machine, or install

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd just mention building on host machine for now. We don't have binary releases; we can mention that after having it.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do have binary releases through the Python wheels, but they don't yet contain all the relevant compiler tools.

# Define our own binary target for the CLI, for host builds only.
# flatcc's `flatcc_cli` target renames itself to `flatcc` or `flatcc_d`
# depending on the build configuration, so we prefer to just set our own name.
if(NOT CMAKE_CROSSCOMPILING)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why make this only for host builds?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly to match how the other CLIs are set up. Some tools may be possible to build for target platforms/architectures, but this consistently uses them from host builds. This can evolve over time, but flatcc was giving me enough trouble already that I just settled for what worked...

@GMNGeoffrey

Copy link
Copy Markdown
Member

feels_good_shave

@ScottTodd

Copy link
Copy Markdown
Member Author

Thanks Scott for taking on this! Overall looks awesome to me. I think we need to update https://google.github.io/iree/get-started/cmake-options-and-variables#cross-compilation too.

Cool, updated that doc too.

@NatashaKnk NatashaKnk mentioned this pull request Jan 26, 2021
copybara-service Bot pushed a commit that referenced this pull request Jan 26, 2021
* 4da7ac0 Allow benchmark pipeline to be run on presubmit (#4607)
* efbf53d Integrate MLIR-EmitC at iml130/mlir-emitc@4e501d8 (#4610)
* 9cdd378 Revert removing explicit linker path in compile_android_modules.sh. (#4605)
* 7ed1872 Merge pull request #4601
* 4e1a69b Remove custom CMake cross compilation for Android. (#4584)
* 38210b5 Merge branch 'main' into google-to-main
* 7defc33 Update third_party/ruy and use its own new CMakeLists.txt. (#4564)
* 71c6802 Integrate MLIR-EmitC at iml130/mlir-emitc@4e501d8 (#4593)
* 7e4dd01 E2E implementation of all remaining fft types (#4585)
* 53fcde4 Merge google -> main (#4588)

COPYBARA_INTEGRATE_REVIEW=#4614 from NatashaKnk:main-to-google 4da7ac0
PiperOrigin-RevId: 353949105
iree-github-actions-bot pushed a commit that referenced this pull request Jan 26, 2021
* 4da7ac0 Allow benchmark pipeline to be run on presubmit (#4607)
* efbf53d Integrate MLIR-EmitC at iml130/mlir-emitc@4e501d8 (#4610)
* 9cdd378 Revert removing explicit linker path in compile_android_modules.sh. (#4605)
* 7ed1872 Merge pull request #4601
* 4e1a69b Remove custom CMake cross compilation for Android. (#4584)
* 38210b5 Merge branch 'main' into google-to-main
* 7defc33 Update third_party/ruy and use its own new CMakeLists.txt. (#4564)
* 71c6802 Integrate MLIR-EmitC at iml130/mlir-emitc@4e501d8 (#4593)
* 7e4dd01 E2E implementation of all remaining fft types (#4585)
* 53fcde4 Merge google -> main (#4588)

COPYBARA_INTEGRATE_REVIEW=#4614 from NatashaKnk:main-to-google 4da7ac0
PiperOrigin-RevId: 353949105
not-jenni added a commit to not-jenni/iree that referenced this pull request Jan 26, 2021
ScottTodd added a commit that referenced this pull request Jan 29, 2021
I misconfigured this as part of #4584, leading to issues spotted on #4617. The flatcc cli is still required for the runtime, which is what I originally filed that issue for, but compiler tools like `iree-translate` should not be.

See also https://github.com/google/iree/blob/7d0108f0d565956c51c446dd52062fa1e50ca4e3/build_tools/cmake/iree_lit_test.cmake#L39-L43
GMNGeoffrey added a commit that referenced this pull request Feb 26, 2021
Rather than having CMake invoke Bazel itself, require that the
necessary binaries be built prior to running CMake and then import
them.

This is similar to what #4584 did
in the Android build and has similar advantages: the user can get these
binaries in a variety of ways: building with their chosen config (e.g.
with local or remote caching), installing prebuilt binaries,  etc.

It also is significantly more clear what's going on IMO. Having CMake
invoke Bazel has caused a fair amount of confusion.

Incidentally, I'm pretty sure this increases test coverage by enabling
TF tests that were apparently not getting run.

Tested:
In addition to the CI, ran all the release distribution commands
locally and confirmed they still exited successfully.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

infrastructure Relating to build systems, CI, or testing platform/android 🤖 Android-specific build, execution, benchmarking, and deployment

Projects

None yet

4 participants