[PATCH] D146666: [CMake] Respect variables for specifying host tools even without LLVM_USE_HOST_TOOLS set

Martin Storsjö via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 23 00:55:13 PDT 2023


mstorsjo added a comment.

In D146666#4214857 <https://reviews.llvm.org/D146666#4214857>, @smeenai wrote:

> In D146666#4214806 <https://reviews.llvm.org/D146666#4214806>, @mstorsjo wrote:
>
>> In D146666#4214769 <https://reviews.llvm.org/D146666#4214769>, @smeenai wrote:
>>
>>> I'd need to learn more about the use case (I see you're awaiting a response on the issue), but I'm not a huge fan personally; it seems really weird to not be going through the standard CMake mechanisms for cross-compilation (setting a `CMAKE_SYSTEM_NAME`), and if you do that then this should work as expected. We should understand why LLVM_USE_HOST_TOOLS isn't being set automatically.
>>
>> Yeah, in one sense, that’s the correct thing to do. But on the other hand, even if I’m doing a simple native build, if I’m going out of my way to specify the path to these tools, perhaps we should respect it. We already do it somewhat inconsistently - AFAIK the variables do take effect for the tablegen family of tools without checking the LLVM_USE_HOST_TOOLS variables.
>
> The flip side could be that you have a shared configuration for all your builds that just sets that flag in case it's needed, and that shared config is used by both native and cross-compilation. Not sure how realistic that is either, but I can see someone being surprised the other way as well.

That's true - although if the provided tools are valid (up to date), it should be harmless to use them. It could possibly even speed up the build, if it could use the preexisting tools for generating headers without first needing to build the new tool (but it's possible that there are dependencies in place that force the new tools to be built first anyway).

In any case, if looking at historical behaviour, the tablegen tools have respected the setting without looking at `LLVM_USE_HOST_TOOLS` since forever - and still do, that part wasn't refactored in my commit, and the clang-tools-extra tools also used their individual settings without looking at `LLVM_USE_HOST_TOOLS` in 15.x. Previously it was only `mlir-linalg-ods-gen` which required `LLVM_USE_HOST_TOOLS` to be set.

So with long term behaviour vs surprises, my refactoring was the one that brought in the surprise change.

It's still of course important to use cmake correctly and make sure it's aware of the fact that the user is cross compiling - but I think I needlessly caused surprises/breakage for users here.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D146666/new/

https://reviews.llvm.org/D146666



More information about the llvm-commits mailing list