Skip to content

[ci] Add Kokoro configuration for Android CMake cross-compilation - #2357

Merged
GMNGeoffrey merged 4 commits into
iree-org:mainfrom
antiagainst:kokoro-android
Jul 1, 2020
Merged

GMNGeoffrey merged 4 commits into
iree-org:mainfrom
antiagainst:kokoro-android

Conversation

@antiagainst

@antiagainst antiagainst commented Jun 29, 2020 •

Copy link
Copy Markdown
Member

This commit adds a new Dockerfile that inherits from the base
CMake Dockerfile and installs Android NDK. Kokoro build
configurations are added to use this Docker image to test cross
compilation towards Android.

This commit adds a new Dockerfile that inherits from the base
CMake Dockerfile and installs Android NDK. Kokoro jobs are added
to use this Docker image to test cross compilation towards
Android.
Comment thread build_tools/cmake/build_android.sh Resolved
Comment thread build_tools/cmake/build_android.sh Resolved

@GMNGeoffrey GMNGeoffrey 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.

To get a presubmit run of this, we need to set up a new Kokoro job. Let me do that

Comment thread build_tools/cmake/build_android.sh Resolved
Comment thread build_tools/cmake/build_android.sh Resolved
Comment on lines +18 to +39
set -x
set -e

# Ensure correct authorization.
gcloud auth configure-docker

# Determine which image tag to update. Updates :latest by default.
TAG="latest"
if [[ "$#" -ne 0 ]]; then
if [[ "$@" == "--update-prod" ]]; then
TAG="prod"
else
echo "Invalid commandline arguments. Accepts --update-prod or no arguments."
exit 1
fi
fi
echo "Updating ${TAG}"


# Build and push the cmake image.
docker build --tag "gcr.io/iree-oss/cmake-android:${TAG}" build_tools/docker/cmake/
docker push "gcr.io/iree-oss/cmake-android:${TAG}"

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.

So we should probably refactor so we only need one script. This should just be:

update_gcr cmake_android

(not this PR). @phoenix-meadowlark could you take a look at that?

@phoenix-meadowlark phoenix-meadowlark Jun 30, 2020 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Something like

./build_tools/docker/update_gcr.sh --image=bazel --update-prod

Where image ∈ {bazel, bazel-bindings, bazel-tensorflow, cmake, cmake-android, rbe} maps to a bunch of conditional statements? (Switch statements with drop through would work if we had chain dependencies, but we have bazel -> bazel-bindings and bazel -> bazel-tensorflow).

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.

Yes. Except per the organization point below, I think the images should be called linux/bazel/core, linux/bazel/bindings, android/cmake, etc.

Check out getopt for shell command line flag parsing.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We should probably also rename all of our images then. E.g. gcr.io/iree-oss/linux/bazel/core and so on :)

@GMNGeoffrey GMNGeoffrey added cmake infrastructure Relating to build systems, CI, or testing labels Jun 29, 2020
@GMNGeoffrey

Copy link
Copy Markdown
Member

So file organization question:

