[PATCH] D142404: [docs] Prefer setting LLVM_HOST_TRIPLE instead of LLVM_DEFAULT_TARGET_TRIPLE and LLVM_TARGET_ARCH

Martin Storsjö via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 23 14:32:41 PST 2023


mstorsjo added a comment.

In D142404#4074961 <https://reviews.llvm.org/D142404#4074961>, @beanz wrote:

> The point of the existing option is to tell you how to setup the default target (the target implied when no target is specified) to be the native architecture of your cross target rather than the host (which is what it defaults to).

If I cross compile a LLVM to run on Linux/AArch64 and configure it with `LLVM_HOST_TRIPLE=aarch64-linux-gnu`, then this also implicitly sets `LLVM_DEFAULT_TARGET_TRIPLE` to the same, unless I have manually set another value for `LLVM_DEFAULT_TARGET_TRIPLE` - or do you disagree on this bit?

> In theory, `LLVM_HOST_TRIPLE` should be inferable from the build configuration environment so you should never need to specify it explicitly.

`LLVM_HOST_TRIPLE` is generally inferrable when _not_ cross compiling, but when cross compiling, AFAIK we don't quite infer it. If `LLVM_HOST_TRIPLE` isn't set, it's defaulted to `LLVM_INFERRED_HOST_TRIPLE` which is set with `get_host_triple`: https://github.com/llvm/llvm-project/blob/35912ad39d8a0f244f36d24526ec70b8b028a6e0/llvm/cmake/config-ix.cmake#L441-L445 For some targets/OSes, `get_host_triple` does try to figure out the cross target host triple, but for the generic fallback case, it's simply set to the build host by running the `config.guess` script: https://github.com/llvm/llvm-project/blob/35912ad39d8a0f244f36d24526ec70b8b028a6e0/llvm/cmake/modules/GetHostTriple.cmake#L48

So for e.g. cross compilation to Linux targets, as far as I can see, you do need to set `LLVM_HOST_TRIPLE` manually as it will otherwise default to that of the machine where you are doing the cross compilation.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142404



More information about the llvm-commits mailing list