[PATCH] D41580: CMAKE: Add flags to skip building NATIVE tools

Don Hinton via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 27 11:25:56 PST 2017


hintonda added a comment.

In https://reviews.llvm.org/D41580#964323, @martell wrote:

> In https://reviews.llvm.org/D41580#964147, @hintonda wrote:
>
> > I like your idea, but can't you do this without adding new flags?
> >
> > You already have to pass `-D(CLANG|LLVM)_TABLEGEN` which prevents them from getting built.  llvm-config is a little different in that you need to pass `-D_LLVM_CONFIG_EXE` since `project` is undefined in tools/llvm-config,  but adding a test for `${project}_LLVM_CONFIG_EXE` is consistent and should work as well.  Perhaps this needs to be refactored as well, so you can pass `-DLLVM_CONFIG_EXE` instead of `-D_LLVM_CONFIG_EXE`.
>
>
> I was originally trying to use `-D(CLANG|LLVM)_TABLEGEN` but clang would complain about no rule to build a target.
>  This either was fixed very very recently (like in the last day or two) or the following set of extra flags fix this
>
>   -DCMAKE_SYSTEM_PROGRAM_PATH=$TOOLCHAIN_PREFIX/bin
>   -DCMAKE_FIND_ROOT_PATH=$TOOLCHAIN_PREFIX
>   -DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM=NEVER
>   -DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=ONLY
>   -DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=ONLY
>   
>
> I can probably drop that part of the patch now, though I would like to know how it was fixed.


I don't think any of this has changed recently, and can't reproduce the problem you mention.  However, the check uses STREQUAL, so you must add a path when setting (CLANG|LLVM)_TABLEGEN.  If you passed `llvm-config`, it would succeed and build the NATIVE version.  That bit of code could be refactored to respect the `-D` flag.

Also, the CMAKE_FIND_* variables only affect how the find_xxx* functions work, so I don't think they make any difference in this context.

> When building llvm project out of tree you are able to specify `-DLLVM_CONFIG_PATH`, this is true for both lld and clang on a quick look.
>  It would probably be better to use `LLVM_CONFIG_PATH` to keep the flags consistent across projects rather than using `_LLVM_CONFIG_EXE`

I don't see `LLVM_CONFIG_PATH` being used anywhere.  I see examples of where it's set, but not used.  Could you give me a pointer to where it is used?

Btw, use of `${project}` variable in llvm/tools/llvm-config/CMakeLists.txt looks like a bug to me, in the sense that it is never defined and just melts away.  Perhaps removing it and the `_` prefix from `_LLVM_CONFIG_EXE` would simplify everything.


Repository:
  rL LLVM

https://reviews.llvm.org/D41580





More information about the llvm-commits mailing list