Skip to content

Add a IREE_ENABLE_CCACHE build option. OFF by default. - #3689

Merged
bjacob merged 2 commits into
iree-org:mainfrom
bjacob:ccache
Nov 3, 2020
Merged

bjacob merged 2 commits into
iree-org:mainfrom
bjacob:ccache

Conversation

@bjacob

@bjacob bjacob commented Nov 2, 2020

Copy link
Copy Markdown
Collaborator

If enabled, this will try to detect ccache, and if found, CMake will
be told to use it. No-op if ccache is not found.

@bjacob
bjacob requested review from ScottTodd and benvanik November 2, 2020 20:40
@google-cla google-cla Bot added the cla: yes label Nov 2, 2020
Comment thread CMakeLists.txt Outdated
option(IREE_BUILD_EXPERIMENTAL "Builds experimental projects." OFF)
option(IREE_ENABLE_CCACHE "Use ccache if installed to speed up rebuilds." OFF)

if (${IREE_ENABLE_CCACHE})

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.

can you move if() down in the file to someplace else we set things like this? it's nice to have all the options a human needs to read up in one place at the top of the file so you don't have to go hunting for them

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Actually the options are already grouped in different sections, and I had the wrong section. Moved.

If enabled, this will try to detect ccache, and if found, CMake will
be told to use it. No-op if ccache is not found.
@ScottTodd ScottTodd added the cmake label Nov 3, 2020
@bjacob
bjacob merged commit e694d95 into iree-org:main Nov 3, 2020
@hanhanW hanhanW mentioned this pull request Nov 3, 2020
@GMNGeoffrey GMNGeoffrey added the infrastructure Relating to build systems, CI, or testing label May 11, 2021
@GMNGeoffrey

GMNGeoffrey commented Nov 23, 2022 •

Copy link
Copy Markdown
Member

Hey digging this old thing up. I'm looking to use sccache in the CI (https://github.com/mozilla/sccache). Couple questions:

  1. Why did you make this noop if ccache isn't found? I think if the user specifically added a setting requesting ccache, it would make sense to error if it's not found. Another option would be to have an "auto" mode that uses ccache iff it's on the path.
  2. Why RULE_LAUNCH_COMPILE instead of CMAKE_<LANG>_COMPILER_LAUNCHER? Seems like the latter is preferred: https://cmake.org/cmake/help/latest/prop_gbl/RULE_LAUNCH_COMPILE.html
  3. Why does this exist at all? Unless we're doing something fancy like enabling it automatically, I don't think there's much benefit in making this a project-specific setting. Users already have the builtin variables they can use. I guess this was because it RULE_LAUNCH_COMPILE is a property and so users couldn't set it?

So, proposals:

  1. Remove this. Let users use the built-in commands
  2. Add something that uses ccache or sccache if it finds one on the path. Requires that we set some prioritization between those. Maybe put this behind a variable IREE_DETECT_COMPILER_LAUNCHER. Default on unless a CMAKE_<LANG>_COMPILER_LAUNCHER variable is set.
  3. Since this is a C and C++ project and most compiler launchers do both, we could create IREE_COMPILER_LAUNCHER. Default auto (detect), otherwise set CMAKE_C_COMPILER_LAUNCHER and CMAKE_CXX_COMPILER_LAUNCHER to that value. This seems like a lot of magic to avoid someone having to pass an extra arg in their configure command though. I think cmake presets are a better solution for this.

@GMNGeoffrey

Copy link
Copy Markdown
Member

Oh even better CMAKE_<LANG>_COMPILER_LAUNCHER can be set from environment variables, so there's no need to add it to the configure line. I think we should drop this option and just use that

@bjacob

bjacob commented Nov 23, 2022

Copy link
Copy Markdown
Collaborator Author

Re questions:

  1. I don't remember, sorry. I agree with you that explicit failure is probably best here.
  2. I also don't remember the details. Probably I played a bit with both and settled with the first thing that seemed to work without properly exploring all ramifications.
  3. I think I agree, now. There are many ways that ccache can be enabled and as you say, some don't require any custom logic in our CMakeLists, and it's neater indeed to be able to keep that strictly a user-side setting.

Re proposals +1 to everything you deem best. Thanks for caring about this issue, you know much more than me at this point!

@GMNGeoffrey

Copy link
Copy Markdown
Member

Sounds good, thanks :-) Just wanted to make sure I wasn't missing some background here

GMNGeoffrey added a commit that referenced this pull request Nov 24, 2022
This setting uses `RULE_LAUNCH_COMPILE` which is discouraged:
https://cmake.org/cmake/help/latest/prop_gbl/RULE_LAUNCH_COMPILE.html.
It's also unnecessary. As of CMake 3.4, the
`CMAKE_<LANG>_COMPILER_LAUNCHER` can be used to set the compiler
launcher per language. They can be set as a configuration option or via
an environment variable. There's really no reason for us to have a
project-specific configuration for this.

While I was here, I made it an error if `IREE_ENABLE_CCACHE` is set and
`ccache` is not found. This is an easy case where we can tell people to
stop using it :-)

See some discussion in #3689
@stellaraccident

Copy link
Copy Markdown
Collaborator

Oh even better CMAKE_<LANG>_COMPILER_LAUNCHER can be set from environment variables, so there's no need to add it to the configure line. I think we should drop this option and just use that

Because I work across projects a lot, I end up using these env vars (or setting explicitly on the configure line) a lot. The only time I use the project specific ones are even I can't remember to spell the right one ;)

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