Skip to content

Add CMake guards to allow building just IREE's runtime - #4279

Merged
not-jenni merged 5 commits into
iree-org:mainfrom
not-jenni:iree-runtime
Dec 24, 2020
Merged

not-jenni merged 5 commits into
iree-org:mainfrom
not-jenni:iree-runtime

Conversation

@not-jenni

Copy link
Copy Markdown
Contributor

The runtime can be built by setting IREE_BUILD_COMPILER=OFF and IREE_ENABLE_MLIR=OFF. Fixes #4155

Comment thread CMakeLists.txt Resolved
Comment thread iree/modules/check/test/BUILD Resolved
Comment thread CMakeLists.txt Resolved
Comment thread iree/modules/check/test/BUILD Resolved

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

lgtm once Bazel builds are green again, see comment

Comment thread iree/modules/strings/BUILD Resolved
Comment thread iree/modules/strings/BUILD Outdated

iree_cmake_extra_content(
content = """
if(${IREE_BUILD_COMPILER} AND ${IREE_BUILD_TESTS})

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.

Drop the indent. It makes the indenting in the cmake file weird. I suggested textwrap.dedent to Scott when this was introduced for this reason

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Like this?

Untitled

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.

Uh not sure how that will work with the newlines. If it works, then great :-) I was thinking like https://github.com/google/iree/blob/4ca12072652be6785075e8e6e48052347f9de784/iree/hal/vulkan/BUILD#L26-L30 The main thing is just not having the if be indented weird. in the CMake file.

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.

Wait I just read this again and now I see that GitHub just makes everything look indented 2 spaces... I have it backwards

The thing that is weird is that the stuff inside the if block in the cmake file isn't indented, which makes it hard to track. I don't see an easy way to fix that, so just ignore me.

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.

One way around this is to make this a guard statement instead and put all the compiler stuff at the bottom. Then this would be

Suggested change
if(${IREE_BUILD_COMPILER} AND ${IREE_BUILD_TESTS})
if(NOT ${IREE_BUILD_COMPILER})
return()
endif()

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I switched to this for all files except iree/vm/BUILD, where it was a bit more complicated

@GMNGeoffrey

Copy link
Copy Markdown
Member

Really great to finally see this dependency broken. Thanks Jenni!

Comment thread iree/vm/BUILD
# ],
# )

iree_cmake_extra_content(

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

(not here, but in the future) would be nice to have explicit helpers for this - like iree_cmake_if("${IREE_BUILD_COMPILER} AND ${IREE_BUILD_TESTS}") / iree_cmake_endif()

Comment thread iree/modules/strings/CMakeLists.txt Outdated
PUBLIC
)

if(${IREE_BUILD_COMPILER} AND ${IREE_BUILD_TESTS})

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.

IREE_BUILD_TESTS is redundant here. All tests are already gated on that

Comment thread iree/modules/tensorlist/BUILD Outdated

iree_cmake_extra_content(
content = """
if(${IREE_BUILD_COMPILER} AND ${IREE_BUILD_TESTS})

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.

Instead of IREE_BUILD_TESTS, you can add testonly = True to the testonly rule. Then it will only get built if tests are enabled because of https://github.com/google/iree/blob/4ca12072652be6785075e8e6e48052347f9de784/build_tools/cmake/iree_bytecode_module.cmake#L46-L48

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I believe testonly = True isn't currently supported for iree_bytecode_module in bazel_to_cmake, so can I leave the check for IREE_BUILD_TESTS for now and update this and bazel_to_cmake in a followup PR?

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.

Ah you're right. SG, thanks :-)

Comment thread iree/modules/strings/BUILD Outdated

iree_cmake_extra_content(
content = """
if(${IREE_BUILD_COMPILER} AND ${IREE_BUILD_TESTS})

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.

One way around this is to make this a guard statement instead and put all the compiler stuff at the bottom. Then this would be

Suggested change
if(${IREE_BUILD_COMPILER} AND ${IREE_BUILD_TESTS})
if(NOT ${IREE_BUILD_COMPILER})
return()
endif()

@GMNGeoffrey

Copy link
Copy Markdown
Member

Want to go ahead and merge this? The clang-format issue is not you (fixed in #4302), but not worth rebasing/merging to pick that up. As someone currently testing the cmake runtime build and having to build all of LLVM for no reason, would love to see this go in :-D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Remove or add CMake guards for remaining runtime dependencies on LLVM/MLIR

4 participants