We've been organizing things by platform/build_system/component. Like "linux/bazel/bindings". That's the format for the directory structure, build badges, etc. Implicitly "gcp_ubuntu" here is a stand-in for linux (it's what Kokoro calls the runner cluster type, so internally that directory name is load-bearing), but when cross-compiling this doesn't fit as nicely, since we're still running the build on gcp_ubuntu, just with a different toolchain. Should this be in and "android/cmake" directory instead of "cmake/android"? That feels a little silly since it has the most in common with the other cmake build, but it isn't really referencing it. We really just need a DAG filesystem :-P But having cmake/android next to cmake/core is going to be confusing I think.

More generally, I kind of want to move the kokoro directory out of the top-level and into build_tools. If I'm doing that anyway, I'll have to deal with all the annoying pointers between things. Maybe we should reorganize like "cluster/platform/build_system/component":

- build_tools
  - kokoro
    - gcp_ubuntu
      - linux
        - bazel
          - core
          - bindings
          - integrations
        - cmake
          // Subdirs iff we split the build
      - android
        - cmake
          // Subdirs iff we split the build
    - gcp_windows
      - windows
        - bazel
          // ...
        - cmake

And I think the docker containers and build scripts should follow the same pattern minus the leading "cluster", since that's just a Kokoro thing. The gcr paths should be folders (slash-separated) instead of dash-separated.

@phoenix-meadowlark Thoughts?

The immediate question is whether this should be "android/cmake" instead of "cmake/android"

@GMNGeoffrey

Copy link
Copy Markdown
Member

Oh also should this be android_arm64 explicitly?

@phoenix-meadowlark

Copy link
Copy Markdown
Contributor

So file organization question:

We've been organizing things by platform/build_system/component. Like "linux/bazel/bindings". That's the format for the directory structure, build badges, etc. Implicitly "gcp_ubuntu" here is a stand-in for linux (it's what Kokoro calls the runner cluster type, so internally that directory name is load-bearing), but when cross-compiling this doesn't fit as nicely, since we're still running the build on gcp_ubuntu, just with a different toolchain. Should this be in and "android/cmake" directory instead of "cmake/android"? That feels a little silly since it has the most in common with the other cmake build, but it isn't really referencing it. We really just need a DAG filesystem :-P But having cmake/android next to cmake/core is going to be confusing I think.

More generally, I kind of want to move the kokoro directory out of the top-level and into build_tools. If I'm doing that anyway, I'll have to deal with all the annoying pointers between things. Maybe we should reorganize like "cluster/platform/build_system/component":

- build_tools
  - kokoro
    - gcp_ubuntu
      - linux
        - bazel
          - core
          - bindings
          - integrations
        - cmake
          // Subdirs iff we split the build
      - android
        - cmake
          // Subdirs iff we split the build
    - gcp_windows
      - windows
        - bazel
          // ...
        - cmake

And I think the docker containers and build scripts should follow the same pattern minus the leading "cluster", since that's just a Kokoro thing. The gcr paths should be folders (slash-separated) instead of dash-separated.

@phoenix-meadowlark Thoughts?

The immediate question is whether this should be "android/cmake" instead of "cmake/android"

That all sounds good to me. Are there any other platforms that we could build for in gcp_windows? Either way I think it's good to keep that for symmetry.

@antiagainst

Copy link
Copy Markdown
Member Author

I don't have a particular opinion towards this, so either way works for me. :) @GMNGeoffrey let me know when you think I should land this. It's clear on my side now.

@antiagainst
antiagainst requested a review from GMNGeoffrey June 30, 2020 17:08
@GMNGeoffrey

Copy link
Copy Markdown
Member

That all sounds good to me. Are there any other platforms that we could build for in gcp_windows? Either way I think it's good to keep that for symmetry.

We could have cross-compiling on windows too.

Another option is to do "cluster/build_system/target_platform/component". Actually maybe the only reason I had target platform first was because I was conflating it with Kokoro cluster type.

- build_tools
  - kokoro
    - gcp_ubuntu
      - bazel
        - linux
          - core
          - bindings
          - integrations
      - cmake
        - linux
          // Subdirs iff we split the build
        - android_arm64
          // Subdirs iff we split the build
    - gcp_windows
      - bazel
        - windows
          // ...
      - cmake
        - windows
        - android_arm64

@GMNGeoffrey

Copy link
Copy Markdown
Member

I don't have a particular opinion towards this, so either way works for me. :) @GMNGeoffrey let me know when you think I should land this. It's clear on my side now.

Are we going to target other android CPU architectures, do you think? e.g. android_x86 or android_arm32? In that case it might be better to add the CPU architecture to the name as well. These things are kind of a pain to rename. Yet another naming option is to break cpu architecture out as a separate directory component from OS (android/arm64).

@ScottTodd
ScottTodd removed their request for review June 30, 2020 18:41
@antiagainst

antiagainst commented Jun 30, 2020 •

Copy link
Copy Markdown
Member Author

Are we going to target other android CPU architectures, do you think? e.g. android_x86 or android_arm32? In that case it might be better to add the CPU architecture to the name as well. These things are kind of a pain to rename. Yet another naming option is to break cpu architecture out as a separate directory component from OS (android/arm64).

I don't think we want to target android_arm32 or android_x86 anytime soon. android_arm64 will be the focus for quite some time. But it never hurts to be future proof though with some reasonable amount of extra work. :) Regarding android_arm64 vs android/arm64, I think the latter has the benefits that we can host some common across-arch files under android. So I have weak preference to android/arm64.

@benvanik

Copy link
Copy Markdown
Collaborator

We'll need android x86/64 ASAP (even if codegen is not great) as that's the fastest way to run the emulator and what any dependent project will be using for CI testing or local emulator development.

@antiagainst

Copy link
Copy Markdown
Member Author

Ah good point. Sorry missed that. :)

@antiagainst

Copy link
Copy Markdown
Member Author

So, should I put the newly added configurations under gcp_ubuntu/cmake/android/arm64 then? Let me know.

@GMNGeoffrey

Copy link
Copy Markdown
Member

So, should I put the newly added configurations under gcp_ubuntu/cmake/android/arm64 then? Let me know.

Yes please put it there :-)

@antiagainst

antiagainst commented Jul 1, 2020 •

Copy link
Copy Markdown
Member Author

So, should I put the newly added configurations under gcp_ubuntu/cmake/android/arm64 then? Let me know.

Yes please put it there :-)

Okay, there you go in 5c53b21. I put build.sh still under android/ but made it generic so other abi can still use it.

@GMNGeoffrey GMNGeoffrey 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.

I've got a presubmit build set up that we can manually trigger on this PR. Currently we need to push the docker image to GCR first though.

@phoenix-meadowlark

phoenix-meadowlark commented Jul 1, 2020 •

Copy link
Copy Markdown
Contributor

I've got a presubmit build set up that we can manually trigger on this PR. Currently we need to push the docker image to GCR first though.

Pushed to gcr.io/iree-oss/cmake-android:prod!

Edit: I also just manually triggered the presubmit since the last one was before the image was available.

@antiagainst

Copy link
Copy Markdown
Member Author

@GMNGeoffrey
GMNGeoffrey merged commit 44fd282 into iree-org:main Jul 1, 2020
@antiagainst
antiagainst deleted the kokoro-android branch July 1, 2020 21:20
ScottTodd pushed a commit to ScottTodd/iree that referenced this pull request Jul 6, 2020
…ee-org#2357)

This commit adds a new Dockerfile that inherits from the base
CMake Dockerfile and installs Android NDK. Kokoro build
configurations are added to use this Docker image to test cross
compilation towards Android.
This was referenced Jul 7, 2020
GMNGeoffrey added a commit that referenced this pull request Jul 22, 2020
This moves the entire `kokoro` directory under `build_tools` and
restructures the directories to consistently indicate features
of the build. Some previous discussion in
#2357

The structure is
`kokoro_cluster/build_system/os/target_architecture[/iree_component]`.
Subsequent PRs will move build scripts into these directories and make
docker image and build status badges follow the same naming conventions.

The old Kokoro directory structure with configs is preserved to allow
the existing job configs to still find the build configs they point at.
Once PRs are rebased past this commit on main, I will update the job
configs to point at the new locations and then delete the old directory.
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants