[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
Tue Jan 24 00:41:01 PST 2023


mstorsjo added a comment.

In D142404#4075147 <https://reviews.llvm.org/D142404#4075147>, @phosek wrote:

> Since we're already on this topic, in D137451 <https://reviews.llvm.org/D137451> it was also brought up that having both `LLVM_DEFAULT_TARGET_TRIPLE` and `LLVM_TARGET_TRIPLE` is confusing and that perhaps we should only have one (presumably the latter).

Hmm, I haven't quite followed exactly what `LLVM_TARGET_TRIPLE` is and which parts of the code it affects. I don't offhand know where it would be relevant, since a LLVM build supports multiple targets.

I agree that `LLVM_DEFAULT_TARGET_TRIPLE` is confusing and IMO incorrect for the runtimes. But for building LLVM/Clang level code generation, it's a totally valid option though.

> In runtimes, we currently use `LLVM_DEFAULT_TARGET_TRIPLE` to construct the installation path but that's a ongoing source of issues. Neither `LLVM_HOST_TRIPLE` nor `LLVM_TARGET_TRIPLE` seem like the right replacement

IMO, if we'd follow the autoconf build/host/target nomenclature strictly, then `LLVM_HOST_TRIPLE` would be the correct name for it; within the context of the runtimes, that denotes what host the compiled code will be running on.

> since those variables are exported in `LLVMConfig.cmake` but in the runtimes build (which uses `LLVMConfig.cmake`)

Ok, so the `LLVMConfig.cmake` from the surrounding LLVM build ends up included in the cmake builds of the individual cross built runtimes, contaminating these variables with values from the host? That's kinda non-ideal.

IMO, we ideally should avoid including that entirely, or at least filter out such settings which are incorrect here. Anything within LLVMConfig.cmake which is about the host of the LLVM build (arch/executable suffix/triples/etc) should be filtered out altogether. At most some parts that relate to the autoconf-labelled "build" environment can be reasonable to include, since the autoconf "build" environment is the same across both - I guess built tools like FileCheck are propagated this way?

> we need to set the triple based on the host we're compiling runtimes for, not based on the host we compiled LLVM for.
>
> The solution I came up with in D137451 <https://reviews.llvm.org/D137451> is introducing a new variable `LLVM_RUNTIME_TRIPLE` to avoid conflict with any of the existing variables. Do you have any other suggestions?

I guess that sounds reasonable. `LLVM_DEFAULT_TARGET_TRIPLE` is at least kinda wrong. I haven't tried to track what `LLVM_TARGET_TRIPLE` actually does though, but either that or an entirely new variable is probably fine. `LLVM_HOST_TRIPLE` would be the technically correct but I guess it's messy, especially as long as compiler-rt still is expected to work in a somewhat-cross nature as a project within the main llvm build.


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