-
Notifications
You must be signed in to change notification settings - Fork 11k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[llvm][CMake] Introduce LLVM_RUNTIME_<project>_BUILD in CMake #88934
Conversation
c61dfb7
to
175d6e1
Compare
@petrhosek @delcypher Would have a bit of time to have a look at this PR? I would greatly appreciate your review. |
So, is this adding a variable that's used to detect if a project has "any" runtime enabled for it? I know for detecting |
In LLVM, we have runtimes and bootstrapping builds. The runtimes build uses https://github.com/llvm/llvm-project/tree/main/runtimes to build runtimes specified by The bootstrapping build uses https://github.com/llvm/llvm-project/tree/main/llvm/runtimes to first build a toolchain with projects specified by This patch only sets |
I do hope that this will simply this. For the OpenMP tests, one would also have to explicitly check the presence of "openmp" in LLVM_ENABLE_PROJECTS. After this, this will hopefully be not needed anymore. If you could have a look and see if this PR helps there, I'd appreciate that. |
Thanks to @petrhosek for the suggestion!
Thanks for taking the time to review and the explanation about the mechanics!
I have moved the code to runtimes/CMakeLists.txt now. Does that look better now? |
# Set LLVM_RUNTIME_<project>_BUILD variables if a sub-project is enabled to be built as | ||
# a runtime. As with LLVM_TOOL_<project>_BUILD, the LLVM_RUNTIME_<project>_BUILD variables | ||
# should be not directly used from the CMake configuration command line. | ||
foreach(proj ${LLVM_SUPPORTED_RUNTIMES}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't we need to check for each LLVM_RUNTIME_TARGETS
if RUNTIMES_<triple>_LLVM_ENABLE_RUNTIMES
is set?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good question. I'm not qualified to answer it, though.
It should be moved to |
Hm. When I do this, it does not seem that it is picked up and when adding a debugging message, CMake does not seem to go through
So, if I correctly understand your explanation above, then I'm doing a bootstrapping build with the above command line. I have to use a command line like this to trigger the code in
So, a bootstrapping build simply configures the request to build a runtime via Because then it would seem like code would need to be duplicated (or be moved to a CMake file that can be included in both |
…BUILD With this a build can now see if a runtime build has been requested as part of the bootstrap process. In such a build, LLVM_BOOTSTRAP_RUNTIME_..._BUILD will be set to tell the LLVM build system that a particular runtime as been configured. During the runtime build itself or when building as a runtime build, LLVM_RUNTIME_..._BUILD is set to show that a build of a runtime component has been requested.
I have implemented thing that way now. @petrhosek Please have a look and let me know that's an acceptable compromise to be as flexible as possible in detecting how builds are being configured. |
Yes, your understanding is correct.
No, I don't think this is desirable. The reason is that the bootstrapping build also supports more advanced scenarios such as the following:
This would invoke the runtimes build once for requested target, so simply setting Can you explain what the motivation behind introducing these variables is (and also ideally include it in the description of the PR)? I can try to think a better way we could address your needs but I need to understand the use case. |
Sure, one use case is to determine if, say, the OpenMP runtime was built and enable the tests for it. Right now config.have_openmp_rtl = ("@LLVM_TOOL_OPENMP_BUILD@" == "TRUE") However, there's no good way to detect and enable that test configuration if OpenMP is built via |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure about this approach.
It seems to me that you should instead have a parameter you pass to lit with --param
and then have it set from the CI cache you use to configure your build. That would prevent having to infer whether a project is being built or not.
The reason why I'm lukewarm about this change is that it adds yet another procedural aspect to our CMake builds, and we've been working hard to get rid of that. We want to move towards more declarative (and more modern) CMake constructs where we define targets and avoid global state and logic, and this basically introduces another way to add such logic. So while I don't 100% understand your use case and the constraints you have to solve it, this specific approach seems like the wrong one to me at a high level.
Closing this PR to research for a better way. |
This PR adds CMake code to set
LLVM_RUNTIME_<project>_BUILD
similar toLLVM_TOOL_<project>_BUILD
. This makes it easier to detect if a particular runtime build has been requested.